[Mesa-dev] [PATCH v2] glsl: reject samplers not declared as uniform/function params earlier

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Feb 24 13:46:08 UTC 2017


This improves consistency with image variables and atomic
counters which are already rejected the same way.

Note that opaque variables can't be treated as l-values, which
means only the 'in' function parameter is allowed.

v2: rewrite commit message

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com> (v1)
---
 src/compiler/glsl/ast_to_hir.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index ad1fd9150a..c0629feb58 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -3589,6 +3589,15 @@ apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual,
       }
    }
 
+   if (var->type->contains_sampler()) {
+      if (var->data.mode != ir_var_uniform &&
+          var->data.mode != ir_var_function_in) {
+         _mesa_glsl_error(loc, state, "sampler variables may only be declared "
+                          "as function parameters or uniform-qualified "
+                          "global variables");
+      }
+   }
+
    /* Is the 'layout' keyword used with parameters that allow relaxed checking.
     * Many implementations of GL_ARB_fragment_coord_conventions_enable and some
     * implementations (only Mesa?) GL_ARB_explicit_attrib_location_enable
-- 
2.11.1



More information about the mesa-dev mailing list