summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-04-26 18:19:39 -0700
committerEric Anholt <[email protected]>2012-07-20 10:43:12 -0700
commitf7561e8ecd80e915150ca63c0c79a5f9839c8e12 (patch)
tree76d52d4b5a5b69a0b8d3ac06f3bdd79ff302400a /src/glsl/ast_to_hir.cpp
parentcdad337fec39d788a4b04de080a51d0ea1325e10 (diff)
glsl: Turn UBO variable declarations into ir_variables and check qualifiers.
Fixes piglit layout-*-non-uniform and layout-*-within-block. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 5ad754c398d..8c739653fbe 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1917,7 +1917,8 @@ static void
apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
ir_variable *var,
struct _mesa_glsl_parse_state *state,
- YYLTYPE *loc)
+ YYLTYPE *loc,
+ bool ubo_qualifiers_valid)
{
if (qual->flags.q.invariant) {
if (var->used) {
@@ -2177,6 +2178,23 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
var->depth_layout = ir_depth_layout_unchanged;
else
var->depth_layout = ir_depth_layout_none;
+
+ if (qual->flags.q.std140 ||
+ qual->flags.q.packed ||
+ qual->flags.q.shared) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers std140, packed, and "
+ "shared can only be applied to uniform blocks, not "
+ "members");
+ }
+
+ if (!ubo_qualifiers_valid &&
+ (qual->flags.q.row_major || qual->flags.q.column_major)) {
+ _mesa_glsl_error(loc, state,
+ "uniform block layout qualifiers row_major and "
+ "column_major can only be applied to uniform block "
+ "members");
+ }
}
/**
@@ -2597,7 +2615,7 @@ ast_declarator_list::hir(exec_list *instructions,
}
apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
- & loc);
+ & loc, this->ubo_qualifiers_valid);
if (this->type->qualifier.flags.q.invariant) {
if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
@@ -3014,7 +3032,8 @@ ast_parameter_declarator::hir(exec_list *instructions,
/* Apply any specified qualifiers to the parameter declaration. Note that
* for function parameters the default mode is 'in'.
*/
- apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc);
+ apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc,
+ false);
/* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
*
@@ -3983,6 +4002,14 @@ ast_uniform_block::hir(exec_list *instructions,
* need to turn those into ir_variables with an association
* with this uniform block.
*/
+ foreach_list_typed(ast_declarator_list, decl_list, link, &declarations) {
+ exec_list declared_variables;
+
+ decl_list->hir(&declared_variables, state);
+
+ instructions->append_list(&declared_variables);
+ }
+
return NULL;
}