From d0642c52fce91936443ea64ebbc2719813b95aae Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 20 May 2016 15:17:37 -0700 Subject: [PATCH] glsl: Add a has_tessellation_shader() helper. Similar to has_geometry_shader(), has_compute_shader(), and so on. This will make it easier to add more conditions here later. Signed-off-by: Kenneth Graunke Reviewed-by: Timothy Arceri --- src/compiler/glsl/builtin_variables.cpp | 6 ++---- src/compiler/glsl/glsl_parser.yy | 19 +++++-------------- src/compiler/glsl/glsl_parser_extras.h | 5 +++++ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp index f63dc3a..20d1d75 100644 --- a/src/compiler/glsl/builtin_variables.cpp +++ b/src/compiler/glsl/builtin_variables.cpp @@ -861,8 +861,7 @@ builtin_variable_generator::generate_constants() state->Const.MaxImageSamples); } - if (state->is_version(400, 0) || - state->ARB_tessellation_shader_enable) { + if (state->has_tessellation_shader()) { add_const("gl_MaxTessControlImageUniforms", state->Const.MaxTessControlImageUniforms); add_const("gl_MaxTessEvaluationImageUniforms", @@ -880,8 +879,7 @@ builtin_variable_generator::generate_constants() state->ARB_viewport_array_enable) add_const("gl_MaxViewports", state->Const.MaxViewports); - if (state->is_version(400, 0) || - state->ARB_tessellation_shader_enable) { + if (state->has_tessellation_shader()) { add_const("gl_MaxPatchVertices", state->Const.MaxPatchVertices); add_const("gl_MaxTessGenLevel", state->Const.MaxTessGenLevel); add_const("gl_MaxTessControlInputComponents", state->Const.MaxTessControlInputComponents); diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy index 3885688..61c4723 100644 --- a/src/compiler/glsl/glsl_parser.yy +++ b/src/compiler/glsl/glsl_parser.yy @@ -1390,9 +1390,7 @@ layout_qualifier_id: } } - if ($$.flags.i && - !state->ARB_tessellation_shader_enable && - !state->is_version(400, 0)) { + if ($$.flags.i && !state->has_tessellation_shader()) { _mesa_glsl_error(& @1, state, "primitive mode qualifier `%s' requires " "GLSL 4.00 or ARB_tessellation_shader", $1); @@ -1415,9 +1413,7 @@ layout_qualifier_id: } } - if ($$.flags.i && - !state->ARB_tessellation_shader_enable && - !state->is_version(400, 0)) { + if ($$.flags.i && !state->has_tessellation_shader()) { _mesa_glsl_error(& @1, state, "vertex spacing qualifier `%s' requires " "GLSL 4.00 or ARB_tessellation_shader", $1); @@ -1432,9 +1428,7 @@ layout_qualifier_id: $$.ordering = GL_CCW; } - if ($$.flags.i && - !state->ARB_tessellation_shader_enable && - !state->is_version(400, 0)) { + if ($$.flags.i && !state->has_tessellation_shader()) { _mesa_glsl_error(& @1, state, "ordering qualifier `%s' requires " "GLSL 4.00 or ARB_tessellation_shader", $1); @@ -1446,9 +1440,7 @@ layout_qualifier_id: $$.point_mode = true; } - if ($$.flags.i && - !state->ARB_tessellation_shader_enable && - !state->is_version(400, 0)) { + if ($$.flags.i && !state->has_tessellation_shader()) { _mesa_glsl_error(& @1, state, "qualifier `point_mode' requires " "GLSL 4.00 or ARB_tessellation_shader"); @@ -1608,8 +1600,7 @@ layout_qualifier_id: if (match_layout_qualifier("vertices", $1, state) == 0) { $$.flags.q.vertices = 1; $$.vertices = new(ctx) ast_layout_expression(@1, $3); - if (!state->ARB_tessellation_shader_enable && - !state->is_version(400, 0)) { + if (!state->has_tessellation_shader()) { _mesa_glsl_error(& @1, state, "vertices qualifier requires GLSL 4.00 or " "ARB_tessellation_shader"); diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h index cca7fa8..f9c1ffc 100644 --- a/src/compiler/glsl/glsl_parser_extras.h +++ b/src/compiler/glsl/glsl_parser_extras.h @@ -277,6 +277,11 @@ struct _mesa_glsl_parse_state { return OES_geometry_shader_enable || is_version(150, 320); } + bool has_tessellation_shader() const + { + return ARB_tessellation_shader_enable || is_version(400, 0); + } + bool has_clip_distance() const { return EXT_clip_cull_distance_enable || is_version(130, 0); -- 2.7.4