diff options
author | Samuel Pitoiset <[email protected]> | 2016-01-05 23:53:30 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2016-02-13 16:01:01 +0100 |
commit | 805d92e54038255c145e464670d3352276ae27a9 (patch) | |
tree | 743ca7564b0b88a5786a896bf93ea45989290ea5 /src/mesa | |
parent | 61c87cd2c0698fad68e4a02c44cdcbd4fd00191a (diff) |
st/mesa: add state validation for compute shaders
This binds atomics, constants, samplers, ssbos, textures and ubos.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_atom.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom.h | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_atomicbuf.c | 18 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_constbuf.c | 46 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_sampler.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_storagebuf.c | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_texture.c | 26 |
7 files changed, 129 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 3427a92972f..8a04d747b13 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -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, }; diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index ef33645eaa7..ac1aae8e6c2 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -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; diff --git a/src/mesa/state_tracker/st_atom_atomicbuf.c b/src/mesa/state_tracker/st_atom_atomicbuf.c index 1c30d1fb701..d83c3960640 100644 --- a/src/mesa/state_tracker/st_atom_atomicbuf.c +++ b/src/mesa/state_tracker/st_atom_atomicbuf.c @@ -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 +}; diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 66811d29c29..407dfd31c80 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -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 +}; diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 94231cf1946..82dcf5ee0ca 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -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]); + } } diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c index f165cc3e0a1..37b4c4d256d 100644 --- a/src/mesa/state_tracker/st_atom_storagebuf.c +++ b/src/mesa/state_tracker/st_atom_storagebuf.c @@ -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 +}; diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index 3e3775200a8..b4e6f9b639a 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -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 */ +}; |