[Mesa-dev] [PATCH 08/23] glsl/parser: Handle the early_fragment_tests input layout qualifier.
Francisco Jerez
currojerez at riseup.net
Tue Nov 26 00:02:24 PST 2013
---
src/glsl/glsl_parser.yy | 61 ++++++++++++++++++++++++++---------------
src/glsl/glsl_parser_extras.cpp | 1 +
src/glsl/glsl_parser_extras.h | 2 ++
3 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 44c332d..e436b16 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1295,6 +1295,15 @@ layout_qualifier_id:
}
}
+ /* Layout qualifiers for ARB_shader_image_load_store. */
+ if (state->ARB_shader_image_load_store_enable ||
+ state->is_version(420, 0)) {
+ if (!$$.flags.i &&
+ match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
+ $$.flags.q.early_fragment_tests = 1;
+ }
+ }
+
if (!$$.flags.i) {
_mesa_glsl_error(& @1, state, "unrecognized layout identifier "
"`%s'", $1);
@@ -2373,31 +2382,39 @@ layout_defaults:
| layout_qualifier IN_TOK ';'
{
void *ctx = state;
+ ast_type_qualifier qualifier = $1;
+
$$ = NULL;
- if (state->target != geometry_shader) {
- _mesa_glsl_error(& @1, state,
- "input layout qualifiers only valid in "
- "geometry shaders");
- } else if (!$1.flags.q.prim_type) {
- _mesa_glsl_error(& @1, state,
- "input layout qualifiers must specify a primitive"
- " type");
- } else {
- /* Make sure this is a valid input primitive type. */
- switch ($1.prim_type) {
- case GL_POINTS:
- case GL_LINES:
- case GL_LINES_ADJACENCY:
- case GL_TRIANGLES:
- case GL_TRIANGLES_ADJACENCY:
- $$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type);
- break;
- default:
- _mesa_glsl_error(&@1, state,
- "invalid geometry shader input primitive type");
- break;
+
+ if (state->target == geometry_shader) {
+ if (qualifier.flags.q.prim_type) {
+ /* Make sure this is a valid input primitive type. */
+ switch (qualifier.prim_type) {
+ case GL_POINTS:
+ case GL_LINES:
+ case GL_LINES_ADJACENCY:
+ case GL_TRIANGLES:
+ case GL_TRIANGLES_ADJACENCY:
+ $$ = new(ctx) ast_gs_input_layout(@1, qualifier.prim_type);
+ break;
+ default:
+ _mesa_glsl_error(&@1, state,
+ "invalid geometry shader input primitive type");
+ break;
+ }
+
+ qualifier.flags.q.prim_type = 0;
}
}
+
+ if (qualifier.flags.q.early_fragment_tests) {
+ state->early_fragment_tests = true;
+ qualifier.flags.q.early_fragment_tests = 0;
+ }
+
+ if (qualifier.flags.i) {
+ _mesa_glsl_error(&@1, state, "invalid input layout qualifier");
+ }
}
| layout_qualifier OUT_TOK ';'
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 3719f5c..1c82a1d 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -191,6 +191,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->gs_input_prim_type = GL_POINTS;
this->gs_input_size = 0;
this->out_qualifier = new(this) ast_type_qualifier();
+ this->early_fragment_tests = false;
}
/**
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index d7cff89..ba02166 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -376,6 +376,8 @@ struct _mesa_glsl_parse_state {
*/
unsigned gs_input_size;
+ bool early_fragment_tests;
+
/** Atomic counter offsets by binding */
unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
};
--
1.8.3.4
More information about the mesa-dev
mailing list