Mesa (master): glsl/es3.1: Allow interger mix built-ins in GLSL ES 3.10

Ian Romanick idr at kemper.freedesktop.org
Mon May 4 21:26:43 UTC 2015


Module: Mesa
Branch: master
Commit: ad14f44b3e89cf4d05d29f2aaf9f64fe0e42af3b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ad14f44b3e89cf4d05d29f2aaf9f64fe0e42af3b

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Apr 28 12:50:51 2015 -0700

glsl/es3.1: Allow interger mix built-ins in GLSL ES 3.10

v2: Add missing lexer support.  Noticed by Tapani.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu> [v1]

---

 src/glsl/builtin_functions.cpp  |    3 ++-
 src/glsl/builtin_variables.cpp  |   35 +++++++++++++++++++++++++++++++----
 src/glsl/glsl_lexer.ll          |    2 +-
 src/glsl/glsl_parser_extras.cpp |   10 ++++++++++
 src/glsl/glsl_parser_extras.h   |   12 +++++++++++-
 5 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 5ce8112..435d926 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -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
diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 9d0b272..6806aa1 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -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) {
diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 2785ed1..10db5b8 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -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;
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 9e2f19f..c14481d 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -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++)
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 00fcc75..4612071 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -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];




More information about the mesa-commit mailing list