[Mesa-dev] [PATCH 2/8] mesa: set up gl_vert_result and gl_frag_attrib values for gl_ClipDistance.

Paul Berry stereotype441 at gmail.com
Tue Sep 20 15:42:32 PDT 2011


This patch assigns enumerated values for gl_ClipDistance in the
gl_vert_result and gl_frag_attrib enums, so that driver back-ends can
assign gl_ClipDistance to the appropriate hardware registers.  It also
adjusts the functions _mesa_vert_result_to_frag_attrib() and
_mesa_frag_attrib_to_vert_result() (which translate between the two
enums) to correctly translate the new enumerated values.
---
 src/glsl/ir_variable.cpp |    8 ++++----
 src/mesa/main/mtypes.h   |   16 ++++++++++------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index e0b6f38..58be64b 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -621,9 +621,9 @@ generate_130_vs_variables(exec_list *instructions,
    const glsl_type *const clip_distance_array_type =
       glsl_type::get_array_instance(glsl_type::float_type, 0);
 
-   /* FINISHME: gl_ClipDistance needs a real location assigned. */
    add_variable(instructions, state->symbols,
-		"gl_ClipDistance", clip_distance_array_type, ir_var_out, -1);
+		"gl_ClipDistance", clip_distance_array_type, ir_var_out,
+                VERT_RESULT_CLIP_DIST0);
 
 }
 
@@ -841,9 +841,9 @@ generate_130_fs_variables(exec_list *instructions,
    const glsl_type *const clip_distance_array_type =
       glsl_type::get_array_instance(glsl_type::float_type, 0);
 
-   /* FINISHME: gl_ClipDistance needs a real location assigned. */
    add_variable(instructions, state->symbols,
-		"gl_ClipDistance", clip_distance_array_type, ir_var_in, -1);
+		"gl_ClipDistance", clip_distance_array_type, ir_var_in,
+                FRAG_ATTRIB_CLIP_DIST0);
 }
 
 static void
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 173d6c2..1c3ac40 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -237,7 +237,9 @@ typedef enum
    VERT_RESULT_BFC0 = 13,
    VERT_RESULT_BFC1 = 14,
    VERT_RESULT_EDGE = 15,
-   VERT_RESULT_VAR0 = 16,  /**< shader varying */
+   VERT_RESULT_CLIP_DIST0 = 16,
+   VERT_RESULT_CLIP_DIST1 = 17,
+   VERT_RESULT_VAR0 = 18,  /**< shader varying */
    VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING)
 } gl_vert_result;
 
@@ -335,7 +337,9 @@ typedef enum
    FRAG_ATTRIB_TEX7 = 11,
    FRAG_ATTRIB_FACE = 12,  /**< front/back face */
    FRAG_ATTRIB_PNTC = 13,  /**< sprite/point coord */
-   FRAG_ATTRIB_VAR0 = 14,  /**< shader varying */
+   FRAG_ATTRIB_CLIP_DIST0 = 14,
+   FRAG_ATTRIB_CLIP_DIST1 = 15,
+   FRAG_ATTRIB_VAR0 = 16,  /**< shader varying */
    FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
 } gl_frag_attrib;
 
@@ -352,8 +356,8 @@ typedef enum
 static INLINE int
 _mesa_vert_result_to_frag_attrib(gl_vert_result vert_result)
 {
-   if (vert_result >= VERT_RESULT_VAR0)
-      return vert_result - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0;
+   if (vert_result >= VERT_RESULT_CLIP_DIST0)
+      return vert_result - VERT_RESULT_CLIP_DIST0 + FRAG_ATTRIB_CLIP_DIST0;
    else if (vert_result <= VERT_RESULT_TEX7)
       return vert_result;
    else
@@ -374,8 +378,8 @@ _mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib)
 {
    if (frag_attrib <= FRAG_ATTRIB_TEX7)
       return frag_attrib;
-   else if (frag_attrib >= FRAG_ATTRIB_VAR0)
-      return frag_attrib - FRAG_ATTRIB_VAR0 + VERT_RESULT_VAR0;
+   else if (frag_attrib >= FRAG_ATTRIB_CLIP_DIST0)
+      return frag_attrib - FRAG_ATTRIB_CLIP_DIST0 + VERT_RESULT_CLIP_DIST0;
    else
       return -1;
 }
-- 
1.7.6.2



More information about the mesa-dev mailing list