]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix a test case and add a couple more
authorMikko Rasa <tdb@tdb.fi>
Thu, 11 Mar 2021 22:24:40 +0000 (00:24 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 11 Mar 2021 22:25:39 +0000 (00:25 +0200)
tests/glsl/chained_member_access.glsl [new file with mode: 0644]
tests/glsl/expression_inline_iteration.glsl
tests/glsl/function_overloading.glsl [new file with mode: 0644]

diff --git a/tests/glsl/chained_member_access.glsl b/tests/glsl/chained_member_access.glsl
new file mode 100644 (file)
index 0000000..c34cf7d
--- /dev/null
@@ -0,0 +1,41 @@
+struct TransformComponents
+{
+       vec3 position;
+       vec3 scale;
+};
+struct Transform
+{
+       TransformComponents components;
+};
+uniform ModelData
+{
+       Transform transform;
+} model;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void main()
+{
+       gl_Position = vec4(model.transform.components.position+position.xyz*model.transform.components.scale, 1.0);
+}
+
+/* Expected output: vertex
+struct TransformComponents
+{
+       vec3 position;
+       vec3 scale;
+};
+struct Transform
+{
+       TransformComponents components;
+};
+uniform ModelData
+{
+       Transform transform;
+} model;
+layout(location=0) in vec4 position;
+void main()
+{
+       gl_Position = vec4(model.transform.components.position+position.xyz*model.transform.components.scale, 1.0);
+}
+*/
index 3ad81bc8cdededa4605b531ec203c2115eb5f2d5..4a125099ddc78eeb0389f6897795285d54259e7a 100644 (file)
@@ -9,7 +9,7 @@ void main()
        {
                float scale = 2.0;
                p += direction*scale;
-               if(p.z<0)
+               if(p.z<0.0)
                        break;
                step = i;
        }
@@ -26,7 +26,7 @@ void main()
        for(int i=0; i<10; ++i)
        {
                p += direction*2.0;
-               if(p.z<0)
+               if(p.z<0.0)
                        break;
                step = i;
        }
diff --git a/tests/glsl/function_overloading.glsl b/tests/glsl/function_overloading.glsl
new file mode 100644 (file)
index 0000000..636db51
--- /dev/null
@@ -0,0 +1,60 @@
+uniform mat4 mvp;
+uniform sampler2D tex;
+uniform vec3 ambient;
+
+vec3 srgb_to_linear(vec3 color)
+{
+       bvec3 near_zero = lessThan(color, vec3(0.04045));
+       vec3 gamma = pow((color.rgb+0.055)/1.055, vec3(2.4));
+       return mix(color.rgb/12.92, gamma, near_zero);
+}
+vec4 srgb_to_linear(vec4 color)
+{
+       return vec4(srgb_to_linear(color.rgb), color.a);
+}
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+layout(location=1) in vec2 texcoord;
+void main()
+{
+       passthrough;
+       gl_Position = mvp*position;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = srgb_to_linear(texture(tex, texcoord));
+}
+
+/* Expected output: vertex
+uniform mat4 mvp;
+layout(location=0) in vec4 position;
+layout(location=1) in vec2 texcoord;
+out vec2 _vs_out_texcoord;
+void main()
+{
+  _vs_out_texcoord = texcoord;
+  gl_Position = mvp*position;
+}
+*/
+
+/* Expected output: fragment
+uniform sampler2D tex;
+vec3 srgb_to_linear(vec3 color)
+{
+  return mix(color.rgb/12.92, pow((color.rgb+0.055)/1.055, vec3(2.4)), lessThan(color, vec3(0.04045)));
+}
+vec4 srgb_to_linear(vec4 color)
+{
+  return vec4(srgb_to_linear(color.rgb), color.a);
+}
+layout(location=0) out vec4 frag_color;
+in vec2 _vs_out_texcoord;
+void main()
+{
+  frag_color = srgb_to_linear(texture(tex, _vs_out_texcoord));
+}
+*/