summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-02-23 18:07:58 +0100
committerSamuel Pitoiset <[email protected]>2017-02-27 19:39:37 +0100
commit87ee1729d0cd5c6a26c62109eae9b75b006a9d1a (patch)
tree7a25d5390a3f38fb8d3f9c8f877eb63f65214187 /src/compiler/glsl/ast_to_hir.cpp
parentde2727925a5b69e7c7fa1fee3c7e7ad0cbabcb02 (diff)
glsl: use an enum for AMD_conservative_depth layout qualifiers
The main idea behind this is to free some bits in the flags.q struct because currently all 64-bits are used and we can't add more layout qualifiers without reaching a static assert. In order to do that (mainly for ARB_bindless_texture), use an enumeration for the AMD_conservative_depth layout qualifiers because it's forbidden to declare more than one depth qualifier for gl_FragDepth. Note that ast_type_qualifier::merge_qualifier() will prevent using duplicate layout qualifiers by returning a compile-time error. No piglit regressions found (including compiler tests) with RX480 on RadeonSI. v2: use a switch case Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]> (v1)
Diffstat (limited to 'src/compiler/glsl/ast_to_hir.cpp')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index db48cf81134..8424b5bb3f2 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -3629,11 +3629,7 @@ apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual,
/* Layout qualifiers for gl_FragDepth, which are enabled by extension
* AMD_conservative_depth.
*/
- int depth_layout_count = qual->flags.q.depth_any
- + qual->flags.q.depth_greater
- + qual->flags.q.depth_less
- + qual->flags.q.depth_unchanged;
- if (depth_layout_count > 0
+ if (qual->flags.q.depth_type
&& !state->is_version(420, 0)
&& !state->AMD_conservative_depth_enable
&& !state->ARB_conservative_depth_enable) {
@@ -3641,27 +3637,30 @@ apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual,
"extension GL_AMD_conservative_depth or "
"GL_ARB_conservative_depth must be enabled "
"to use depth layout qualifiers");
- } else if (depth_layout_count > 0
+ } else if (qual->flags.q.depth_type
&& strcmp(var->name, "gl_FragDepth") != 0) {
_mesa_glsl_error(loc, state,
"depth layout qualifiers can be applied only to "
"gl_FragDepth");
- } else if (depth_layout_count > 1
- && strcmp(var->name, "gl_FragDepth") == 0) {
- _mesa_glsl_error(loc, state,
- "at most one depth layout qualifier can be applied to "
- "gl_FragDepth");
}
- if (qual->flags.q.depth_any)
+
+ switch (qual->depth_type) {
+ case ast_depth_any:
var->data.depth_layout = ir_depth_layout_any;
- else if (qual->flags.q.depth_greater)
+ break;
+ case ast_depth_greater:
var->data.depth_layout = ir_depth_layout_greater;
- else if (qual->flags.q.depth_less)
+ break;
+ case ast_depth_less:
var->data.depth_layout = ir_depth_layout_less;
- else if (qual->flags.q.depth_unchanged)
- var->data.depth_layout = ir_depth_layout_unchanged;
- else
- var->data.depth_layout = ir_depth_layout_none;
+ break;
+ case ast_depth_unchanged:
+ var->data.depth_layout = ir_depth_layout_unchanged;
+ break;
+ default:
+ var->data.depth_layout = ir_depth_layout_none;
+ break;
+ }
if (qual->flags.q.std140 ||
qual->flags.q.std430 ||