From 819d57fce94b20fa0d34da6f037f0a53c4a5bdc2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 12 Jan 2011 15:37:37 -0800 Subject: 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. --- src/glsl/ast_function.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/glsl/ast_function.cpp') 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; -- cgit v1.2.3