Blame SOURCES/0001-glsl-Allow-compatibility-shaders-with-MESA_GL_VERSIO.patch

f06792
From d7a0486a9e4e71d98c694872815909b8f8c0d3ac Mon Sep 17 00:00:00 2001
f06792
From: Matt Turner <mattst88@gmail.com>
f06792
Date: Tue, 31 Jan 2017 15:41:52 -0800
f06792
Subject: [PATCH] glsl: Allow compatibility shaders with
f06792
 MESA_GL_VERSION_OVERRIDE=...
f06792
f06792
Previously if you used MESA_GL_VERSION_OVERRIDE=3.3COMPAT, Mesa exposed
f06792
an OpenGL 3.3 compatibility profile context (with various unimplemented
f06792
features and bugs), but still refused to compile shaders with
f06792
f06792
   #version 330 compatibility
f06792
f06792
This patch simply adds a small bit of plumbing to let that through.
f06792
f06792
Of course the same caveats apply: compatibility profile is still not
f06792
supported (and will not be supported), so there are no guarantees that
f06792
anything will work.
f06792
f06792
Tested-by: Dylan Baker <dylan@pnwbakers.com>
f06792
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
f06792
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
f06792
---
f06792
 src/compiler/glsl/builtin_types.cpp      |  2 +-
f06792
 src/compiler/glsl/builtin_variables.cpp  |  2 +-
f06792
 src/compiler/glsl/glsl_parser_extras.cpp | 13 +++++++++++--
f06792
 src/compiler/glsl/glsl_parser_extras.h   |  1 +
f06792
 4 files changed, 14 insertions(+), 4 deletions(-)
f06792
f06792
diff --git a/src/compiler/glsl/builtin_types.cpp b/src/compiler/glsl/builtin_types.cpp
f06792
index a63d736..cae972b 100644
f06792
--- a/src/compiler/glsl/builtin_types.cpp
f06792
+++ b/src/compiler/glsl/builtin_types.cpp
f06792
@@ -288,7 +288,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
f06792
    /* Add deprecated structure types.  While these were deprecated in 1.30,
f06792
     * they're still present.  We've removed them in 1.40+ (OpenGL 3.1+).
f06792
     */
f06792
-   if (!state->es_shader && state->language_version < 140) {
f06792
+   if (state->compat_shader) {
f06792
       for (unsigned i = 0; i < ARRAY_SIZE(deprecated_types); i++) {
f06792
          add_type(symbols, deprecated_types[i]);
f06792
       }
f06792
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
f06792
index 4eb275e..be593e9 100644
f06792
--- a/src/compiler/glsl/builtin_variables.cpp
f06792
+++ b/src/compiler/glsl/builtin_variables.cpp
f06792
@@ -444,7 +444,7 @@ private:
f06792
 builtin_variable_generator::builtin_variable_generator(
f06792
    exec_list *instructions, struct _mesa_glsl_parse_state *state)
f06792
    : instructions(instructions), state(state), symtab(state->symbols),
f06792
-     compatibility(!state->is_version(140, 100)),
f06792
+     compatibility(state->compat_shader || !state->is_version(140, 100)),
f06792
      bool_t(glsl_type::bool_type), int_t(glsl_type::int_type),
f06792
      uint_t(glsl_type::uint_type),
f06792
      float_t(glsl_type::float_type), vec2_t(glsl_type::vec2_type),
f06792
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
f06792
index 6fe1dd9..c4da79a 100644
f06792
--- a/src/compiler/glsl/glsl_parser_extras.cpp
f06792
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
f06792
@@ -83,6 +83,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
f06792
    this->forced_language_version = ctx->Const.ForceGLSLVersion;
f06792
    this->zero_init = ctx->Const.GLSLZeroInit;
f06792
    this->gl_version = 20;
f06792
+   this->compat_shader = true;
f06792
    this->es_shader = false;
f06792
    this->ARB_texture_rectangle_enable = true;
f06792
 
f06792
@@ -370,6 +371,7 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
f06792
                                                   const char *ident)
f06792
 {
f06792
    bool es_token_present = false;
f06792
+   bool compat_token_present = false;
f06792
    if (ident) {
f06792
       if (strcmp(ident, "es") == 0) {
f06792
          es_token_present = true;
f06792
@@ -379,8 +381,12 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
f06792
              * a core profile shader since that's the only profile we support.
f06792
              */
f06792
          } else if (strcmp(ident, "compatibility") == 0) {
f06792
-            _mesa_glsl_error(locp, this,
f06792
-                             "the compatibility profile is not supported");
f06792
+            compat_token_present = true;
f06792
+
f06792
+            if (this->ctx->API != API_OPENGL_COMPAT) {
f06792
+               _mesa_glsl_error(locp, this,
f06792
+                                "the compatibility profile is not supported");
f06792
+            }
f06792
          } else {
f06792
             _mesa_glsl_error(locp, this,
f06792
                              "\"%s\" is not a valid shading language profile; "
f06792
@@ -412,6 +418,9 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
f06792
    else
f06792
       this->language_version = version;
f06792
 
f06792
+   this->compat_shader = compat_token_present ||
f06792
+                         (!this->es_shader && this->language_version < 140);
f06792
+
f06792
    bool supported = false;
f06792
    for (unsigned i = 0; i < this->num_supported_versions; i++) {
f06792
       if (this->supported_versions[i].ver == this->language_version
f06792
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
f06792
index 424cab5..66a954f 100644
f06792
--- a/src/compiler/glsl/glsl_parser_extras.h
f06792
+++ b/src/compiler/glsl/glsl_parser_extras.h
f06792
@@ -348,6 +348,7 @@ struct _mesa_glsl_parse_state {
f06792
    } supported_versions[16];
f06792
 
f06792
    bool es_shader;
f06792
+   bool compat_shader;
f06792
    unsigned language_version;
f06792
    unsigned forced_language_version;
f06792
    bool zero_init;
f06792
-- 
f06792
2.9.3
f06792