1 #include "ANGLETest.h"
2
3 class GLSLStructTest : public ANGLETest
4 {
5 protected:
GLSLStructTest()6 GLSLStructTest()
7 {
8 setWindowWidth(128);
9 setWindowHeight(128);
10 setConfigRedBits(8);
11 setConfigGreenBits(8);
12 setConfigBlueBits(8);
13 setConfigAlphaBits(8);
14 }
15
SetUp()16 virtual void SetUp()
17 {
18 ANGLETest::SetUp();
19
20 mVertexShaderSource = SHADER_SOURCE
21 (
22 attribute vec4 inputAttribute;
23 void main()
24 {
25 gl_Position = inputAttribute;
26 }
27 );
28 }
29
30 std::string mVertexShaderSource;
31 };
32
TEST_F(GLSLStructTest,nameless_scoped_structs)33 TEST_F(GLSLStructTest, nameless_scoped_structs)
34 {
35 const std::string fragmentShaderSource = SHADER_SOURCE
36 (
37 precision mediump float;
38
39 void main()
40 {
41 struct
42 {
43 float q;
44 } b;
45
46 gl_FragColor = vec4(1, 0, 0, 1);
47 gl_FragColor.a += b.q;
48 }
49 );
50
51 GLuint program = compileProgram(mVertexShaderSource, fragmentShaderSource);
52 EXPECT_NE(0u, program);
53 }
TEST_F(GLSLStructTest,scoped_structs_order_bug)54 TEST_F(GLSLStructTest, scoped_structs_order_bug)
55 {
56 const std::string fragmentShaderSource = SHADER_SOURCE
57 (
58 precision mediump float;
59
60 struct T
61 {
62 float f;
63 };
64
65 void main()
66 {
67 T a;
68
69 struct T
70 {
71 float q;
72 };
73
74 T b;
75
76 gl_FragColor = vec4(1, 0, 0, 1);
77 gl_FragColor.a += a.f;
78 gl_FragColor.a += b.q;
79 }
80 );
81
82 GLuint program = compileProgram(mVertexShaderSource, fragmentShaderSource);
83 EXPECT_NE(0u, program);
84 }
85
TEST_F(GLSLStructTest,scoped_structs_bug)86 TEST_F(GLSLStructTest, scoped_structs_bug)
87 {
88 const std::string fragmentShaderSource = SHADER_SOURCE
89 (
90 precision mediump float;
91
92 struct T_0
93 {
94 float f;
95 };
96
97 void main()
98 {
99 gl_FragColor = vec4(1, 0, 0, 1);
100
101 struct T
102 {
103 vec2 v;
104 };
105
106 T_0 a;
107 T b;
108
109 gl_FragColor.a += a.f;
110 gl_FragColor.a += b.v.x;
111 }
112 );
113
114 GLuint program = compileProgram(mVertexShaderSource, fragmentShaderSource);
115 EXPECT_NE(0u, program);
116 }
117