aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-04 09:25:36 +1100
committerTimothy Arceri <[email protected]>2017-01-06 11:21:42 +1100
commitc46a630000a2539e38a448f24a456397ce201a2e (patch)
treea9c8fc697557c5821225c4001fbc33c84c64b09a /src/mesa/main
parent6e3f6097c995a74d4ce52f542413b01ff819c203 (diff)
mesa: make _CurrentFragmentProgram a gl_program struct pointer
Making this point to a gl_program struct rather than a gl_shader_program struct will allow use to later also make the CurrentProgram array hold gl_program structs which in turn will allow for code simpilifcation. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_validate.c6
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/pipelineobj.c2
-rw-r--r--src/mesa/main/shaderapi.c14
-rw-r--r--src/mesa/main/state.c20
5 files changed, 20 insertions, 24 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 42eeeba1414..5f051dbec6f 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -99,10 +99,8 @@ check_blend_func_error(struct gl_context *ctx)
* the blend equation or "blend_support_all_equations", the error
* INVALID_OPERATION is generated [...]"
*/
- const struct gl_shader_program *sh_prog =
- ctx->_Shader->_CurrentFragmentProgram;
- const GLbitfield blend_support = !sh_prog ? 0 :
- sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->sh.fs.BlendSupport;
+ const struct gl_program *prog = ctx->_Shader->_CurrentFragmentProgram;
+ const GLbitfield blend_support = !prog ? 0 : prog->sh.fs.BlendSupport;
if ((blend_support & ctx->Color._AdvancedBlendMode) == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 40a240c961c..ffd21ecea3b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2921,7 +2921,7 @@ struct gl_pipeline_object
*/
struct gl_shader_program *CurrentProgram[MESA_SHADER_STAGES];
- struct gl_shader_program *_CurrentFragmentProgram;
+ struct gl_program *_CurrentFragmentProgram;
/**
* Program used by glUniform calls.
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 5fc2808a0c8..9651a40dbb8 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -58,7 +58,7 @@ _mesa_delete_pipeline_object(struct gl_context *ctx,
{
unsigned i;
- _mesa_reference_shader_program(ctx, &obj->_CurrentFragmentProgram, NULL);
+ _mesa_reference_program(ctx, &obj->_CurrentFragmentProgram, NULL);
for (i = 0; i < MESA_SHADER_STAGES; i++)
_mesa_reference_shader_program(ctx, &obj->CurrentProgram[i], NULL);
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index f9106140770..571b35be58b 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -161,8 +161,7 @@ _mesa_free_shader_state(struct gl_context *ctx)
_mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram[i],
NULL);
}
- _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
- NULL);
+ _mesa_reference_program(ctx, &ctx->Shader._CurrentFragmentProgram, NULL);
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
/* Extended for ARB_separate_shader_objects */
@@ -1230,10 +1229,13 @@ use_shader_program(struct gl_context *ctx, gl_shader_stage stage,
/* Empty for now. */
break;
case MESA_SHADER_FRAGMENT:
- if (*target == ctx->_Shader->_CurrentFragmentProgram) {
- _mesa_reference_shader_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- NULL);
+ if (*target != NULL &&
+ ((*target)->_LinkedShaders[MESA_SHADER_FRAGMENT] &&
+ (*target)->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program ==
+ ctx->_Shader->_CurrentFragmentProgram)) {
+ _mesa_reference_program(ctx,
+ &ctx->_Shader->_CurrentFragmentProgram,
+ NULL);
}
break;
}
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index e56f6e136d3..2a926a182b9 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -135,9 +135,8 @@ update_program(struct gl_context *ctx)
if (fsProg && fsProg->data->LinkStatus
&& fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
/* Use GLSL fragment shader */
- _mesa_reference_shader_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- fsProg);
+ _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);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
@@ -145,9 +144,8 @@ update_program(struct gl_context *ctx)
}
else if (ctx->FragmentProgram._Enabled) {
/* Use user-defined fragment program */
- _mesa_reference_shader_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- NULL);
+ _mesa_reference_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
+ NULL);
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
ctx->FragmentProgram.Current);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
@@ -156,9 +154,8 @@ update_program(struct gl_context *ctx)
else if (ctx->ATIFragmentShader._Enabled &&
ctx->ATIFragmentShader.Current->Program) {
/* Use the enabled ATI fragment shader's associated program */
- _mesa_reference_shader_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- NULL);
+ _mesa_reference_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
+ NULL);
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
ctx->ATIFragmentShader.Current->Program);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
@@ -168,9 +165,8 @@ update_program(struct gl_context *ctx)
/* Use fragment program generated from fixed-function state */
struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx);
- _mesa_reference_shader_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- f);
+ _mesa_reference_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
+ f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,