summaryrefslogtreecommitdiff
path: root/src/glsl/ast_type.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2012-06-22 13:36:35 -0700
committerEric Anholt <eric@anholt.net>2012-07-31 12:06:20 -0700
commit551bdf25bc4e57bea51c54da7e31c44c507e6c9f (patch)
tree30fe843355b1f850c0ce0772b605b65f1e03dd46 /src/glsl/ast_type.cpp
parent7b77c64254109ff1d59a8937f8f15216c10c8cb7 (diff)
glsl: Add support for default layout qualifiers for uniforms.
I ended up having to add rallocing of the ast_type_qualifier in order to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted to track an ast_type_qualifier in the state. Fixes piglit ARB_uniform_buffer_object/row-major. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/ast_type.cpp')
-rw-r--r--src/glsl/ast_type.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 6c44f8c41de..29493e2f6c6 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -71,3 +71,48 @@ ast_type_qualifier::interpolation_string() const
else
return NULL;
}
+
+bool
+ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
+ _mesa_glsl_parse_state *state,
+ ast_type_qualifier q)
+{
+ ast_type_qualifier ubo_mat_mask;
+ ubo_mat_mask.flags.i = 0;
+ ubo_mat_mask.flags.q.row_major = 1;
+ ubo_mat_mask.flags.q.column_major = 1;
+
+ ast_type_qualifier ubo_layout_mask;
+ ubo_layout_mask.flags.i = 0;
+ ubo_layout_mask.flags.q.std140 = 1;
+ ubo_layout_mask.flags.q.packed = 1;
+ ubo_layout_mask.flags.q.shared = 1;
+
+ /* Uniform block layout qualifiers get to overwrite each
+ * other (rightmost having priority), while all other
+ * qualifiers currently don't allow duplicates.
+ */
+
+ if ((this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i |
+ ubo_layout_mask.flags.i)) != 0) {
+ _mesa_glsl_error(loc, state,
+ "duplicate layout qualifiers used\n");
+ return false;
+ }
+
+ if ((q.flags.i & ubo_mat_mask.flags.i) != 0)
+ this->flags.i &= ~ubo_mat_mask.flags.i;
+ if ((q.flags.i & ubo_layout_mask.flags.i) != 0)
+ this->flags.i &= ~ubo_layout_mask.flags.i;
+
+ this->flags.i |= q.flags.i;
+
+ if (q.flags.q.explicit_location)
+ this->location = q.location;
+
+ if (q.flags.q.explicit_index)
+ this->index = q.index;
+
+ return true;
+}
+