Fixes shader parser bug for Vulkan-GLSL 98/316198/9
authorAdam Bialogonski <adam.b@samsung.com>
Fri, 16 Aug 2024 08:57:56 +0000 (09:57 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Fri, 23 Aug 2024 13:11:40 +0000 (14:11 +0100)
Fragment shader output location set to 0 (single output)
Sampler and UBO bindings unified as one counter

Change-Id: I0fc8daf7e02ab5e6b8caffa5dd26ed1520a3e99d

automated-tests/resources/shaders/canvas-view-with-output.frag.glsl-spirv
automated-tests/resources/shaders/canvas-view.frag.glsl-spirv
dali/internal/graphics/common/shader-parser.cpp
dali/internal/graphics/common/shader-parser.h

index f0230d8..ce4ee19 100644 (file)
@@ -8,9 +8,9 @@ layout(set=0, binding=1, std140) uniform FragBlock
 };
 
 layout(location = 0) in mediump vec2 vTexCoord;
-layout(binding = 0) uniform sampler2D sTexture;
+layout(binding = 2) uniform sampler2D sTexture;
 
-out mediump vec4 fragColor;
+layout(location=0) out mediump vec4 fragColor;
 
 void main()
 {
index fd67394..f83c3cb 100644 (file)
@@ -8,10 +8,10 @@ layout(set=0, binding=1, std140) uniform FragBlock
 };
 
 layout(location = 0) in mediump vec2 vTexCoord;
-layout(binding = 0) uniform sampler2D sTexture;
+layout(binding = 2) uniform sampler2D sTexture;
 
 #define gl_FragColor _glFragColor
-out mediump vec4 _glFragColor;
+layout(location=0) out mediump vec4 _glFragColor;
 void main()
 {
   gl_FragColor = TEXTURE(sTexture, vTexCoord) * uColor;
index 9337ec9..1083289 100644 (file)
@@ -220,9 +220,9 @@ bool ProcessTokenOUTPUT(IT& it, Program& program, OutputLanguage lang, ShaderSta
         else
         {
           // for fragment shader the gl_FragColor is our output
-          // we will use OUT_COLOR
+          // we will use OUT_COLOR, in such shader we have only single output
           auto varName = GetToken(l, -1);
-          ss << "out" << l.line.substr(l.tokens[0].first + l.tokens[0].second).c_str() << "\n";
+          ss << "layout(location=0) out" << l.line.substr(l.tokens[0].first + l.tokens[0].second).c_str() << "\n";
           outString += ss.str();
         }
         return true;
index 1addfe0..058dcdc 100644 (file)
@@ -70,7 +70,7 @@ struct Program
   Shader                     fragmentShader;
   std::map<std::string, int> varyings;
   int                        uboBinding{0};
-  int                        samplerBinding{0};
+  int&                       samplerBinding{uboBinding}; // sampler bindings and ubo bindings are the same
 };
 
 struct ShaderParserInfo