diff options
author | Timothy Arceri <[email protected]> | 2016-10-31 22:39:17 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-01-23 14:48:04 +1100 |
commit | c505d6d852220f4aaaee161465dd2c579647e672 (patch) | |
tree | d77bf00e32a00b310fa09399974f5a51f99be073 /src/mesa/state_tracker | |
parent | 31daeb5bf14334bc0d39f28c9102cd15d834abfc (diff) |
mesa: use gl_program for CurrentProgram rather than gl_shader_program
This makes much more sense and should be more performant in some
critical paths such as SSO validation which is called at draw time.
Previously the CurrentProgram array could have contained multiple
pointers to the same struct which was confusing and we would often
need to fish out the information we were really after from the
gl_program anyway.
Also it was error prone to depend on the _LinkedShader array for
programs in current use because a failed linking attempt will lose
the infomation about the current program in use which is still
valid.
V2: fix validate_io() to compare linked_stages rather than the
consumer and producer to decide if we are looking at inward
facing shader interfaces which don't need validation.
Acked-by: Edward O'Callaghan <[email protected]>
To avoid build regressions the following 2 patches were squashed in to
this commit:
mesa/meta: rewrite _mesa_shader_program_use() and _mesa_program_use()
These are rewritten to do what the function name suggests, that is
_mesa_shader_program_use() sets the use of all stage and
_mesa_program_use() sets the use of a single stage.
Reviewed-by: Lionel Landwerlin <[email protected]>
Acked-by: Edward O'Callaghan <[email protected]>
mesa: update active relinked program
This likely fixes a subroutine bug were
_mesa_shader_program_init_subroutine_defaults() would never have been
called for the relinked program as we previously just set
_NEW_PROGRAM as dirty and never called the _mesa_use* functions when
linking.
Acked-by: Edward O'Callaghan <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_atomicbuf.c | 20 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_constbuf.c | 43 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_image.c | 42 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_storagebuf.c | 48 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_compute.c | 4 |
5 files changed, 48 insertions, 109 deletions
diff --git a/src/mesa/state_tracker/st_atom_atomicbuf.c b/src/mesa/state_tracker/st_atom_atomicbuf.c index 93538b567f1..11fb84f1118 100644 --- a/src/mesa/state_tracker/st_atom_atomicbuf.c +++ b/src/mesa/state_tracker/st_atom_atomicbuf.c @@ -41,8 +41,7 @@ #include "st_program.h" static void -st_bind_atomics(struct st_context *st, - struct gl_shader_program *prog, +st_bind_atomics(struct st_context *st, struct gl_program *prog, enum pipe_shader_type shader_type) { unsigned i; @@ -50,8 +49,9 @@ st_bind_atomics(struct st_context *st, if (!prog || !st->pipe->set_shader_buffers) return; - for (i = 0; i < prog->data->NumAtomicBuffers; i++) { - struct gl_active_atomic_buffer *atomic = &prog->data->AtomicBuffers[i]; + for (i = 0; i < prog->sh.data->NumAtomicBuffers; i++) { + struct gl_active_atomic_buffer *atomic = + &prog->sh.data->AtomicBuffers[i]; struct gl_atomic_buffer_binding *binding = &st->ctx->AtomicBufferBindings[atomic->Binding]; struct st_buffer_object *st_obj = @@ -72,7 +72,7 @@ st_bind_atomics(struct st_context *st, static void bind_vs_atomics(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; st_bind_atomics(st, prog, PIPE_SHADER_VERTEX); @@ -85,7 +85,7 @@ const struct st_tracked_state st_bind_vs_atomics = { static void bind_fs_atomics(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; st_bind_atomics(st, prog, PIPE_SHADER_FRAGMENT); @@ -98,7 +98,7 @@ const struct st_tracked_state st_bind_fs_atomics = { static void bind_gs_atomics(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; st_bind_atomics(st, prog, PIPE_SHADER_GEOMETRY); @@ -111,7 +111,7 @@ const struct st_tracked_state st_bind_gs_atomics = { static void bind_tcs_atomics(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]; st_bind_atomics(st, prog, PIPE_SHADER_TESS_CTRL); @@ -124,7 +124,7 @@ const struct st_tracked_state st_bind_tcs_atomics = { static void bind_tes_atomics(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; st_bind_atomics(st, prog, PIPE_SHADER_TESS_EVAL); @@ -137,7 +137,7 @@ const struct st_tracked_state st_bind_tes_atomics = { static void bind_cs_atomics(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; st_bind_atomics(st, prog, PIPE_SHADER_COMPUTE); diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 958b202eb73..6ab4ca99be6 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -278,13 +278,10 @@ static void st_bind_ubos(struct st_context *st, struct gl_program *prog, static void bind_vs_ubos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_VERTEX]) - return; - - st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program, PIPE_SHADER_VERTEX); + st_bind_ubos(st, prog, PIPE_SHADER_VERTEX); } const struct st_tracked_state st_bind_vs_ubos = { @@ -293,13 +290,10 @@ const struct st_tracked_state st_bind_vs_ubos = { static void bind_fs_ubos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) - return; - - st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program, PIPE_SHADER_FRAGMENT); + st_bind_ubos(st, prog, PIPE_SHADER_FRAGMENT); } const struct st_tracked_state st_bind_fs_ubos = { @@ -308,13 +302,10 @@ const struct st_tracked_state st_bind_fs_ubos = { static void bind_gs_ubos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_GEOMETRY]) - return; - - st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program, PIPE_SHADER_GEOMETRY); + st_bind_ubos(st, prog, PIPE_SHADER_GEOMETRY); } const struct st_tracked_state st_bind_gs_ubos = { @@ -323,13 +314,10 @@ const struct st_tracked_state st_bind_gs_ubos = { static void bind_tcs_ubos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) - return; - - st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program, PIPE_SHADER_TESS_CTRL); + st_bind_ubos(st, prog, PIPE_SHADER_TESS_CTRL); } const struct st_tracked_state st_bind_tcs_ubos = { @@ -338,13 +326,10 @@ const struct st_tracked_state st_bind_tcs_ubos = { static void bind_tes_ubos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]) - return; - - st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program, PIPE_SHADER_TESS_EVAL); + st_bind_ubos(st, prog, PIPE_SHADER_TESS_EVAL); } const struct st_tracked_state st_bind_tes_ubos = { @@ -353,14 +338,10 @@ const struct st_tracked_state st_bind_tes_ubos = { static void bind_cs_ubos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_COMPUTE]) - return; - - st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program, - PIPE_SHADER_COMPUTE); + st_bind_ubos(st, prog, PIPE_SHADER_COMPUTE); } const struct st_tracked_state st_bind_cs_ubos = { diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c index 649906c1c1b..5dd2cd64f90 100644 --- a/src/mesa/state_tracker/st_atom_image.c +++ b/src/mesa/state_tracker/st_atom_image.c @@ -129,13 +129,10 @@ st_bind_images(struct st_context *st, struct gl_program *prog, static void bind_vs_images(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_VERTEX]) - return; - - st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program, PIPE_SHADER_VERTEX); + st_bind_images(st, prog, PIPE_SHADER_VERTEX); } const struct st_tracked_state st_bind_vs_images = { @@ -144,13 +141,10 @@ const struct st_tracked_state st_bind_vs_images = { static void bind_fs_images(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) - return; - - st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program, PIPE_SHADER_FRAGMENT); + st_bind_images(st, prog, PIPE_SHADER_FRAGMENT); } const struct st_tracked_state st_bind_fs_images = { @@ -159,13 +153,10 @@ const struct st_tracked_state st_bind_fs_images = { static void bind_gs_images(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_GEOMETRY]) - return; - - st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program, PIPE_SHADER_GEOMETRY); + st_bind_images(st, prog, PIPE_SHADER_GEOMETRY); } const struct st_tracked_state st_bind_gs_images = { @@ -174,13 +165,10 @@ const struct st_tracked_state st_bind_gs_images = { static void bind_tcs_images(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) - return; - - st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program, PIPE_SHADER_TESS_CTRL); + st_bind_images(st, prog, PIPE_SHADER_TESS_CTRL); } const struct st_tracked_state st_bind_tcs_images = { @@ -189,13 +177,10 @@ const struct st_tracked_state st_bind_tcs_images = { static void bind_tes_images(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]) - return; - - st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program, PIPE_SHADER_TESS_EVAL); + st_bind_images(st, prog, PIPE_SHADER_TESS_EVAL); } const struct st_tracked_state st_bind_tes_images = { @@ -204,13 +189,10 @@ const struct st_tracked_state st_bind_tes_images = { static void bind_cs_images(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_COMPUTE]) - return; - - st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program, PIPE_SHADER_COMPUTE); + st_bind_images(st, prog, PIPE_SHADER_COMPUTE); } const struct st_tracked_state st_bind_cs_images = { diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c index 174b4b3980e..ec89f163832 100644 --- a/src/mesa/state_tracker/st_atom_storagebuf.c +++ b/src/mesa/state_tracker/st_atom_storagebuf.c @@ -92,14 +92,10 @@ st_bind_ssbos(struct st_context *st, struct gl_program *prog, static void bind_vs_ssbos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_VERTEX]) - return; - - st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program, - PIPE_SHADER_VERTEX); + st_bind_ssbos(st, prog, PIPE_SHADER_VERTEX); } const struct st_tracked_state st_bind_vs_ssbos = { @@ -108,14 +104,10 @@ const struct st_tracked_state st_bind_vs_ssbos = { static void bind_fs_ssbos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_FRAGMENT]) - return; - - st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program, - PIPE_SHADER_FRAGMENT); + st_bind_ssbos(st, prog, PIPE_SHADER_FRAGMENT); } const struct st_tracked_state st_bind_fs_ssbos = { @@ -124,14 +116,10 @@ const struct st_tracked_state st_bind_fs_ssbos = { static void bind_gs_ssbos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_GEOMETRY]) - return; - - st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program, - PIPE_SHADER_GEOMETRY); + st_bind_ssbos(st, prog, PIPE_SHADER_GEOMETRY); } const struct st_tracked_state st_bind_gs_ssbos = { @@ -140,14 +128,10 @@ const struct st_tracked_state st_bind_gs_ssbos = { static void bind_tcs_ssbos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) - return; - - st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program, - PIPE_SHADER_TESS_CTRL); + st_bind_ssbos(st, prog, PIPE_SHADER_TESS_CTRL); } const struct st_tracked_state st_bind_tcs_ssbos = { @@ -156,14 +140,10 @@ const struct st_tracked_state st_bind_tcs_ssbos = { static void bind_tes_ssbos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]) - return; - - st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program, - PIPE_SHADER_TESS_EVAL); + st_bind_ssbos(st, prog, PIPE_SHADER_TESS_EVAL); } const struct st_tracked_state st_bind_tes_ssbos = { @@ -172,14 +152,10 @@ const struct st_tracked_state st_bind_tes_ssbos = { static void bind_cs_ssbos(struct st_context *st) { - struct gl_shader_program *prog = + struct gl_program *prog = st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_COMPUTE]) - return; - - st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program, - PIPE_SHADER_COMPUTE); + st_bind_ssbos(st, prog, PIPE_SHADER_COMPUTE); } const struct st_tracked_state st_bind_cs_ssbos = { diff --git a/src/mesa/state_tracker/st_cb_compute.c b/src/mesa/state_tracker/st_cb_compute.c index ccc5dc2b004..f91df4bd177 100644 --- a/src/mesa/state_tracker/st_cb_compute.c +++ b/src/mesa/state_tracker/st_cb_compute.c @@ -40,7 +40,7 @@ static void st_dispatch_compute_common(struct gl_context *ctx, struct pipe_resource *indirect, GLintptr indirect_offset) { - struct gl_shader_program *prog = + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; @@ -57,7 +57,7 @@ static void st_dispatch_compute_common(struct gl_context *ctx, st_validate_state(st, ST_PIPELINE_COMPUTE); for (unsigned i = 0; i < 3; i++) { - info.block[i] = group_size ? group_size[i] : prog->Comp.LocalSize[i]; + info.block[i] = group_size ? group_size[i] : prog->info.cs.local_size[i]; info.grid[i] = num_groups ? num_groups[i] : 0; } |