summaryrefslogtreecommitdiff
path: root/src/glsl/ast_function.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2011-01-12 15:37:37 -0800
committerKenneth Graunke <kenneth@whitecape.org>2011-01-31 11:10:59 -0800
commit819d57fce94b20fa0d34da6f037f0a53c4a5bdc2 (patch)
treeea4c12c2a582e0f4a4119b4ace0bfecc5245d14b /src/glsl/ast_function.cpp
parentc5a27b5939427bdc95c926b450ed3de1ff4baafb (diff)
glsl: Introduce a new "const_in" variable mode.
This annotation is for an "in" function parameter for which it is only legal to pass constant expressions. The only known example of this, currently, is the textureOffset functions. This should never be used for globals.
Diffstat (limited to 'src/glsl/ast_function.cpp')
-rw-r--r--src/glsl/ast_function.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index b3635bf686..b0f95dd73b 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -132,6 +132,9 @@ match_function_by_name(exec_list *instructions, const char *name,
/* Verify that 'out' and 'inout' actual parameters are lvalues. This
* isn't done in ir_function::matching_signature because that function
* cannot generate the necessary diagnostics.
+ *
+ * Also, validate that 'const_in' formal parameters (an extension of our
+ * IR) correspond to ir_constant actual parameters.
*/
exec_list_iterator actual_iter = actual_parameters->iterator();
exec_list_iterator formal_iter = sig->parameters.iterator();
@@ -143,6 +146,12 @@ match_function_by_name(exec_list *instructions, const char *name,
assert(actual != NULL);
assert(formal != NULL);
+ if (formal->mode == ir_var_const_in && !actual->as_constant()) {
+ _mesa_glsl_error(loc, state,
+ "parameter `%s' must be a constant expression",
+ formal->name);
+ }
+
if ((formal->mode == ir_var_out)
|| (formal->mode == ir_var_inout)) {
const char *mode = NULL;