Mesa (gallium-0.2): glsl: minor clean-up for rect sampler test

Alan Hourihane alanh at kemper.freedesktop.org
Fri Jan 16 16:45:06 UTC 2009


Module: Mesa
Branch: gallium-0.2
Commit: b5f32e1d5a1780292b10ba51fa2c7d05e77a7346
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5f32e1d5a1780292b10ba51fa2c7d05e77a7346

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Jan 14 12:33:06 2009 -0700

glsl: minor clean-up for rect sampler test

---

 src/mesa/shader/slang/slang_codegen.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 51eb4c9..11340d2 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -4239,6 +4239,21 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
 
 
 /**
+ * Check if the given type specifier is a rectangular texture sampler.
+ */
+static GLboolean
+is_rect_sampler_spec(const slang_type_specifier *spec)
+{
+   while (spec->_array) {
+      spec = spec->_array;
+   }
+   return spec->type == SLANG_SPEC_SAMPLER2DRECT ||
+          spec->type == SLANG_SPEC_SAMPLER2DRECTSHADOW;
+}
+
+
+
+/**
  * Called by compiler when a global variable has been parsed/compiled.
  * Here we examine the variable's type to determine what kind of register
  * storage will be used.
@@ -4282,14 +4297,12 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
       }
 #if FEATURE_es2_glsl /* XXX should use FEATURE_texture_rect */
       /* disallow rect samplers */
-      if ((var->type.specifier._array && 
-           (var->type.specifier._array->type == SLANG_SPEC_SAMPLER2DRECT ||
-            var->type.specifier._array->type == SLANG_SPEC_SAMPLER2DRECTSHADOW)) ||
-          (var->type.specifier.type == SLANG_SPEC_SAMPLER2DRECT ||
-           var->type.specifier.type == SLANG_SPEC_SAMPLER2DRECTSHADOW)) {
+      if (is_rect_sampler_spec(&var->type.specifier)) {
          slang_info_log_error(A->log, "invalid sampler type for '%s'", varName);
          return GL_FALSE;
       }
+#else
+      (void) is_rect_sampler_spec; /* silence warning */
 #endif
       {
          GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype);




More information about the mesa-commit mailing list