[Mesa-dev] [PATCH 28/70] mesa/glsl: move BlendSupport bitfield to gl_program

Timothy Arceri timothy.arceri at collabora.com
Fri Nov 11 00:46:10 UTC 2016


This will let us to make _CurrentFragmentProgram a gl_program pointer
allowing for simpilifications to be made.

We also need to add a field to gl_shader to hold it during parsing.

In gl_program we put it inside a union in anticipation of moving
more fields here that can be only fs or vertex stage fields.
---
 src/compiler/glsl/glsl_parser_extras.cpp            |  2 +-
 src/compiler/glsl/linker.cpp                        |  3 +--
 src/compiler/glsl/lower_blend_equation_advanced.cpp |  5 +++--
 src/mesa/main/api_validate.c                        |  2 +-
 src/mesa/main/mtypes.h                              | 19 ++++++++++++++-----
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index db659adf..06479c5 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1810,7 +1810,7 @@ set_shader_inout_layout(struct gl_shader *shader,
       shader->info.ARB_fragment_coord_conventions_enable =
          state->ARB_fragment_coord_conventions_enable;
       shader->info.EarlyFragmentTests = state->fs_early_fragment_tests;
-      shader->info.BlendSupport = state->fs_blend_support;
+      shader->BlendSupport = state->fs_blend_support;
       break;
 
    default:
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index c8e6eba..b701e62 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -1828,7 +1828,6 @@ link_fs_inout_layout_qualifiers(struct gl_shader_program *prog,
    linked_shader->info.uses_gl_fragcoord = false;
    linked_shader->info.origin_upper_left = false;
    linked_shader->info.pixel_center_integer = false;
-   linked_shader->info.BlendSupport = 0;
 
    if (linked_shader->Stage != MESA_SHADER_FRAGMENT ||
        (prog->Version < 150 && !prog->ARB_fragment_coord_conventions_enable))
@@ -1887,7 +1886,7 @@ link_fs_inout_layout_qualifiers(struct gl_shader_program *prog,
 
       linked_shader->info.EarlyFragmentTests |=
          shader->info.EarlyFragmentTests;
-      linked_shader->info.BlendSupport |= shader->info.BlendSupport;
+      linked_shader->Program->sh.fs.BlendSupport |= shader->BlendSupport;
    }
 }
 
diff --git a/src/compiler/glsl/lower_blend_equation_advanced.cpp b/src/compiler/glsl/lower_blend_equation_advanced.cpp
index f8210e3..4f9cd83 100644
--- a/src/compiler/glsl/lower_blend_equation_advanced.cpp
+++ b/src/compiler/glsl/lower_blend_equation_advanced.cpp
@@ -463,7 +463,7 @@ get_main(gl_linked_shader *sh)
 bool
 lower_blend_equation_advanced(struct gl_linked_shader *sh)
 {
-   if (sh->info.BlendSupport == 0)
+   if (sh->Program->sh.fs.BlendSupport == 0)
       return false;
 
    /* Lower early returns in main() so there's a single exit point
@@ -547,7 +547,8 @@ lower_blend_equation_advanced(struct gl_linked_shader *sh)
    ir_factory f(&main->body, mem_ctx);
 
    ir_variable *result_dest =
-      calc_blend_result(f, mode, fb, blend_source, sh->info.BlendSupport);
+      calc_blend_result(f, mode, fb, blend_source,
+                        sh->Program->sh.fs.BlendSupport);
 
    /* Copy the result back to the original values.  It would be simpler
     * to demote the program's output variables, and create a new vec4
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 5e19794..f278e00 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -102,7 +102,7 @@ check_blend_func_error(struct gl_context *ctx)
       const struct gl_shader_program *sh_prog =
          ctx->_Shader->_CurrentFragmentProgram;
       const GLbitfield blend_support = !sh_prog ? 0 :
-         sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->info.BlendSupport;
+         sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->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 f797125..cf83548 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1972,6 +1972,15 @@ struct gl_program
          GLuint NumSubroutineFunctions;
          GLuint MaxSubroutineFunctionIndex;
          struct gl_subroutine_function *SubroutineFunctions;
+
+         union {
+            struct {
+               /**
+                * A bitmask of gl_advanced_blend_mode values
+                */
+               GLbitfield BlendSupport;
+            } fs;
+         };
       } sh;
 
       /** ARB assembly-style program fields */
@@ -2278,11 +2287,6 @@ struct gl_shader_info
    bool EarlyFragmentTests;
 
    /**
-    * A bitmask of gl_advanced_blend_mode values
-    */
-   GLbitfield BlendSupport;
-
-   /**
     * Compute shader state from ARB_compute_shader and
     * ARB_compute_variable_group_size layout qualifiers.
     */
@@ -2429,6 +2433,11 @@ struct gl_shader
    struct exec_list *ir;
    struct glsl_symbol_table *symbols;
 
+   /**
+    * A bitmask of gl_advanced_blend_mode values
+    */
+   GLbitfield BlendSupport;
+
    struct gl_shader_info info;
 };
 
-- 
2.7.4



More information about the mesa-dev mailing list