[Mesa-dev] [PATCH 12/12] Replace gl_frag_attrib enum with gl_varying_slot.

Paul Berry stereotype441 at gmail.com
Mon Mar 11 15:51:16 PDT 2013


This patch makes the following search-and-replace changes:

gl_frag_attrib -> gl_varying_slot
FRAG_ATTRIB_* -> VARYING_SLOT_*
FRAG_BIT_* -> VARYING_BIT_*
--

Note: this patch is very large, so for purposes of mailing list
discussion I've trimmed it down to representative example hunks.  To
see the complete patch, please refer to branch
"combine_varying_slot_enums" of
git://github.com/stereotype441/mesa.git.

 src/glsl/builtin_variables.cpp                 |  26 ++--
 src/glsl/ir.cpp                                |   2 +-
 src/glsl/ir.h                                  |   2 +-
 src/glsl/link_varyings.cpp                     |  13 +-
 src/glsl/linker.cpp                            |   2 +-
 src/mesa/drivers/dri/i915/i915_fragprog.c      |  64 ++++----
 src/mesa/drivers/dri/i915/i915_state.c         |   2 +-
 src/mesa/drivers/dri/i915/intel_tris.c         |   2 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp           |  24 +--
 src/mesa/drivers/dri/i965/brw_fs.h             |   2 +-
 src/mesa/drivers/dri/i965/brw_fs_fp.cpp        |  10 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |   2 +-
 src/mesa/drivers/dri/i965/brw_sf.c             |   2 +-
 src/mesa/drivers/dri/i965/brw_vs_constval.c    |   8 +-
 src/mesa/drivers/dri/i965/brw_wm.c             |  10 +-
 src/mesa/drivers/dri/i965/brw_wm_iz.cpp        |   2 +-
 src/mesa/drivers/dri/i965/brw_wm_state.c       |   2 +-
 src/mesa/drivers/dri/i965/gen6_sf_state.c      |  16 +-
 src/mesa/drivers/dri/i965/gen6_wm_state.c      |   2 +-
 src/mesa/drivers/dri/i965/gen7_sf_state.c      |  14 +-
 src/mesa/drivers/dri/i965/gen7_wm_state.c      |   2 +-
 src/mesa/drivers/x11/xm_line.c                 |   8 +-
 src/mesa/main/context.c                        |   4 +-
 src/mesa/main/ff_fragment_shader.cpp           |  38 ++---
 src/mesa/main/ffvertex_prog.c                  |  14 +-
 src/mesa/main/mtypes.h                         |  62 +-------
 src/mesa/main/state.h                          |   2 +-
 src/mesa/main/texstate.c                       |   2 +-
 src/mesa/program/ir_to_mesa.cpp                |   4 +-
 src/mesa/program/prog_execute.c                |   6 +-
 src/mesa/program/prog_print.c                  |  16 +-
 src/mesa/program/program.c                     |  10 +-
 src/mesa/program/program_parse.y               |   8 +-
 src/mesa/program/programopt.c                  |  14 +-
 src/mesa/state_tracker/st_atom_pixeltransfer.c |   4 +-
 src/mesa/state_tracker/st_atom_rasterizer.c    |   4 +-
 src/mesa/state_tracker/st_cb_bitmap.c          |   4 +-
 src/mesa/state_tracker/st_cb_drawpixels.c      |  10 +-
 src/mesa/state_tracker/st_cb_drawtex.c         |   2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp     |  26 ++--
 src/mesa/state_tracker/st_mesa_to_tgsi.c       |  12 +-
 src/mesa/state_tracker/st_program.c            |  50 +++----
 src/mesa/swrast/s_aaline.c                     |   8 +-
 src/mesa/swrast/s_aalinetemp.h                 |  22 +--
 src/mesa/swrast/s_aatritemp.h                  |  52 +++----
 src/mesa/swrast/s_alpha.c                      |   2 +-
 src/mesa/swrast/s_atifragshader.c              |  10 +-
 src/mesa/swrast/s_context.c                    |  44 +++---
 src/mesa/swrast/s_context.h                    |   6 +-
 src/mesa/swrast/s_copypix.c                    |   4 +-
 src/mesa/swrast/s_drawpix.c                    |   4 +-
 src/mesa/swrast/s_feedback.c                   |  24 +--
 src/mesa/swrast/s_fog.c                        |  20 +--
 src/mesa/swrast/s_fragprog.c                   |  12 +-
 src/mesa/swrast/s_lines.c                      |  12 +-
 src/mesa/swrast/s_linetemp.h                   |  62 ++++----
 src/mesa/swrast/s_logic.c                      |   2 +-
 src/mesa/swrast/s_masking.c                    |   2 +-
 src/mesa/swrast/s_points.c                     |  84 +++++------
 src/mesa/swrast/s_span.c                       | 112 +++++++-------
 src/mesa/swrast/s_span.h                       |  12 +-
 src/mesa/swrast/s_texcombine.c                 |   6 +-
 src/mesa/swrast/s_texfilter.c                  |   2 +-
 src/mesa/swrast/s_triangle.c                   |  40 ++---
 src/mesa/swrast/s_tritemp.h                    | 200 ++++++++++++-------------
 src/mesa/swrast/s_zoom.c                       |  26 ++--
 src/mesa/swrast/swrast.h                       |   6 +-
 src/mesa/swrast_setup/ss_context.c             |  30 ++--
 src/mesa/swrast_setup/ss_triangle.c            |  12 +-
 src/mesa/swrast_setup/ss_tritmp.h              |  92 ++++++------
 src/mesa/tnl/t_context.c                       |   6 +-
 src/mesa/tnl_dd/t_dd_vb.c                      |  96 ++++++------
 72 files changed, 728 insertions(+), 791 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 531effd..b0c7a20 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -52,13 +52,13 @@ static const builtin_variable builtin_core_vs_variables[] = {
 };
 
 static const builtin_variable builtin_core_fs_variables[] = {
-   { ir_var_shader_in,  FRAG_ATTRIB_WPOS,  "vec4",  "gl_FragCoord" },
-   { ir_var_shader_in,  FRAG_ATTRIB_FACE,  "bool",  "gl_FrontFacing" },
+   { ir_var_shader_in,  VARYING_SLOT_POS,  "vec4",  "gl_FragCoord" },
+   { ir_var_shader_in,  VARYING_SLOT_FACE, "bool",  "gl_FrontFacing" },
    { ir_var_shader_out, FRAG_RESULT_COLOR, "vec4",  "gl_FragColor" },
 };
 
 static const builtin_variable builtin_100ES_fs_variables[] = {
-   { ir_var_shader_in,  FRAG_ATTRIB_PNTC,   "vec2",   "gl_PointCoord" },
+   { ir_var_shader_in,  VARYING_SLOT_PNTC,   "vec2",   "gl_PointCoord" },
 };
 
 static const builtin_variable builtin_300ES_vs_variables[] = {
@@ -66,10 +66,10 @@ static const builtin_variable builtin_300ES_vs_variables[] = {
 };
 
 static const builtin_variable builtin_300ES_fs_variables[] = {
-   { ir_var_shader_in,  FRAG_ATTRIB_WPOS,  "vec4",  "gl_FragCoord" },
-   { ir_var_shader_in,  FRAG_ATTRIB_FACE,  "bool",  "gl_FrontFacing" },
+   { ir_var_shader_in,  VARYING_SLOT_POS,  "vec4",  "gl_FragCoord" },
+   { ir_var_shader_in,  VARYING_SLOT_FACE, "bool",  "gl_FrontFacing" },
    { ir_var_shader_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" },
-   { ir_var_shader_in,  FRAG_ATTRIB_PNTC,   "vec2",   "gl_PointCoord" },
+   { ir_var_shader_in,  VARYING_SLOT_PNTC, "vec2",  "gl_PointCoord" },
 };
 
 static const builtin_variable builtin_110_fs_variables[] = {
@@ -77,9 +77,9 @@ static const builtin_variable builtin_110_fs_variables[] = {
 };
 
 static const builtin_variable builtin_110_deprecated_fs_variables[] = {
-   { ir_var_shader_in,  FRAG_ATTRIB_COL0,  "vec4",  "gl_Color" },
-   { ir_var_shader_in,  FRAG_ATTRIB_COL1,  "vec4",  "gl_SecondaryColor" },
-   { ir_var_shader_in,  FRAG_ATTRIB_FOGC,  "float", "gl_FogFragCoord" },
+   { ir_var_shader_in,  VARYING_SLOT_COL0,  "vec4",  "gl_Color" },
+   { ir_var_shader_in,  VARYING_SLOT_COL1,  "vec4",  "gl_SecondaryColor" },
+   { ir_var_shader_in,  VARYING_SLOT_FOGC,  "float", "gl_FogFragCoord" },
 };
 
 static const builtin_variable builtin_110_deprecated_vs_variables[] = {
@@ -105,7 +105,7 @@ static const builtin_variable builtin_110_deprecated_vs_variables[] = {
 };
 
 static const builtin_variable builtin_120_fs_variables[] = {
-   { ir_var_shader_in,  FRAG_ATTRIB_PNTC,   "vec2",   "gl_PointCoord" },
+   { ir_var_shader_in,  VARYING_SLOT_PNTC,   "vec2",   "gl_PointCoord" },
 };
 
 static const builtin_variable builtin_130_vs_variables[] = {
@@ -681,7 +681,7 @@ generate_110_uniforms(exec_list *instructions,
       glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX);
    add_uniform(instructions, symtab, "gl_CurrentAttribVertMESA", vert_attribs);
    const glsl_type *const frag_attribs =
-      glsl_type::get_array_instance(glsl_type::vec4_type, FRAG_ATTRIB_MAX);
+      glsl_type::get_array_instance(glsl_type::vec4_type, VARYING_SLOT_MAX);
    add_uniform(instructions, symtab, "gl_CurrentAttribFragMESA", frag_attribs);
 }
 
@@ -942,7 +942,7 @@ generate_110_fs_variables(exec_list *instructions,
 
    add_variable(instructions, state->symbols,
 		"gl_TexCoord", vec4_array_type, ir_var_shader_in,
-                FRAG_ATTRIB_TEX0);
+                VARYING_SLOT_TEX0);
 
    generate_ARB_draw_buffers_variables(instructions, state, false,
 				       fragment_shader);
@@ -1089,7 +1089,7 @@ generate_fs_clipdistance(exec_list *instructions,
 
    add_variable(instructions, state->symbols,
 		"gl_ClipDistance", clip_distance_array_type, ir_var_shader_in,
-                FRAG_ATTRIB_CLIP_DIST0);
+                VARYING_SLOT_CLIP_DIST0);
 }
 
 static void
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 2eb3af6..60ef8b9 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1553,7 +1553,7 @@ ir_variable::determine_interpolation_mode(bool flat_shade)
       return (glsl_interp_qualifier) this->interpolation;
    int location = this->location;
    bool is_gl_Color =
-      location == FRAG_ATTRIB_COL0 || location == FRAG_ATTRIB_COL1;
+      location == VARYING_SLOT_COL0 || location == VARYING_SLOT_COL1;
    if (flat_shade && is_gl_Color)
       return INTERP_QUALIFIER_FLAT;
    else
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 4d9e8a7..bbfec69 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -506,7 +506,7 @@ public:
     *
     *   - Vertex shader input: one of the values from \c gl_vert_attrib.
     *   - Vertex shader output: one of the values from \c gl_varying_slot.
-    *   - Fragment shader input: one of the values from \c gl_frag_attrib.
+    *   - Fragment shader input: one of the values from \c gl_varying_slot.
     *   - Fragment shader output: one of the values from \c gl_frag_result.
     *   - Uniforms: Per-stage uniform slot number for default uniform block.
     *   - Uniforms: Index within the uniform block definition for UBO members.
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 4da28e9..04c9fdd 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -604,8 +604,8 @@ private:
       /**
        * The location which has been assigned for this varying.  This is
        * expressed in multiples of a float, with the first generic varying
-       * (i.e. the one referred to by VARYING_SLOT_VAR0 or FRAG_ATTRIB_VAR0)
-       * represented by the value 0.
+       * (i.e. the one referred to by VARYING_SLOT_VAR0) represented by the
+       * value 0.
        */
       unsigned generic_location;
    } *matches;
@@ -842,9 +842,9 @@ is_varying_var(GLenum shaderType, const ir_variable *var)
    if (shaderType == GL_FRAGMENT_SHADER &&
        var->mode == ir_var_shader_in) {
       switch (var->location) {
-      case FRAG_ATTRIB_WPOS:
-      case FRAG_ATTRIB_FACE:
-      case FRAG_ATTRIB_PNTC:
+      case VARYING_SLOT_POS:
+      case VARYING_SLOT_FACE:
+      case VARYING_SLOT_PNTC:
          return false;
       default:
          return true;
@@ -958,9 +958,8 @@ assign_varying_locations(struct gl_context *ctx,
                          unsigned num_tfeedback_decls,
                          tfeedback_decl *tfeedback_decls)
 {
-   /* FINISHME: Set dynamically when geometry shader support is added. */
    const unsigned producer_base = VARYING_SLOT_VAR0;
-   const unsigned consumer_base = FRAG_ATTRIB_VAR0;
+   const unsigned consumer_base = VARYING_SLOT_VAR0;
    varying_matches matches(ctx->Const.DisableVaryingPacking);
    hash_table *tfeedback_candidates
       = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);

[snip]

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9c431af..83b6c89 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -286,32 +286,6 @@ typedef enum
 /*********************************************/
 
 /**
- * Indexes for fragment program input attributes.
- */
-typedef enum
-{
-   FRAG_ATTRIB_WPOS = VARYING_SLOT_POS,
-   FRAG_ATTRIB_COL0 = VARYING_SLOT_COL0,
-   FRAG_ATTRIB_COL1 = VARYING_SLOT_COL1,
-   FRAG_ATTRIB_FOGC = VARYING_SLOT_FOGC,
-   FRAG_ATTRIB_TEX0 = VARYING_SLOT_TEX0,
-   FRAG_ATTRIB_TEX1 = VARYING_SLOT_TEX1,
-   FRAG_ATTRIB_TEX2 = VARYING_SLOT_TEX2,
-   FRAG_ATTRIB_TEX3 = VARYING_SLOT_TEX3,
-   FRAG_ATTRIB_TEX4 = VARYING_SLOT_TEX4,
-   FRAG_ATTRIB_TEX5 = VARYING_SLOT_TEX5,
-   FRAG_ATTRIB_TEX6 = VARYING_SLOT_TEX6,
-   FRAG_ATTRIB_TEX7 = VARYING_SLOT_TEX7,
-   FRAG_ATTRIB_FACE = VARYING_SLOT_FACE,  /**< front/back face */
-   FRAG_ATTRIB_PNTC = VARYING_SLOT_PNTC,  /**< sprite/point coord */
-   FRAG_ATTRIB_CLIP_DIST0 = VARYING_SLOT_CLIP_DIST0,
-   FRAG_ATTRIB_CLIP_DIST1 = VARYING_SLOT_CLIP_DIST1,
-   FRAG_ATTRIB_VAR0 = VARYING_SLOT_VAR0,  /**< shader varying */
-   FRAG_ATTRIB_MAX = VARYING_SLOT_MAX
-} gl_frag_attrib;
-
-
-/**
  * Determine if the given gl_varying_slot appears in the fragment shader.
  */
 static inline GLboolean
@@ -332,40 +306,6 @@ _mesa_varying_slot_in_fs(gl_varying_slot slot)
 
 
 /**
- * Bitflags for fragment program input attributes.
- */
-/*@{*/
-#define FRAG_BIT_WPOS  (1 << FRAG_ATTRIB_WPOS)
-#define FRAG_BIT_COL0  (1 << FRAG_ATTRIB_COL0)
-#define FRAG_BIT_COL1  (1 << FRAG_ATTRIB_COL1)
-#define FRAG_BIT_FOGC  (1 << FRAG_ATTRIB_FOGC)
-#define FRAG_BIT_FACE  (1 << FRAG_ATTRIB_FACE)
-#define FRAG_BIT_PNTC  (1 << FRAG_ATTRIB_PNTC)
-#define FRAG_BIT_TEX0  (1 << FRAG_ATTRIB_TEX0)
-#define FRAG_BIT_TEX1  (1 << FRAG_ATTRIB_TEX1)
-#define FRAG_BIT_TEX2  (1 << FRAG_ATTRIB_TEX2)
-#define FRAG_BIT_TEX3  (1 << FRAG_ATTRIB_TEX3)
-#define FRAG_BIT_TEX4  (1 << FRAG_ATTRIB_TEX4)
-#define FRAG_BIT_TEX5  (1 << FRAG_ATTRIB_TEX5)
-#define FRAG_BIT_TEX6  (1 << FRAG_ATTRIB_TEX6)
-#define FRAG_BIT_TEX7  (1 << FRAG_ATTRIB_TEX7)
-#define FRAG_BIT_VAR0  (1 << FRAG_ATTRIB_VAR0)
-
-#define FRAG_BIT_TEX(U)  (FRAG_BIT_TEX0 << (U))
-#define FRAG_BIT_VAR(V)  (FRAG_BIT_VAR0 << (V))
-
-#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0|	\
-			   FRAG_BIT_TEX1|	\
-			   FRAG_BIT_TEX2|	\
-			   FRAG_BIT_TEX3|	\
-			   FRAG_BIT_TEX4|	\
-			   FRAG_BIT_TEX5|	\
-			   FRAG_BIT_TEX6|	\
-			   FRAG_BIT_TEX7)
-/*@}*/
-
-
-/**
  * Fragment program results
  */
 typedef enum
@@ -2016,7 +1956,7 @@ struct gl_fragment_program
     * For inputs that do not have an interpolation qualifier specified in
     * GLSL, the value is INTERP_QUALIFIER_NONE.
     */
-   enum glsl_interp_qualifier InterpQualifier[FRAG_ATTRIB_MAX];
+   enum glsl_interp_qualifier InterpQualifier[VARYING_SLOT_MAX];
 
    /**
     * Bitfield indicating, for each fragment shader input, 1 if that input

[snip]

-- 
1.8.1.5



More information about the mesa-dev mailing list