Mesa (master): glsl: be more careful about counting varying vars in the linker

Brian Paul brianp at kemper.freedesktop.org
Wed Jun 27 17:31:46 UTC 2012


Module: Mesa
Branch: master
Commit: 8fb1e4a4628caee9e80dcbc47f8f9c772db09419
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fb1e4a4628caee9e80dcbc47f8f9c772db09419

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jun 26 13:06:47 2012 -0600

glsl: be more careful about counting varying vars in the linker

Previously, we were counting gl_FrontFacing, gl_FragCoord and gl_PointCoord
against the limit of varying variables.  This prevented some valid shaders
from linking.

The other potential solution to this is to have the driver advertise
more varying vars or set the GLSLSkipStrictMaxVaryingLimitCheck flag.
But the above-mentioned variables aren't conventional varying attributes
so it doesn't seem right to count them.

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/glsl/linker.cpp |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index bdab499..3109447 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1859,6 +1859,32 @@ assign_varying_location(ir_variable *input_var, ir_variable *output_var,
 
 
 /**
+ * Is the given variable a varying variable to be counted against the
+ * limit in ctx->Const.MaxVarying?
+ * This includes variables such as texcoords, colors and generic
+ * varyings, but excludes variables such as gl_FrontFacing and gl_FragCoord.
+ */
+static bool
+is_varying_var(GLenum shaderType, const ir_variable *var)
+{
+   /* Only fragment shaders will take a varying variable as an input */
+   if (shaderType == GL_FRAGMENT_SHADER &&
+       var->mode == ir_var_in &&
+       var->explicit_location) {
+      switch (var->location) {
+      case FRAG_ATTRIB_WPOS:
+      case FRAG_ATTRIB_FACE:
+      case FRAG_ATTRIB_PNTC:
+         return false;
+      default:
+         return true;
+      }
+   }
+   return false;
+}
+
+
+/**
  * Assign locations for all variables that are produced in one pipeline stage
  * (the "producer") and consumed in the next stage (the "consumer").
  *
@@ -1966,7 +1992,7 @@ assign_varying_locations(struct gl_context *ctx,
              * value is written by the previous stage.
              */
             var->mode = ir_var_auto;
-         } else {
+         } else if (is_varying_var(consumer->Type, var)) {
             /* The packing rules are used for vertex shader inputs are also
              * used for fragment shader inputs.
              */




More information about the mesa-commit mailing list