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

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


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

gl_vert_result -> gl_varying_slot
VERT_RESULT_* -> VARYING_SLOT_*
--

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                 | 20 ++++----
 src/glsl/ir.h                                  |  2 +-
 src/glsl/link_varyings.cpp                     |  4 +-
 src/glsl/linker.cpp                            |  2 +-
 src/glsl/lower_packed_varyings.cpp             |  2 +-
 src/mesa/drivers/dri/i965/brw_clip_line.c      |  2 +-
 src/mesa/drivers/dri/i965/brw_clip_tri.c       |  4 +-
 src/mesa/drivers/dri/i965/brw_clip_unfilled.c  | 38 +++++++--------
 src/mesa/drivers/dri/i965/brw_clip_util.c      | 38 +++++++--------
 src/mesa/drivers/dri/i965/brw_context.h        | 35 +++++++-------
 src/mesa/drivers/dri/i965/brw_fs.cpp           |  8 +--
 src/mesa/drivers/dri/i965/brw_gs.c             |  2 +-
 src/mesa/drivers/dri/i965/brw_gs.h             |  2 +-
 src/mesa/drivers/dri/i965/brw_gs_emit.c        |  4 +-
 src/mesa/drivers/dri/i965/brw_sf.c             |  6 +--
 src/mesa/drivers/dri/i965/brw_sf_emit.c        | 48 +++++++++---------
 src/mesa/drivers/dri/i965/brw_vec4.h           |  4 +-
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 58 +++++++++++-----------
 src/mesa/drivers/dri/i965/brw_vec4_vp.cpp      |  2 +-
 src/mesa/drivers/dri/i965/brw_vs.c             | 60 +++++++++++------------
 src/mesa/drivers/dri/i965/brw_vs_constval.c    | 14 +++---
 src/mesa/drivers/dri/i965/gen6_sf_state.c      | 18 +++----
 src/mesa/drivers/dri/i965/gen7_sol_state.c     |  4 +-
 src/mesa/drivers/dri/r200/r200_tcl.c           | 14 +++---
 src/mesa/drivers/dri/r200/r200_vertprog.c      | 40 +++++++--------
 src/mesa/main/context.c                        |  6 +--
 src/mesa/main/ff_fragment_shader.cpp           |  7 ++-
 src/mesa/main/ffvertex_prog.c                  | 38 +++++++--------
 src/mesa/main/mtypes.h                         | 67 +++++++-------------------
 src/mesa/program/prog_print.c                  | 22 ++++-----
 src/mesa/program/program.c                     |  2 +-
 src/mesa/program/program_parse.y               | 16 +++---
 src/mesa/program/programopt.c                  | 18 +++----
 src/mesa/state_tracker/st_atom_rasterizer.c    |  2 +-
 src/mesa/state_tracker/st_cb_feedback.c        |  4 +-
 src/mesa/state_tracker/st_cb_rasterpos.c       |  6 +--
 src/mesa/state_tracker/st_context.h            |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp     | 12 ++---
 src/mesa/state_tracker/st_mesa_to_tgsi.c       | 12 ++---
 src/mesa/state_tracker/st_program.c            | 52 ++++++++++----------
 src/mesa/state_tracker/st_program.h            |  8 +--
 src/mesa/tnl/t_context.c                       |  2 +-
 src/mesa/tnl/t_context.h                       |  2 +-
 src/mesa/tnl/t_pipeline.c                      |  2 +-
 src/mesa/tnl/t_vb_program.c                    | 38 +++++++--------
 45 files changed, 358 insertions(+), 391 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 53c4c51..531effd 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -47,8 +47,8 @@ struct builtin_variable {
 };
 
 static const builtin_variable builtin_core_vs_variables[] = {
-   { ir_var_shader_out, VERT_RESULT_HPOS, "vec4",  "gl_Position" },
-   { ir_var_shader_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" },
+   { ir_var_shader_out, VARYING_SLOT_POS,  "vec4",  "gl_Position" },
+   { ir_var_shader_out, VARYING_SLOT_PSIZ, "float", "gl_PointSize" },
 };
 
 static const builtin_variable builtin_core_fs_variables[] = {
@@ -96,12 +96,12 @@ static const builtin_variable builtin_110_deprecated_vs_variables[] = {
    { ir_var_shader_in,  VERT_ATTRIB_TEX6,        "vec4",  "gl_MultiTexCoord6" },
    { ir_var_shader_in,  VERT_ATTRIB_TEX7,        "vec4",  "gl_MultiTexCoord7" },
    { ir_var_shader_in,  VERT_ATTRIB_FOG,         "float", "gl_FogCoord" },
-   { ir_var_shader_out, VERT_RESULT_CLIP_VERTEX, "vec4",  "gl_ClipVertex" },
-   { ir_var_shader_out, VERT_RESULT_COL0,        "vec4",  "gl_FrontColor" },
-   { ir_var_shader_out, VERT_RESULT_BFC0,        "vec4",  "gl_BackColor" },
-   { ir_var_shader_out, VERT_RESULT_COL1,        "vec4",  "gl_FrontSecondaryColor" },
-   { ir_var_shader_out, VERT_RESULT_BFC1,        "vec4",  "gl_BackSecondaryColor" },
-   { ir_var_shader_out, VERT_RESULT_FOGC,        "float", "gl_FogFragCoord" },
+   { ir_var_shader_out, VARYING_SLOT_CLIP_VERTEX, "vec4",  "gl_ClipVertex" },
+   { ir_var_shader_out, VARYING_SLOT_COL0,        "vec4",  "gl_FrontColor" },
+   { ir_var_shader_out, VARYING_SLOT_BFC0,        "vec4",  "gl_BackColor" },
+   { ir_var_shader_out, VARYING_SLOT_COL1,        "vec4",  "gl_FrontSecondaryColor" },
+   { ir_var_shader_out, VARYING_SLOT_BFC1,        "vec4",  "gl_BackSecondaryColor" },
+   { ir_var_shader_out, VARYING_SLOT_FOGC,        "float", "gl_FogFragCoord" },
 };
 
 static const builtin_variable builtin_120_fs_variables[] = {
@@ -755,7 +755,7 @@ generate_110_vs_variables(exec_list *instructions,
 
    add_variable(instructions, state->symbols,
 		"gl_TexCoord", vec4_array_type, ir_var_shader_out,
-                VERT_RESULT_TEX0);
+                VARYING_SLOT_TEX0);
 
    generate_ARB_draw_buffers_variables(instructions, state, false,
 				       vertex_shader);
@@ -816,7 +816,7 @@ generate_130_vs_variables(exec_list *instructions,
 
    add_variable(instructions, state->symbols,
 		"gl_ClipDistance", clip_distance_array_type, ir_var_shader_out,
-                VERT_RESULT_CLIP_DIST0);
+                VARYING_SLOT_CLIP_DIST0);
 
 }
 
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 393b486..4d9e8a7 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -505,7 +505,7 @@ public:
     * The precise meaning of this field depends on the nature of the variable.
     *
     *   - Vertex shader input: one of the values from \c gl_vert_attrib.
-    *   - Vertex shader output: one of the values from \c gl_vert_result.
+    *   - 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 output: one of the values from \c gl_frag_result.
     *   - Uniforms: Per-stage uniform slot number for default uniform block.
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 616933d..4da28e9 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -604,7 +604,7 @@ 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 VERT_RESULT_VAR0 or FRAG_ATTRIB_VAR0)
+       * (i.e. the one referred to by VARYING_SLOT_VAR0 or FRAG_ATTRIB_VAR0)
        * represented by the value 0.
        */
       unsigned generic_location;
@@ -959,7 +959,7 @@ assign_varying_locations(struct gl_context *ctx,
                          tfeedback_decl *tfeedback_decls)
 {
    /* FINISHME: Set dynamically when geometry shader support is added. */
-   const unsigned producer_base = VERT_RESULT_VAR0;
+   const unsigned producer_base = VARYING_SLOT_VAR0;
    const unsigned consumer_base = FRAG_ATTRIB_VAR0;
    varying_matches matches(ctx->Const.DisableVaryingPacking);
    hash_table *tfeedback_candidates

[snip]

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 37cc2da..1e62e19 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -283,37 +283,6 @@ typedef enum
 /*@}*/
 
 
-/**
- * Indexes for vertex program result attributes.  Note that
- * _mesa_vert_result_to_frag_attrib() and _mesa_frag_attrib_to_vert_result() make
- * assumptions about the layout of this enum.
- */
-typedef enum
-{
-   VERT_RESULT_HPOS = VARYING_SLOT_POS,
-   VERT_RESULT_COL0 = VARYING_SLOT_COL0,
-   VERT_RESULT_COL1 = VARYING_SLOT_COL1,
-   VERT_RESULT_FOGC = VARYING_SLOT_FOGC,
-   VERT_RESULT_TEX0 = VARYING_SLOT_TEX0,
-   VERT_RESULT_TEX1 = VARYING_SLOT_TEX1,
-   VERT_RESULT_TEX2 = VARYING_SLOT_TEX2,
-   VERT_RESULT_TEX3 = VARYING_SLOT_TEX3,
-   VERT_RESULT_TEX4 = VARYING_SLOT_TEX4,
-   VERT_RESULT_TEX5 = VARYING_SLOT_TEX5,
-   VERT_RESULT_TEX6 = VARYING_SLOT_TEX6,
-   VERT_RESULT_TEX7 = VARYING_SLOT_TEX7,
-   VERT_RESULT_PSIZ = VARYING_SLOT_PSIZ,
-   VERT_RESULT_BFC0 = VARYING_SLOT_BFC0,
-   VERT_RESULT_BFC1 = VARYING_SLOT_BFC1,
-   VERT_RESULT_EDGE = VARYING_SLOT_EDGE,
-   VERT_RESULT_CLIP_VERTEX = VARYING_SLOT_CLIP_VERTEX,
-   VERT_RESULT_CLIP_DIST0 = VARYING_SLOT_CLIP_DIST0,
-   VERT_RESULT_CLIP_DIST1 = VARYING_SLOT_CLIP_DIST1,
-   VERT_RESULT_VAR0 = VARYING_SLOT_VAR0,  /**< shader varying */
-   VERT_RESULT_MAX = VARYING_SLOT_MAX
-} gl_vert_result;
-
-
 /*********************************************/
 
 /**
@@ -415,36 +384,34 @@ typedef enum
 
 
 /**
- * Convert from a gl_vert_result value to the corresponding gl_frag_attrib.
+ * Convert from a gl_varying_slot value for a vertex output to the
+ * corresponding gl_frag_attrib.
  *
- * VERT_RESULT_HPOS is converted to FRAG_ATTRIB_WPOS.
- *
- * gl_vert_result values which have no corresponding gl_frag_attrib
- * (VERT_RESULT_PSIZ, VERT_RESULT_BFC0, VERT_RESULT_BFC1, and
- * VERT_RESULT_EDGE) are converted to a value of -1.
+ * Varying output values which have no corresponding gl_frag_attrib
+ * (VARYING_SLOT_PSIZ, VARYING_SLOT_BFC0, VARYING_SLOT_BFC1, and
+ * VARYING_SLOT_EDGE) are converted to a value of -1.
  */
 static inline int
-_mesa_vert_result_to_frag_attrib(gl_vert_result vert_result)
+_mesa_vert_result_to_frag_attrib(gl_varying_slot vert_result)
 {
-   if (vert_result <= VERT_RESULT_TEX7)
+   if (vert_result <= VARYING_SLOT_TEX7)
       return vert_result;
-   else if (vert_result < VERT_RESULT_CLIP_DIST0)
+   else if (vert_result < VARYING_SLOT_CLIP_DIST0)
       return -1;
-   else if (vert_result <= VERT_RESULT_CLIP_DIST1)
-      return vert_result - VERT_RESULT_CLIP_DIST0 + FRAG_ATTRIB_CLIP_DIST0;
-   else if (vert_result < VERT_RESULT_VAR0)
+   else if (vert_result <= VARYING_SLOT_CLIP_DIST1)
+      return vert_result - VARYING_SLOT_CLIP_DIST0 + FRAG_ATTRIB_CLIP_DIST0;
+   else if (vert_result < VARYING_SLOT_VAR0)
       return -1;
    else
-      return vert_result - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0;
+      return vert_result - VARYING_SLOT_VAR0 + FRAG_ATTRIB_VAR0;
 }
 
 
 /**
- * Convert from a gl_frag_attrib value to the corresponding gl_vert_result.
- *
- * FRAG_ATTRIB_WPOS is converted to VERT_RESULT_HPOS.
+ * Convert from a gl_frag_attrib value to the corresponding gl_varying_slot
+ * for a vertex output.
  *
- * gl_frag_attrib values which have no corresponding gl_vert_result
+ * gl_frag_attrib values which have no corresponding vertex output
  * (FRAG_ATTRIB_FACE and FRAG_ATTRIB_PNTC) are converted to a value of -1.
  */
 static inline int
@@ -455,9 +422,9 @@ _mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib)
    else if (frag_attrib < FRAG_ATTRIB_CLIP_DIST0)
       return -1;
    else if (frag_attrib <= FRAG_ATTRIB_CLIP_DIST1)
-      return frag_attrib - FRAG_ATTRIB_CLIP_DIST0 + VERT_RESULT_CLIP_DIST0;
+      return frag_attrib - FRAG_ATTRIB_CLIP_DIST0 + VARYING_SLOT_CLIP_DIST0;
    else /* frag_attrib >= FRAG_ATTRIB_VAR0 */
-      return frag_attrib - FRAG_ATTRIB_VAR0 + VERT_RESULT_VAR0;
+      return frag_attrib - FRAG_ATTRIB_VAR0 + VARYING_SLOT_VAR0;
 }
 
 
[snip]

-- 
1.8.1.5



More information about the mesa-dev mailing list