glsl: Add a has_tessellation_shader() helper.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 20 May 2016 22:17:37 +0000 (15:17 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 8 Aug 2016 06:47:55 +0000 (23:47 -0700)
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 <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
src/compiler/glsl/builtin_variables.cpp
src/compiler/glsl/glsl_parser.yy
src/compiler/glsl/glsl_parser_extras.h

index f63dc3a0b168ff0751eda82a3d778c3c65f6bcf2..20d1d75f596cc35eecf2404de694ed3ae33ffcdc 100644 (file)
@@ -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);
index 3885688d9b8e5a07ddd73cde432c363710611c50..61c4723eac8e3c42aeeb0d97010e0a4a0cf5a322 100644 (file)
@@ -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");
index cca7fa8e0ee8ced8d8df22d2ba1784606a906aa2..f9c1ffca842387938c2b09b58f75a5b550ddeb69 100644 (file)
@@ -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);