summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/state.c
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-10-31 22:39:17 +1100
committerTimothy Arceri <[email protected]>2017-01-23 14:48:04 +1100
commitc505d6d852220f4aaaee161465dd2c579647e672 (patch)
treed77bf00e32a00b310fa09399974f5a51f99be073 /src/mesa/main/state.c
parent31daeb5bf14334bc0d39f28c9102cd15d834abfc (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/main/state.c')
-rw-r--r--src/mesa/main/state.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 2a926a182b9..5cb58a469bb 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -95,17 +95,17 @@ update_program_enables(struct gl_context *ctx)
static GLbitfield
update_program(struct gl_context *ctx)
{
- const struct gl_shader_program *vsProg =
+ struct gl_program *vsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
- const struct gl_shader_program *tcsProg =
+ struct gl_program *tcsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
- const struct gl_shader_program *tesProg =
+ struct gl_program *tesProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- const struct gl_shader_program *gsProg =
+ struct gl_program *gsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- struct gl_shader_program *fsProg =
+ struct gl_program *fsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
- const struct gl_shader_program *csProg =
+ struct gl_program *csProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
const struct gl_program *prevVP = ctx->VertexProgram._Current;
const struct gl_program *prevFP = ctx->FragmentProgram._Current;
@@ -132,13 +132,11 @@ update_program(struct gl_context *ctx)
* come up, or matter.
*/
- if (fsProg && fsProg->data->LinkStatus
- && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
+ if (fsProg) {
/* Use GLSL fragment shader */
_mesa_reference_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
- fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
- _mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
- fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
+ fsProg);
+ _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, fsProg);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
}
@@ -179,32 +177,26 @@ update_program(struct gl_context *ctx)
NULL);
}
- if (gsProg && gsProg->data->LinkStatus
- && gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
+ if (gsProg) {
/* Use GLSL geometry shader */
- _mesa_reference_program(ctx, &ctx->GeometryProgram._Current,
- gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
+ _mesa_reference_program(ctx, &ctx->GeometryProgram._Current, gsProg);
} else {
/* No geometry program */
_mesa_reference_program(ctx, &ctx->GeometryProgram._Current, NULL);
}
- if (tesProg && tesProg->data->LinkStatus
- && tesProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]) {
+ if (tesProg) {
/* Use GLSL tessellation evaluation shader */
- _mesa_reference_program(ctx, &ctx->TessEvalProgram._Current,
- tesProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program);
+ _mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, tesProg);
}
else {
/* No tessellation evaluation program */
_mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, NULL);
}
- if (tcsProg && tcsProg->data->LinkStatus
- && tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]) {
+ if (tcsProg) {
/* Use GLSL tessellation control shader */
- _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current,
- tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program);
+ _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, tcsProg);
}
else {
/* No tessellation control program */
@@ -215,11 +207,9 @@ update_program(struct gl_context *ctx)
* _mesa_get_fixed_func_vertex_program() needs to know active
* fragprog inputs.
*/
- if (vsProg && vsProg->data->LinkStatus
- && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
+ if (vsProg) {
/* Use GLSL vertex shader */
- _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
- vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, vsProg);
}
else if (ctx->VertexProgram._Enabled) {
/* Use user-defined vertex program */
@@ -238,11 +228,9 @@ update_program(struct gl_context *ctx)
_mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
}
- if (csProg && csProg->data->LinkStatus
- && csProg->_LinkedShaders[MESA_SHADER_COMPUTE]) {
+ if (csProg) {
/* Use GLSL compute shader */
- _mesa_reference_program(ctx, &ctx->ComputeProgram._Current,
- csProg->_LinkedShaders[MESA_SHADER_COMPUTE]->Program);
+ _mesa_reference_program(ctx, &ctx->ComputeProgram._Current, csProg);
} else {
/* no compute program */
_mesa_reference_program(ctx, &ctx->ComputeProgram._Current, NULL);