mesa: remove _CurrentFragmentProgram from gl_pipeline_object
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 10 May 2017 00:37:35 +0000 (10:37 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 11 May 2017 04:46:39 +0000 (14:46 +1000)
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.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/main/api_validate.c
src/mesa/main/mtypes.h
src/mesa/main/pipelineobj.c
src/mesa/main/shaderapi.c
src/mesa/main/state.c

index c95fb37..ba98cd4 100644 (file)
@@ -1443,7 +1443,7 @@ 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 = ctx->FragmentProgram._Current;
 
    /* BRW_NEW_FS_PROG_DATA */
    brw_upload_ubo_surfaces(brw, prog, &brw->wm.base, brw->wm.base.prog_data);
index 4694c36..cbb2361 100644 (file)
@@ -99,7 +99,7 @@ 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_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) {
index 79f5013..28d3d94 100644 (file)
@@ -3003,8 +3003,6 @@ struct gl_pipeline_object
 
    struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
 
-   struct gl_program *_CurrentFragmentProgram;
-
    /**
     * Program used by glUniform calls.
     *
index f7c911f..67a8fc8 100644 (file)
@@ -58,8 +58,6 @@ _mesa_delete_pipeline_object(struct gl_context *ctx,
 {
    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);
index 681b730..7430cfe 100644 (file)
@@ -155,7 +155,6 @@ _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 */
@@ -1261,27 +1260,6 @@ use_program(struct gl_context *ctx, gl_shader_stage stage,
          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);
index 5a760f5..73872b8 100644 (file)
@@ -133,16 +133,12 @@ update_program(struct gl_context *ctx)
 
    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,
@@ -151,8 +147,6 @@ 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_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
-                              NULL);
       _mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
                               ctx->ATIFragmentShader.Current->Program);
       _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
@@ -162,8 +156,6 @@ 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_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,