The new interpolateAt* builtins have strange restrictions on the <interpolant> parameter.
- It must be a shader input, or an element of a shader input array. - It must not include a swizzle. V2: Don't abuse ir_var_mode_shader_in for this; make a new flag. Signed-off-by: Chris Forbes <chr...@ijw.co.nz> --- src/glsl/ast_function.cpp | 18 ++++++++++++++++++ src/glsl/ir.h | 6 ++++++ src/glsl/ir_clone.cpp | 1 + 3 files changed, 25 insertions(+) diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 2707522..8730e71 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -131,6 +131,24 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, return false; } + /* Verify that shader_in parameters are shader inputs */ + if (formal->must_be_shader_input) { + ir_variable *var = actual->variable_referenced(); + if (var && var->mode != ir_var_shader_in) { + _mesa_glsl_error(&loc, state, + "parameter `%s` must be a shader input", + formal->name); + return false; + } + + if (actual->ir_type == ir_type_swizzle) { + _mesa_glsl_error(&loc, state, + "parameter `%s` must not be swizzled", + formal->name); + return false; + } + } + /* Verify that 'out' and 'inout' actual parameters are lvalues. */ if (formal->mode == ir_var_function_out || formal->mode == ir_var_function_inout) { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 4f775da..61dd520 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -646,6 +646,12 @@ public: unsigned from_named_ifc_block_array:1; /** + * Non-zero if the variable must be a shader input. This is useful for + * constraints on function parameters. + */ + unsigned must_be_shader_input:1; + + /** * \brief Layout qualifier for gl_FragDepth. * * This is not equal to \c ir_depth_layout_none if and only if this diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 40ed33a..edf578b 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -70,6 +70,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const var->assigned = this->assigned; var->how_declared = this->how_declared; var->used = this->used; + var->must_be_shader_input = this->must_be_shader_input; var->num_state_slots = this->num_state_slots; if (this->state_slots) { -- 1.8.4.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev