mesa: add mesh shader states

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36976>
This commit is contained in:
Qiang Yu 2025-03-05 11:11:57 +08:00
parent 6459dacb8b
commit a47c70ce42
10 changed files with 193 additions and 1 deletions

View file

@ -2202,6 +2202,30 @@ struct gl_compute_program_state
};
/**
* Context state for task programs.
*/
struct gl_task_program_state
{
/** Currently enabled and valid program (including internal programs
* and compiled shader programs).
*/
struct gl_program *_Current;
};
/**
* Context state for mesh programs.
*/
struct gl_mesh_program_state
{
/** Currently enabled and valid program (including internal programs
* and compiled shader programs).
*/
struct gl_program *_Current;
};
/**
* ATI_fragment_shader runtime state
*/
@ -3415,6 +3439,8 @@ struct gl_context
struct gl_tess_ctrl_program_state TessCtrlProgram;
struct gl_tess_eval_program_state TessEvalProgram;
struct gl_ati_fragment_shader_state ATIFragmentShader;
struct gl_task_program_state TaskProgram;
struct gl_mesh_program_state MeshProgram;
struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */
struct gl_pipeline_object Shader; /**< GLSL shader object state */

View file

@ -151,6 +151,24 @@ st_bind_cs_atomics(struct st_context *st)
st_bind_atomics(st, prog, MESA_SHADER_COMPUTE);
}
void
st_bind_ts_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TASK];
st_bind_atomics(st, prog, MESA_SHADER_TASK);
}
void
st_bind_ms_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_MESH];
st_bind_atomics(st, prog, MESA_SHADER_MESH);
}
void
st_bind_hw_atomic_buffers(struct st_context *st)
{

View file

@ -81,7 +81,9 @@ st_upload_constants(struct st_context *st, struct gl_program *prog, mesa_shader_
stage == MESA_SHADER_GEOMETRY ||
stage == MESA_SHADER_TESS_CTRL ||
stage == MESA_SHADER_TESS_EVAL ||
stage == MESA_SHADER_COMPUTE);
stage == MESA_SHADER_COMPUTE ||
stage == MESA_SHADER_TASK ||
stage == MESA_SHADER_MESH);
/* update the ATI constants before rendering */
if (stage == MESA_SHADER_FRAGMENT && prog->ati_fs) {
@ -264,6 +266,24 @@ st_update_cs_constants(struct st_context *st)
MESA_SHADER_COMPUTE);
}
/* Task shader:
*/
void
st_update_ts_constants(struct st_context *st)
{
st_upload_constants(st, st->ctx->TaskProgram._Current,
MESA_SHADER_TASK);
}
/* Mesh shader:
*/
void
st_update_ms_constants(struct st_context *st)
{
st_upload_constants(st, st->ctx->MeshProgram._Current,
MESA_SHADER_MESH);
}
static void
st_bind_ubos(struct st_context *st, struct gl_program *prog,
mesa_shader_stage shader_type)
@ -361,3 +381,21 @@ st_bind_cs_ubos(struct st_context *st)
st_bind_ubos(st, prog, MESA_SHADER_COMPUTE);
}
void
st_bind_ts_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TASK];
st_bind_ubos(st, prog, MESA_SHADER_TASK);
}
void
st_bind_ms_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_MESH];
st_bind_ubos(st, prog, MESA_SHADER_MESH);
}

View file

@ -222,3 +222,19 @@ void st_bind_cs_images(struct st_context *st)
st_bind_images(st, prog, MESA_SHADER_COMPUTE);
}
void st_bind_ts_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TASK];
st_bind_images(st, prog, MESA_SHADER_TASK);
}
void st_bind_ms_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_MESH];
st_bind_images(st, prog, MESA_SHADER_MESH);
}

View file

@ -7,6 +7,8 @@ ST_STATE(ST_NEW_GS_STATE, st_update_gp)
ST_STATE(ST_NEW_TES_STATE, st_update_tep)
ST_STATE(ST_NEW_TCS_STATE, st_update_tcp)
ST_STATE(ST_NEW_VS_STATE, st_update_vp)
ST_STATE(ST_NEW_TS_STATE, st_update_tp)
ST_STATE(ST_NEW_MS_STATE, st_update_mp)
ST_STATE(ST_NEW_POLY_STIPPLE, st_update_polygon_stipple)
ST_STATE(ST_NEW_WINDOW_RECTANGLES, st_update_window_rectangles)
@ -17,6 +19,8 @@ ST_STATE(ST_NEW_FS_SAMPLER_VIEWS, st_update_fragment_textures)
ST_STATE(ST_NEW_GS_SAMPLER_VIEWS, st_update_geometry_textures)
ST_STATE(ST_NEW_TCS_SAMPLER_VIEWS, st_update_tessctrl_textures)
ST_STATE(ST_NEW_TES_SAMPLER_VIEWS, st_update_tesseval_textures)
ST_STATE(ST_NEW_TS_SAMPLER_VIEWS, st_update_task_textures)
ST_STATE(ST_NEW_MS_SAMPLER_VIEWS, st_update_mesh_textures)
/* Non-compute samplers. */
ST_STATE(ST_NEW_VS_SAMPLERS, st_update_vertex_samplers) /* depends on update_*_texture for swizzle */
@ -24,12 +28,16 @@ ST_STATE(ST_NEW_TCS_SAMPLERS, st_update_tessctrl_samplers) /* depends on update_
ST_STATE(ST_NEW_TES_SAMPLERS, st_update_tesseval_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_GS_SAMPLERS, st_update_geometry_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_FS_SAMPLERS, st_update_fragment_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_TS_SAMPLERS, st_update_task_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_MS_SAMPLERS, st_update_mesh_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_VS_IMAGES, st_bind_vs_images)
ST_STATE(ST_NEW_TCS_IMAGES, st_bind_tcs_images)
ST_STATE(ST_NEW_TES_IMAGES, st_bind_tes_images)
ST_STATE(ST_NEW_GS_IMAGES, st_bind_gs_images)
ST_STATE(ST_NEW_FS_IMAGES, st_bind_fs_images)
ST_STATE(ST_NEW_TS_IMAGES, st_bind_ts_images)
ST_STATE(ST_NEW_MS_IMAGES, st_bind_ms_images)
ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer_state) /* depends on update_*_texture and bind_*_images */
ST_STATE(ST_NEW_BLEND, st_update_blend) /* depends on update_framebuffer_state */
@ -44,18 +52,24 @@ ST_STATE(ST_NEW_TCS_CONSTANTS, st_update_tcs_constants)
ST_STATE(ST_NEW_TES_CONSTANTS, st_update_tes_constants)
ST_STATE(ST_NEW_GS_CONSTANTS, st_update_gs_constants)
ST_STATE(ST_NEW_FS_CONSTANTS, st_update_fs_constants)
ST_STATE(ST_NEW_TS_CONSTANTS, st_update_ts_constants)
ST_STATE(ST_NEW_MS_CONSTANTS, st_update_ms_constants)
ST_STATE(ST_NEW_VS_UBOS, st_bind_vs_ubos)
ST_STATE(ST_NEW_TCS_UBOS, st_bind_tcs_ubos)
ST_STATE(ST_NEW_TES_UBOS, st_bind_tes_ubos)
ST_STATE(ST_NEW_FS_UBOS, st_bind_fs_ubos)
ST_STATE(ST_NEW_GS_UBOS, st_bind_gs_ubos)
ST_STATE(ST_NEW_TS_UBOS, st_bind_ts_ubos)
ST_STATE(ST_NEW_MS_UBOS, st_bind_ms_ubos)
ST_STATE(ST_NEW_VS_ATOMICS, st_bind_vs_atomics)
ST_STATE(ST_NEW_TCS_ATOMICS, st_bind_tcs_atomics)
ST_STATE(ST_NEW_TES_ATOMICS, st_bind_tes_atomics)
ST_STATE(ST_NEW_FS_ATOMICS, st_bind_fs_atomics)
ST_STATE(ST_NEW_GS_ATOMICS, st_bind_gs_atomics)
ST_STATE(ST_NEW_TS_ATOMICS, st_bind_ts_atomics)
ST_STATE(ST_NEW_MS_ATOMICS, st_bind_ms_atomics)
/* SSBOs depend on the _atomics having been updated first in the
* !has_hw_atomics case.
@ -65,6 +79,8 @@ ST_STATE(ST_NEW_TCS_SSBOS, st_bind_tcs_ssbos)
ST_STATE(ST_NEW_TES_SSBOS, st_bind_tes_ssbos)
ST_STATE(ST_NEW_FS_SSBOS, st_bind_fs_ssbos)
ST_STATE(ST_NEW_GS_SSBOS, st_bind_gs_ssbos)
ST_STATE(ST_NEW_TS_SSBOS, st_bind_ts_ssbos)
ST_STATE(ST_NEW_MS_SSBOS, st_bind_ms_ssbos)
ST_STATE(ST_NEW_PIXEL_TRANSFER, st_update_pixel_transfer)
ST_STATE(ST_NEW_TESS_STATE, st_update_tess)

View file

@ -431,3 +431,27 @@ st_update_compute_samplers(struct st_context *st)
ctx->ComputeProgram._Current, NULL, NULL);
}
}
void
st_update_task_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->TaskProgram._Current) {
update_shader_samplers(st, MESA_SHADER_TASK,
ctx->TaskProgram._Current, NULL, NULL);
}
}
void
st_update_mesh_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->MeshProgram._Current) {
update_shader_samplers(st, MESA_SHADER_MESH,
ctx->MeshProgram._Current, NULL, NULL);
}
}

View file

@ -347,3 +347,21 @@ st_update_cp(struct st_context *st)
MESA_SHADER_COMPUTE, &st->cp);
cso_set_compute_shader_handle(st->cso_context, shader);
}
void
st_update_tp(struct st_context *st)
{
void *shader = st_update_common_program(st,
st->ctx->TaskProgram._Current,
MESA_SHADER_TASK, &st->tp);
cso_set_task_shader_handle(st->cso_context, shader);
}
void
st_update_mp(struct st_context *st)
{
void *shader = st_update_common_program(st,
st->ctx->MeshProgram._Current,
MESA_SHADER_MESH, &st->mp);
cso_set_mesh_shader_handle(st->cso_context, shader);
}

View file

@ -138,3 +138,19 @@ void st_bind_cs_ssbos(struct st_context *st)
st_bind_ssbos(st, prog, MESA_SHADER_COMPUTE);
}
void st_bind_ts_ssbos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TASK];
st_bind_ssbos(st, prog, MESA_SHADER_TASK);
}
void st_bind_ms_ssbos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_MESH];
st_bind_ssbos(st, prog, MESA_SHADER_MESH);
}

View file

@ -424,3 +424,21 @@ st_update_compute_textures(struct st_context *st)
ctx->ComputeProgram._Current);
}
}
void
st_update_task_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->TaskProgram._Current)
update_textures(st, MESA_SHADER_TASK, ctx->TaskProgram._Current);
}
void
st_update_mesh_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->MeshProgram._Current)
update_textures(st, MESA_SHADER_MESH, ctx->MeshProgram._Current);
}

View file

@ -273,6 +273,8 @@ struct st_context
struct gl_program *gp; /**< Currently bound geometry program */
struct gl_program *fp; /**< Currently bound fragment program */
struct gl_program *cp; /**< Currently bound compute program */
struct gl_program *tp; /**< Currently bound task program */
struct gl_program *mp; /**< Currently bound mesh program */
};
struct gl_program *current_program[MESA_SHADER_MESH_STAGES];
};