st/mesa: add state validation for compute shaders
This binds atomics, constants, samplers, ssbos, textures and ubos. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
@@ -99,6 +99,12 @@ static const struct st_tracked_state *render_atoms[] =
|
||||
static const struct st_tracked_state *compute_atoms[] =
|
||||
{
|
||||
&st_update_cp,
|
||||
&st_update_compute_texture,
|
||||
&st_update_sampler, /* depends on update_compute_texture for swizzle */
|
||||
&st_update_cs_constants,
|
||||
&st_bind_cs_ubos,
|
||||
&st_bind_cs_atomics,
|
||||
&st_bind_cs_ssbos,
|
||||
};
|
||||
|
||||
|
||||
|
@@ -72,26 +72,31 @@ extern const struct st_tracked_state st_update_vertex_texture;
|
||||
extern const struct st_tracked_state st_update_geometry_texture;
|
||||
extern const struct st_tracked_state st_update_tessctrl_texture;
|
||||
extern const struct st_tracked_state st_update_tesseval_texture;
|
||||
extern const struct st_tracked_state st_update_compute_texture;
|
||||
extern const struct st_tracked_state st_update_fs_constants;
|
||||
extern const struct st_tracked_state st_update_gs_constants;
|
||||
extern const struct st_tracked_state st_update_tes_constants;
|
||||
extern const struct st_tracked_state st_update_tcs_constants;
|
||||
extern const struct st_tracked_state st_update_vs_constants;
|
||||
extern const struct st_tracked_state st_update_cs_constants;
|
||||
extern const struct st_tracked_state st_bind_fs_ubos;
|
||||
extern const struct st_tracked_state st_bind_vs_ubos;
|
||||
extern const struct st_tracked_state st_bind_gs_ubos;
|
||||
extern const struct st_tracked_state st_bind_tcs_ubos;
|
||||
extern const struct st_tracked_state st_bind_tes_ubos;
|
||||
extern const struct st_tracked_state st_bind_cs_ubos;
|
||||
extern const struct st_tracked_state st_bind_fs_atomics;
|
||||
extern const struct st_tracked_state st_bind_vs_atomics;
|
||||
extern const struct st_tracked_state st_bind_gs_atomics;
|
||||
extern const struct st_tracked_state st_bind_tcs_atomics;
|
||||
extern const struct st_tracked_state st_bind_tes_atomics;
|
||||
extern const struct st_tracked_state st_bind_cs_atomics;
|
||||
extern const struct st_tracked_state st_bind_fs_ssbos;
|
||||
extern const struct st_tracked_state st_bind_vs_ssbos;
|
||||
extern const struct st_tracked_state st_bind_gs_ssbos;
|
||||
extern const struct st_tracked_state st_bind_tcs_ssbos;
|
||||
extern const struct st_tracked_state st_bind_tes_ssbos;
|
||||
extern const struct st_tracked_state st_bind_cs_ssbos;
|
||||
extern const struct st_tracked_state st_update_pixel_transfer;
|
||||
extern const struct st_tracked_state st_update_tess;
|
||||
|
||||
|
@@ -156,3 +156,21 @@ const struct st_tracked_state st_bind_tes_atomics = {
|
||||
},
|
||||
bind_tes_atomics
|
||||
};
|
||||
|
||||
static void
|
||||
bind_cs_atomics(struct st_context *st)
|
||||
{
|
||||
struct gl_shader_program *prog =
|
||||
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
|
||||
|
||||
st_bind_atomics(st, prog, PIPE_SHADER_COMPUTE);
|
||||
}
|
||||
|
||||
const struct st_tracked_state st_bind_cs_atomics = {
|
||||
"st_bind_cs_atomics",
|
||||
{
|
||||
0,
|
||||
ST_NEW_COMPUTE_PROGRAM | ST_NEW_ATOMIC_BUFFER,
|
||||
},
|
||||
bind_cs_atomics
|
||||
};
|
||||
|
@@ -61,7 +61,8 @@ void st_upload_constants( struct st_context *st,
|
||||
shader_type == PIPE_SHADER_FRAGMENT ||
|
||||
shader_type == PIPE_SHADER_GEOMETRY ||
|
||||
shader_type == PIPE_SHADER_TESS_CTRL ||
|
||||
shader_type == PIPE_SHADER_TESS_EVAL);
|
||||
shader_type == PIPE_SHADER_TESS_EVAL ||
|
||||
shader_type == PIPE_SHADER_COMPUTE);
|
||||
|
||||
/* update constants */
|
||||
if (params && params->NumParameters) {
|
||||
@@ -226,6 +227,28 @@ const struct st_tracked_state st_update_tes_constants = {
|
||||
update_tes_constants /* update */
|
||||
};
|
||||
|
||||
/* Compute shader:
|
||||
*/
|
||||
static void update_cs_constants(struct st_context *st )
|
||||
{
|
||||
struct st_compute_program *cp = st->cp;
|
||||
struct gl_program_parameter_list *params;
|
||||
|
||||
if (cp) {
|
||||
params = cp->Base.Base.Parameters;
|
||||
st_upload_constants( st, params, PIPE_SHADER_COMPUTE );
|
||||
}
|
||||
}
|
||||
|
||||
const struct st_tracked_state st_update_cs_constants = {
|
||||
"st_update_cs_constants", /* name */
|
||||
{ /* dirty */
|
||||
_NEW_PROGRAM_CONSTANTS, /* mesa */
|
||||
ST_NEW_COMPUTE_PROGRAM, /* st */
|
||||
},
|
||||
update_cs_constants /* update */
|
||||
};
|
||||
|
||||
static void st_bind_ubos(struct st_context *st,
|
||||
struct gl_shader *shader,
|
||||
unsigned shader_type)
|
||||
@@ -363,3 +386,24 @@ const struct st_tracked_state st_bind_tes_ubos = {
|
||||
},
|
||||
bind_tes_ubos
|
||||
};
|
||||
|
||||
static void bind_cs_ubos(struct st_context *st)
|
||||
{
|
||||
struct gl_shader_program *prog =
|
||||
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
|
||||
|
||||
if (!prog)
|
||||
return;
|
||||
|
||||
st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE],
|
||||
PIPE_SHADER_COMPUTE);
|
||||
}
|
||||
|
||||
const struct st_tracked_state st_bind_cs_ubos = {
|
||||
"st_bind_cs_ubos",
|
||||
{
|
||||
0,
|
||||
ST_NEW_COMPUTE_PROGRAM | ST_NEW_UNIFORM_BUFFER,
|
||||
},
|
||||
bind_cs_ubos
|
||||
};
|
||||
|
@@ -321,6 +321,14 @@ update_samplers(struct st_context *st)
|
||||
st->state.samplers[PIPE_SHADER_TESS_EVAL],
|
||||
&st->state.num_samplers[PIPE_SHADER_TESS_EVAL]);
|
||||
}
|
||||
if (ctx->ComputeProgram._Current) {
|
||||
update_shader_samplers(st,
|
||||
PIPE_SHADER_COMPUTE,
|
||||
&ctx->ComputeProgram._Current->Base,
|
||||
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
|
||||
st->state.samplers[PIPE_SHADER_COMPUTE],
|
||||
&st->state.num_samplers[PIPE_SHADER_COMPUTE]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -194,3 +194,24 @@ const struct st_tracked_state st_bind_tes_ssbos = {
|
||||
},
|
||||
bind_tes_ssbos
|
||||
};
|
||||
|
||||
static void bind_cs_ssbos(struct st_context *st)
|
||||
{
|
||||
struct gl_shader_program *prog =
|
||||
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
|
||||
|
||||
if (!prog)
|
||||
return;
|
||||
|
||||
st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE],
|
||||
PIPE_SHADER_COMPUTE);
|
||||
}
|
||||
|
||||
const struct st_tracked_state st_bind_cs_ssbos = {
|
||||
"st_bind_cs_ssbos",
|
||||
{
|
||||
0,
|
||||
ST_NEW_COMPUTE_PROGRAM | ST_NEW_STORAGE_BUFFER,
|
||||
},
|
||||
bind_cs_ssbos
|
||||
};
|
||||
|
@@ -534,6 +534,22 @@ update_tesseval_textures(struct st_context *st)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
update_compute_textures(struct st_context *st)
|
||||
{
|
||||
const struct gl_context *ctx = st->ctx;
|
||||
|
||||
if (ctx->ComputeProgram._Current) {
|
||||
update_textures(st,
|
||||
MESA_SHADER_COMPUTE,
|
||||
&ctx->ComputeProgram._Current->Base,
|
||||
ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
|
||||
st->state.sampler_views[PIPE_SHADER_COMPUTE],
|
||||
&st->state.num_sampler_views[PIPE_SHADER_COMPUTE]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const struct st_tracked_state st_update_fragment_texture = {
|
||||
"st_update_texture", /* name */
|
||||
{ /* dirty */
|
||||
@@ -582,3 +598,13 @@ const struct st_tracked_state st_update_tesseval_texture = {
|
||||
},
|
||||
update_tesseval_textures /* update */
|
||||
};
|
||||
|
||||
|
||||
const struct st_tracked_state st_update_compute_texture = {
|
||||
"st_update_compute_texture", /* name */
|
||||
{ /* dirty */
|
||||
_NEW_TEXTURE, /* mesa */
|
||||
ST_NEW_COMPUTE_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
|
||||
},
|
||||
update_compute_textures /* update */
|
||||
};
|
||||
|
Reference in New Issue
Block a user