glsl/es3.1: Allow interger mix built-ins in GLSL ES 3.10
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 28 Apr 2015 19:50:51 +0000 (12:50 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 4 May 2015 20:49:58 +0000 (13:49 -0700)
v2: Add missing lexer support.  Noticed by Tapani.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> [v1]
src/glsl/builtin_functions.cpp
src/glsl/builtin_variables.cpp
src/glsl/glsl_lexer.ll
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h

index 5ce811289d12a1bd6c8666411453f4c8f0137605..435d926c660b8aa97d6e475c5119cebbffa8bddf 100644 (file)
@@ -194,7 +194,8 @@ shader_bit_encoding(const _mesa_glsl_parse_state *state)
 static bool
 shader_integer_mix(const _mesa_glsl_parse_state *state)
 {
-   return v130(state) && state->EXT_shader_integer_mix_enable;
+   return state->is_version(450, 310) ||
+          v130(state) && state->EXT_shader_integer_mix_enable;
 }
 
 static bool
index 9d0b27209e77c7c33d73cb65b760ee518c4283e7..6806aa1f962f51f6411f8814f7d544498fbe12a5 100644 (file)
@@ -656,16 +656,43 @@ builtin_variable_generator::generate_constants()
    if (state->has_atomic_counters()) {
       add_const("gl_MaxVertexAtomicCounters",
                 state->Const.MaxVertexAtomicCounters);
-      add_const("gl_MaxGeometryAtomicCounters",
-                state->Const.MaxGeometryAtomicCounters);
       add_const("gl_MaxFragmentAtomicCounters",
                 state->Const.MaxFragmentAtomicCounters);
       add_const("gl_MaxCombinedAtomicCounters",
                 state->Const.MaxCombinedAtomicCounters);
       add_const("gl_MaxAtomicCounterBindings",
                 state->Const.MaxAtomicBufferBindings);
-      add_const("gl_MaxTessControlAtomicCounters", 0);
-      add_const("gl_MaxTessEvaluationAtomicCounters", 0);
+
+      /* When Mesa adds support for GL_OES_geometry_shader and
+       * GL_OES_tessellation_shader, this will need to change.
+       */
+      if (!state->es_shader) {
+         add_const("gl_MaxGeometryAtomicCounters",
+                   state->Const.MaxGeometryAtomicCounters);
+         add_const("gl_MaxTessControlAtomicCounters", 0);
+         add_const("gl_MaxTessEvaluationAtomicCounters", 0);
+      }
+   }
+
+   if (state->is_version(420, 310)) {
+      add_const("gl_MaxVertexAtomicCounterBuffers",
+                state->Const.MaxVertexAtomicCounterBuffers);
+      add_const("gl_MaxFragmentAtomicCounterBuffers",
+                state->Const.MaxFragmentAtomicCounterBuffers);
+      add_const("gl_MaxCombinedAtomicCounterBuffers",
+                state->Const.MaxCombinedAtomicCounterBuffers);
+      add_const("gl_MaxAtomicCounterBufferSize",
+                state->Const.MaxAtomicCounterBufferSize);
+
+      /* When Mesa adds support for GL_OES_geometry_shader and
+       * GL_OES_tessellation_shader, this will need to change.
+       */
+      if (!state->es_shader) {
+         add_const("gl_MaxGeometryAtomicCounterBuffers",
+                   state->Const.MaxGeometryAtomicCounterBuffers);
+         add_const("gl_MaxTessControlAtomicCounterBuffers", 0);
+         add_const("gl_MaxTessEvaluationAtomicCounterBuffers", 0);
+      }
    }
 
    if (state->is_version(430, 0) || state->ARB_compute_shader_enable) {
index 2785ed16884dd457f4048054bcf7654ae34e6991..10db5b8b632e4fe8d97fea5993ed3724252c25df 100644 (file)
@@ -409,7 +409,7 @@ restrict    KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store
 readonly       KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, READONLY);
 writeonly      KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, WRITEONLY);
 
-atomic_uint     KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
+atomic_uint     KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
 
 struct         return STRUCT;
 void           return VOID_TOK;
index 9e2f19f6388088b3f1d60412962b247bbf8b19ad..c14481df1743482a3626620e750237e73a088e25 100644 (file)
@@ -117,6 +117,16 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
    this->Const.MaxFragmentAtomicCounters = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters;
    this->Const.MaxCombinedAtomicCounters = ctx->Const.MaxCombinedAtomicCounters;
    this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings;
+   this->Const.MaxVertexAtomicCounterBuffers =
+      ctx->Const.Program[MESA_SHADER_VERTEX].MaxAtomicBuffers;
+   this->Const.MaxGeometryAtomicCounterBuffers =
+      ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers;
+   this->Const.MaxFragmentAtomicCounterBuffers =
+      ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
+   this->Const.MaxCombinedAtomicCounterBuffers =
+      ctx->Const.MaxCombinedAtomicBuffers;
+   this->Const.MaxAtomicCounterBufferSize =
+      ctx->Const.MaxAtomicBufferSize;
 
    /* Compute shader constants */
    for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupCount); i++)
index 00fcc75ca06452ee9bc85cccda6a59207c4c75d0..4612071426b62e805d0edf3a07f6436623b6eb4b 100644 (file)
@@ -192,7 +192,7 @@ struct _mesa_glsl_parse_state {
 
    bool has_atomic_counters() const
    {
-      return ARB_shader_atomic_counters_enable || is_version(420, 0);
+      return ARB_shader_atomic_counters_enable || is_version(420, 310);
    }
 
    bool has_explicit_attrib_stream() const
@@ -353,6 +353,16 @@ struct _mesa_glsl_parse_state {
       unsigned MaxCombinedAtomicCounters;
       unsigned MaxAtomicBufferBindings;
 
+      /* These are also atomic counter related, but they weren't added to
+       * until atomic counters were added to core in GLSL 4.20 and GLSL ES
+       * 3.10.
+       */
+      unsigned MaxVertexAtomicCounterBuffers;
+      unsigned MaxGeometryAtomicCounterBuffers;
+      unsigned MaxFragmentAtomicCounterBuffers;
+      unsigned MaxCombinedAtomicCounterBuffers;
+      unsigned MaxAtomicCounterBufferSize;
+
       /* ARB_compute_shader */
       unsigned MaxComputeWorkGroupCount[3];
       unsigned MaxComputeWorkGroupSize[3];