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/drivers | |
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/drivers')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 28 | ||||
-rw-r--r-- | src/mesa/drivers/common/meta.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_ff_gs.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tcs_surface_state.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tes_surface_state.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 9 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/gen6_sol.c | 24 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/gen7_l3_state.c | 6 |
11 files changed, 40 insertions, 77 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 0d5661ba062..5b99c6baa52 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -167,7 +167,7 @@ _mesa_meta_use_program(struct gl_context *ctx, _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader); /* Update the program */ - _mesa_use_program(ctx, sh_prog); + _mesa_use_shader_program(ctx, sh_prog); } void @@ -594,8 +594,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) * that we don't have to worry about the current pipeline state. */ for (i = 0; i < MESA_SHADER_STAGES; i++) { - _mesa_reference_shader_program(ctx, &save->Shader[i], - ctx->Shader.CurrentProgram[i]); + _mesa_reference_program(ctx, &save->Program[i], + ctx->Shader.CurrentProgram[i]); } _mesa_reference_shader_program(ctx, &save->ActiveShader, ctx->Shader.ActiveProgram); @@ -931,16 +931,6 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_SHADER) { - static const GLenum targets[] = { - GL_VERTEX_SHADER, - GL_TESS_CONTROL_SHADER, - GL_TESS_EVALUATION_SHADER, - GL_GEOMETRY_SHADER, - GL_FRAGMENT_SHADER, - GL_COMPUTE_SHADER, - }; - STATIC_ASSERT(MESA_SHADER_STAGES == ARRAY_SIZE(targets)); - bool any_shader; if (ctx->Extensions.ARB_vertex_program) { @@ -966,22 +956,20 @@ _mesa_meta_end(struct gl_context *ctx) any_shader = false; for (i = 0; i < MESA_SHADER_STAGES; i++) { - /* It is safe to call _mesa_use_shader_program even if the extension + /* It is safe to call _mesa_use_program even if the extension * necessary for that program state is not supported. In that case, * the saved program object must be NULL and the currently bound - * program object must be NULL. _mesa_use_shader_program is a no-op + * program object must be NULL. _mesa_use_program is a no-op * in that case. */ - _mesa_use_shader_program(ctx, targets[i], - save->Shader[i], - &ctx->Shader); + _mesa_use_program(ctx, i, save->Program[i], &ctx->Shader); /* Do this *before* killing the reference. :) */ - if (save->Shader[i] != NULL) + if (save->Program[i] != NULL) any_shader = true; - _mesa_reference_shader_program(ctx, &save->Shader[i], NULL); + _mesa_reference_program(ctx, &save->Program[i], NULL); } _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 0a913e9fa82..1b5cf42eb87 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -125,7 +125,7 @@ struct save_state GLboolean FragmentProgramEnabled; struct gl_program *FragmentProgram; GLboolean ATIFragmentShaderEnabled; - struct gl_shader_program *Shader[MESA_SHADER_STAGES]; + struct gl_program *Program[MESA_SHADER_STAGES]; struct gl_shader_program *ActiveShader; struct gl_pipeline_object *Pipeline; diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 84d34c0f6a0..0b3ac897aa0 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -274,14 +274,12 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) /* Resolve color for each active shader image. */ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { - const struct gl_linked_shader *shader = - ctx->_Shader->CurrentProgram[i] ? - ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL; + const struct gl_program *prog = ctx->_Shader->CurrentProgram[i]; - if (unlikely(shader && shader->Program->info.num_images)) { - for (unsigned j = 0; j < shader->Program->info.num_images; j++) { + if (unlikely(prog && prog->info.num_images)) { + for (unsigned j = 0; j < prog->info.num_images; j++) { struct gl_image_unit *u = - &ctx->ImageUnits[shader->Program->sh.ImageUnits[j]]; + &ctx->ImageUnits[prog->sh.ImageUnits[j]]; tex_obj = intel_texture_object(u->TexObj); if (tex_obj && tex_obj->mt) { diff --git a/src/mesa/drivers/dri/i965/brw_ff_gs.c b/src/mesa/drivers/dri/i965/brw_ff_gs.c index 4934af3fd39..0316d0f8c3b 100644 --- a/src/mesa/drivers/dri/i965/brw_ff_gs.c +++ b/src/mesa/drivers/dri/i965/brw_ff_gs.c @@ -195,10 +195,10 @@ brw_ff_gs_populate_key(struct brw_context *brw, /* On Gen6, GS is used for transform feedback. */ /* BRW_NEW_TRANSFORM_FEEDBACK */ if (_mesa_is_xfb_active_and_unpaused(ctx)) { - const struct gl_shader_program *shaderprog = + const struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; const struct gl_transform_feedback_info *linked_xfb_info = - shaderprog->xfb_program->sh.LinkedTransformFeedback; + prog->sh.LinkedTransformFeedback; int i; /* Make sure that the VUE slots won't overflow the unsigned chars in diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c index dc064626aea..d5a106d6bec 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c @@ -72,17 +72,13 @@ brw_upload_gs_ubo_surfaces(struct brw_context *brw) struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_GEOMETRY]) - return; - /* BRW_NEW_GS_PROG_DATA */ struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data; - brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program, - &brw->gs.base, prog_data); + brw_upload_ubo_surfaces(brw, prog, &brw->gs.base, prog_data); } const struct brw_tracked_state brw_gs_ubo_surfaces = { diff --git a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c index 083058bdf20..ede7ae9d521 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c @@ -72,17 +72,13 @@ brw_upload_tcs_ubo_surfaces(struct brw_context *brw) struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) - return; - /* BRW_NEW_TCS_PROG_DATA */ struct brw_stage_prog_data *prog_data = brw->tcs.base.prog_data; - brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program, - &brw->tcs.base, prog_data); + brw_upload_ubo_surfaces(brw, prog, &brw->tcs.base, prog_data); } const struct brw_tracked_state brw_tcs_ubo_surfaces = { diff --git a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c index 03b301e6de3..1982955be8f 100644 --- a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c @@ -72,17 +72,13 @@ brw_upload_tes_ubo_surfaces(struct brw_context *brw) struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]) - return; - /* BRW_NEW_TES_PROG_DATA */ struct brw_stage_prog_data *prog_data = brw->tes.base.prog_data; - brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program, - &brw->tes.base, prog_data); + brw_upload_ubo_surfaces(brw, prog, &brw->tes.base, prog_data); } const struct brw_tracked_state brw_tes_ubo_surfaces = { diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 5665735f432..29359d43c31 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -140,15 +140,10 @@ brw_upload_vs_ubo_surfaces(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = - ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; - - if (!prog || !prog->_LinkedShaders[MESA_SHADER_VERTEX]) - return; + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; /* BRW_NEW_VS_PROG_DATA */ - brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program, - &brw->vs.base, brw->vs.base.prog_data); + brw_upload_ubo_surfaces(brw, prog, &brw->vs.base, brw->vs.base.prog_data); } const struct brw_tracked_state brw_vs_ubo_surfaces = { diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index c7c73774c3b..a6fadf9b760 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -1461,15 +1461,11 @@ brw_upload_cs_ubo_surfaces(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; - if (!prog || !prog->_LinkedShaders[MESA_SHADER_COMPUTE]) - return; - /* BRW_NEW_CS_PROG_DATA */ - brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program, - &brw->cs.base, brw->cs.base.prog_data); + brw_upload_ubo_surfaces(brw, prog, &brw->cs.base, brw->cs.base.prog_data); } const struct brw_tracked_state brw_cs_ubo_surfaces = { @@ -1844,7 +1840,7 @@ brw_upload_cs_work_groups_surface(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = + struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; /* BRW_NEW_CS_PROG_DATA */ const struct brw_cs_prog_data *cs_prog_data = diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 656d042769e..6f1d2c2fd04 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -98,7 +98,7 @@ brw_gs_upload_binding_table(struct brw_context *brw) { uint32_t *bind; struct gl_context *ctx = &brw->ctx; - const struct gl_shader_program *shaderprog; + const struct gl_program *prog; bool need_binding_table = false; /* We have two scenarios here: @@ -112,11 +112,11 @@ brw_gs_upload_binding_table(struct brw_context *brw) if (!brw->geometry_program) { /* BRW_NEW_VERTEX_PROGRAM */ - shaderprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; - if (shaderprog) { + prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; + if (prog) { /* Skip making a binding table if we don't have anything to put in it */ const struct gl_transform_feedback_info *linked_xfb_info = - shaderprog->xfb_program->sh.LinkedTransformFeedback; + prog->sh.LinkedTransformFeedback; need_binding_table = linked_xfb_info->NumOutputs > 0; } if (!need_binding_table) { @@ -140,12 +140,12 @@ brw_gs_upload_binding_table(struct brw_context *brw) BRW_MAX_SOL_BINDINGS * sizeof(uint32_t)); } else { /* BRW_NEW_GEOMETRY_PROGRAM */ - shaderprog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; - if (shaderprog) { + prog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; + if (prog) { /* Skip making a binding table if we don't have anything to put in it */ struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data; const struct gl_transform_feedback_info *linked_xfb_info = - shaderprog->xfb_program->sh.LinkedTransformFeedback; + prog->sh.LinkedTransformFeedback; need_binding_table = linked_xfb_info->NumOutputs > 0 || prog_data->binding_table.size_bytes > 0; } @@ -225,7 +225,7 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode, struct gl_transform_feedback_object *obj) { struct brw_context *brw = brw_context(ctx); - const struct gl_shader_program *shaderprog; + const struct gl_program *prog; const struct gl_transform_feedback_info *linked_xfb_info; struct gl_transform_feedback_object *xfb_obj = ctx->TransformFeedback.CurrentObject; @@ -234,14 +234,12 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode, if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) { /* BRW_NEW_GEOMETRY_PROGRAM */ - shaderprog = - ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; + prog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]; } else { /* BRW_NEW_VERTEX_PROGRAM */ - shaderprog = - ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; + prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]; } - linked_xfb_info = shaderprog->xfb_program->sh.LinkedTransformFeedback; + linked_xfb_info = prog->sh.LinkedTransformFeedback; /* Compute the maximum number of vertices that we can write without * overflowing any of the buffers currently being used for feedback. diff --git a/src/mesa/drivers/dri/i965/gen7_l3_state.c b/src/mesa/drivers/dri/i965/gen7_l3_state.c index dce39c3d192..536c00c4543 100644 --- a/src/mesa/drivers/dri/i965/gen7_l3_state.c +++ b/src/mesa/drivers/dri/i965/gen7_l3_state.c @@ -49,12 +49,12 @@ get_pipeline_state_l3_weights(const struct brw_context *brw) bool needs_dc = false, needs_slm = false; for (unsigned i = 0; i < ARRAY_SIZE(stage_states); i++) { - const struct gl_shader_program *prog = + const struct gl_program *prog = brw->ctx._Shader->CurrentProgram[stage_states[i]->stage]; const struct brw_stage_prog_data *prog_data = stage_states[i]->prog_data; - needs_dc |= (prog && (prog->data->NumAtomicBuffers || - prog->data->NumShaderStorageBlocks)) || + needs_dc |= (prog && (prog->sh.data->NumAtomicBuffers || + prog->sh.data->NumShaderStorageBlocks)) || (prog_data && (prog_data->total_scratch || prog_data->nr_image_params)); needs_slm |= prog_data && prog_data->total_shared; } |