glsl: allow "varying out" for fragment shader outputs with EXT_gpu_shader4
authorMarek Olšák <marek.olsak@amd.com>
Fri, 5 Apr 2019 21:01:55 +0000 (17:01 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 25 Apr 2019 00:45:15 +0000 (20:45 -0400)
Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/ast_type.cpp
src/compiler/glsl/glsl_parser.yy

index 79e14cc6c9b86bf7d60faeac874c066a8c0c9c25..a3a24810012abf704ef2499acd3dd742d4412397 100644 (file)
@@ -5132,7 +5132,12 @@ ast_declarator_list::hir(exec_list *instructions,
           && !state->has_explicit_attrib_location()
           && !state->has_separate_shader_objects()
           && !state->ARB_fragment_coord_conventions_enable) {
-         if (this->type->qualifier.flags.q.out) {
+         /* GL_EXT_gpu_shader4 only allows "varying out" on fragment shader
+          * outputs. (the varying flag is not set by the parser)
+          */
+         if (this->type->qualifier.flags.q.out &&
+             (!state->EXT_gpu_shader4_enable ||
+              state->stage != MESA_SHADER_FRAGMENT)) {
             _mesa_glsl_error(& loc, state,
                              "`out' qualifier in declaration of `%s' "
                              "only valid for function parameters in %s",
index b499ee913e7d914caba4c9efffd7becd5e945d67..c7f74e7aa08f3941e6b194741179e38c50aaad36 100644 (file)
@@ -489,6 +489,13 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
        q.flags.q.bound_image)
       merge_bindless_qualifier(state);
 
+   if (state->EXT_gpu_shader4_enable &&
+       state->stage == MESA_SHADER_FRAGMENT &&
+       this->flags.q.varying && q.flags.q.out) {
+      this->flags.q.varying = 0;
+      this->flags.q.out = 1;
+   }
+
    return r;
 }
 
index 80634144084e63f5907848578e0ca713c5d00b3b..6426f890b9e622e6da0b5f486b8c6e75a7c43793 100644 (file)
@@ -2086,8 +2086,13 @@ type_qualifier:
       /* Section 4.3 of the GLSL 1.20 specification states:
        * "Variable declarations may have a storage qualifier specified..."
        *  1.30 clarifies this to "may have one storage qualifier".
+       *
+       * GL_EXT_gpu_shader4 allows "varying out" in fragment shaders.
        */
-      if ($2.has_storage())
+      if ($2.has_storage() &&
+          (!state->EXT_gpu_shader4_enable ||
+           state->stage != MESA_SHADER_FRAGMENT ||
+           !$1.flags.q.varying || !$2.flags.q.out))
          _mesa_glsl_error(&@1, state, "duplicate storage qualifier");
 
       if (!state->has_420pack_or_es31() &&