Mesa (master): glsl: redeclare built-in variable with separate shader

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 13:32:01 UTC 2021


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

Author: cheyang <cheyang at bytedance.com>
Date:   Tue Dec 15 16:18:13 2020 +0800

glsl: redeclare built-in variable with separate shader

according to :
https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_separate_shader_objects.gles.txt
properly handle the declaration of these interface block varibales

Signed-off-by: cheyang <cheyang at bytedance.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8101>

---

 src/compiler/glsl/ast_to_hir.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 6c0c3b6f365..6d85dd4374f 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4409,6 +4409,27 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,
               earlier->data.how_declared == ir_var_declared_implicitly) {
       /* No need to do anything, just allow it. Qualifier is stored in state */
 
+   } else if (state->is_version(0, 300) &&
+              state->has_separate_shader_objects() &&
+              (strcmp(var->name, "gl_Position") == 0 ||
+              strcmp(var->name, "gl_PointSize") == 0)) {
+
+       /*  EXT_separate_shader_objects spec says:
+       *
+       *  "The following vertex shader outputs may be redeclared
+       *   at global scope to specify a built-in output interface,
+       *   with or without special qualifiers:
+       *
+       *    gl_Position
+       *    gl_PointSize
+       *
+       *    When compiling shaders using either of the above variables,
+       *    both such variables must be redeclared prior to use."
+       */
+      if (earlier->data.used) {
+         _mesa_glsl_error(&loc, state, "the first redeclaration of "
+                         "%s must appear before any use", var->name);
+      }
    } else if ((earlier->data.how_declared == ir_var_declared_implicitly &&
                state->allow_builtin_variable_redeclaration) ||
               allow_all_redeclarations) {



More information about the mesa-commit mailing list