[Mesa-dev] [PATCH] mesa/i965: remove _CurrentFragmentProgram from gl_pipeline_object
Timothy Arceri
tarceri at itsqueeze.com
Wed May 10 01:57:53 UTC 2017
This was added in b527dd65c830a as a work around because fixed function
fragment shaders were tracked in ctx->FragmentProgram._Current as
a gl_program rather than gl_shader_program.
However after my refactoring of the program and shader structs
at the end of 2016 which culminated in c505d6d85222, we no longer
need gl_shader_program to track the current program making
_CurrentFragmentProgram obsolete.
---
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 3 +--
src/mesa/main/api_validate.c | 2 +-
src/mesa/main/mtypes.h | 2 --
src/mesa/main/pipelineobj.c | 2 --
src/mesa/main/shaderapi.c | 22 ----------------------
src/mesa/main/state.c | 8 --------
6 files changed, 2 insertions(+), 37 deletions(-)
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 49383c7..cad9c1c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1434,23 +1434,22 @@ brw_upload_ubo_surfaces(struct brw_context *brw, struct gl_program *prog,
}
}
if (prog->info.num_ubos || prog->info.num_ssbos)
brw->ctx.NewDriverState |= BRW_NEW_SURFACES;
}
static void
brw_upload_wm_ubo_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_program *prog = ctx->_Shader->_CurrentFragmentProgram;
+ struct gl_program *prog = brw->fragment_program;
/* BRW_NEW_FS_PROG_DATA */
brw_upload_ubo_surfaces(brw, prog, &brw->wm.base, brw->wm.base.prog_data);
}
const struct brw_tracked_state brw_wm_ubo_surfaces = {
.dirty = {
.mesa = _NEW_PROGRAM,
.brw = BRW_NEW_BATCH |
BRW_NEW_BLORP |
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 4694c36..cbb2361 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -92,21 +92,21 @@ check_blend_func_error(struct gl_context *ctx)
/* The KHR_blend_equation_advanced spec says:
*
* "Advanced blending equations require the use of a fragment shader
* with a matching "blend_support" layout qualifier. If the current
* blend equation is found in table X.1 or X.2, and the active
* fragment shader does not include the layout qualifier matching
* the blend equation or "blend_support_all_equations", the error
* INVALID_OPERATION is generated [...]"
*/
- const struct gl_program *prog = ctx->_Shader->_CurrentFragmentProgram;
+ const struct gl_program *prog = ctx->FragmentProgram._Current;
const GLbitfield blend_support = !prog ? 0 : prog->sh.fs.BlendSupport;
if ((blend_support & ctx->Color._AdvancedBlendMode) == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"fragment shader does not allow advanced blending mode "
"(%s)",
_mesa_enum_to_string(ctx->Color.Blend[0].EquationRGB));
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0d594bf..dff4192 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2996,22 +2996,20 @@ struct gl_pipeline_object
/**
* Programs used for rendering
*
* There is a separate program set for each shader stage.
*/
struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
- struct gl_program *_CurrentFragmentProgram;
-
/**
* Program used by glUniform calls.
*
* Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
*/
struct gl_shader_program *ActiveProgram;
GLbitfield Flags; /**< Mask of GLSL_x flags */
GLboolean EverBound; /**< Has the pipeline object been created */
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index f7c911f..67a8fc8 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -51,22 +51,20 @@
/**
* Delete a pipeline object.
*/
void
_mesa_delete_pipeline_object(struct gl_context *ctx,
struct gl_pipeline_object *obj)
{
unsigned i;
- _mesa_reference_program(ctx, &obj->_CurrentFragmentProgram, NULL);
-
for (i = 0; i < MESA_SHADER_STAGES; i++) {
_mesa_reference_program(ctx, &obj->CurrentProgram[i], NULL);
_mesa_reference_shader_program(ctx, &obj->ReferencedPrograms[i], NULL);
}
_mesa_reference_shader_program(ctx, &obj->ActiveProgram, NULL);
free(obj->Label);
ralloc_free(obj);
}
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index f91cc89..ef0941d 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -150,21 +150,20 @@ _mesa_init_shader_state(struct gl_context *ctx)
/**
* Free the per-context shader-related state.
*/
void
_mesa_free_shader_state(struct gl_context *ctx)
{
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
_mesa_reference_program(ctx, &ctx->Shader.CurrentProgram[i], NULL);
}
- _mesa_reference_program(ctx, &ctx->Shader._CurrentFragmentProgram, NULL);
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
/* Extended for ARB_separate_shader_objects */
_mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
assert(ctx->Shader.RefCount == 1);
}
/**
@@ -1251,41 +1250,20 @@ use_program(struct gl_context *ctx, gl_shader_stage stage,
if (new_prog) {
_mesa_program_init_subroutine_defaults(ctx, new_prog);
}
if (*target != new_prog) {
/* Program is current, flush it */
if (shTarget == ctx->_Shader) {
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
}
- /* If the shader is also bound as the current rendering shader, unbind
- * it from that binding point as well. This ensures that the correct
- * semantics of glDeleteProgram are maintained.
- */
- switch (stage) {
- case MESA_SHADER_VERTEX:
- case MESA_SHADER_TESS_CTRL:
- case MESA_SHADER_TESS_EVAL:
- case MESA_SHADER_GEOMETRY:
- case MESA_SHADER_COMPUTE:
- /* Empty for now. */
- break;
- case MESA_SHADER_FRAGMENT:
- if (*target == ctx->_Shader->_CurrentFragmentProgram) {
- _mesa_reference_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- NULL);
- }
- break;
- }
-
_mesa_reference_shader_program(ctx,
&shTarget->ReferencedPrograms[stage],
shProg);
_mesa_reference_program(ctx, target, new_prog);
return;
}
}
/**
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 5a760f5..73872b8 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -126,51 +126,43 @@ update_program(struct gl_context *ctx)
* 3. ATI fragment shader
* 4. Programs derived from fixed-function state.
*
* Note: it's possible for a vertex shader to get used with a fragment
* program (and vice versa) here, but in practice that shouldn't ever
* come up, or matter.
*/
if (fsProg) {
/* Use GLSL fragment shader */
- _mesa_reference_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
- fsProg);
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current, fsProg);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
}
else if (ctx->FragmentProgram._Enabled) {
/* Use user-defined fragment program */
- _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,
NULL);
}
else if (ctx->ATIFragmentShader._Enabled &&
ctx->ATIFragmentShader.Current->Program) {
/* Use the enabled ATI fragment shader's associated program */
- _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,
NULL);
}
else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
/* Use fragment program generated from fixed-function state */
struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx);
- _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,
f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
}
else {
/* No fragment program */
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current, NULL);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
--
2.9.3
More information about the mesa-dev
mailing list