[Mesa-dev] [PATCH 1/2] mesa, gallium: add a cap for GPUs without unified color+generic varying slots

Marek Olšák maraeo at gmail.com
Tue Dec 13 16:32:06 PST 2011


---
 src/gallium/drivers/r300/r300_screen.c |    3 ++-
 src/gallium/include/pipe/p_defines.h   |    3 ++-
 src/glsl/linker.cpp                    |    6 ++++++
 src/mesa/main/mtypes.h                 |    9 +++++++++
 src/mesa/state_tracker/st_extensions.c |    3 +++
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 0bae065..a761939 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -102,6 +102,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TEXTURE_BARRIER:
         case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
         case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
+        case PIPE_CAP_SEPARATE_COLOR_VARYINGS:
             return 1;
 
         /* r300 cannot do swizzling of compressed textures. Supported otherwise. */
@@ -182,7 +183,7 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
              * R500 has the ability to turn 3rd and 4th color into
              * additional texcoords but there is no two-sided color
              * selection then. However the facing bit can be used instead. */
-            return 10;
+            return 8;
         case PIPE_SHADER_CAP_MAX_CONSTS:
             return is_r500 ? 256 : 32;
         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 30f1d7f..5229c5f 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -467,7 +467,8 @@ enum pipe_cap {
    PIPE_CAP_CONDITIONAL_RENDER = 52,
    PIPE_CAP_TEXTURE_BARRIER = 53,
    PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS = 54, /* temporary */
-   PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS = 55 /* temporary */
+   PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS = 55, /* temporary */
+   PIPE_CAP_SEPARATE_COLOR_VARYINGS = 56
 };
 
 /**
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index b8a7126..e9298bb 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1805,6 +1805,12 @@ assign_varying_locations(struct gl_context *ctx,
              */
             var->mode = ir_var_auto;
          } else {
+            if (ctx->Const.GLSLSeparateColorVaryings &&
+                (var->location == FRAG_ATTRIB_COL0 ||
+                 var->location == FRAG_ATTRIB_COL1)) {
+               continue;
+            }
+
             /* The packing rules are used for vertex shader inputs are also
              * used for fragment shader inputs.
              */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1934349..9e9ad83 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2839,6 +2839,15 @@ struct gl_constants
     */
    GLboolean GLSLSkipStrictMaxVaryingLimitCheck;
    GLboolean GLSLSkipStrictMaxUniformLimitCheck;
+
+   /**
+    * Whether the color varyings do not share varying slots with generic
+    * varyings. In such a case, the driver must not include the color
+    * varyings in the maximum number of varyings limit. In return,
+    * the GLSL linker will not count the color varyings to the number of
+    * used varying components.
+    */
+   GLboolean GLSLSeparateColorVaryings;
 };
 
 
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 457d5d6..7a7919f 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -228,6 +228,9 @@ void st_init_limits(struct st_context *st)
 
    c->GLSLSkipStrictMaxVaryingLimitCheck =
       screen->get_param(screen, PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS);
+
+   c->GLSLSeparateColorVaryings =
+      screen->get_param(screen, PIPE_CAP_SEPARATE_COLOR_VARYINGS);
 }
 
 
-- 
1.7.4.1



More information about the mesa-dev mailing list