Add more structure constructor tests.
[piglit/hramrach.git] / tests / glslparsertest / shaders / CorrectFull.vert
blob0b754b2fc73003f7b3dd4786db9b0ac8bbf17b54
1 void test_function(const in int in_int, inout int out_int);\r
2 int test_function1(in int in_int, inout int out_int);\r
3 \r
4 int test_function1(in int in_int1, inout int , out int);\r
5 int test_function1(in int in_int1, inout int , out int); \r
6 \r
7 uniform float array_float[2]; \r
8 \r
9 struct light1 \r
10 {\r
11    float intensity;\r
12    vec3 position;\r
13    int test_int[2];\r
14    struct nested\r
15    {\r
16       int a;\r
17       float f; \r
18    } light2;\r
19 } lightVar;\r
20 light1 ll2;\r
22 varying struct light3 {\r
23     float i;\r
24 } ;\r
26 attribute struct light4 {\r
27     float i;\r
28 };\r
30 struct light5 {\r
31     float i ;\r
32     float a[2];\r
33 } light5_inst;\r
35 uniform light3 uniformLight3;\r
37 uniform struct light6 {  \r
38     float i;\r
39 };\r
40 uniform light6 uniformLight6; \r
43 struct light7 {\r
44     struct {\r
45         struct {\r
46             struct {\r
47                 float f;\r
48             } light10;\r
49         } light9;\r
50      } light8;\r
51 } ;\r
54 light3 struct_var = light3(5.0); \r
56 // Attribtue variables can only be Global\r
57 attribute float flt_attrib;\r
58 attribute vec2 vec2_attrib;\r
59 attribute vec3 vec3_attrib;\r
60 attribute vec4 vec4_attrib; \r
61 attribute mat2 mat2_attrib; \r
62 attribute mat3 mat3_attrib; \r
63 attribute mat4 mat4_attrib; \r
65 uniform float flt_uniform; \r
66 uniform vec3 uniform_vec3; \r
67 uniform mat3 uniform_mat3; \r
69 uniform sampler1D samp[];  \r
70 uniform sampler1D samp1;  \r
72 const struct light12 { \r
73     int a;\r
74 } uniform_struct = light12(2);\r
76 varying vec3 varying_vec3; \r
77 varying vec2 varying_vec2;  \r
78 varying vec4 varying_vec4;  \r
79 varying mat4 varying_mat4;  \r
80 varying mat2 varying_mat2;  \r
81 varying mat3 varying_mat3;  \r
82 varying float varying_flt;  \r
84 float frequencies[2]; \r
86 void test_function2(int func_int)\r
87 {\r
88 }\r
90 void test_function3(light3);\r
91 void test_function4(light5 ll20);\r
92 void test_function5(light1);\r
93 light6 test_function6(int a);\r
95 const float FloatConst1 = 3.0 * 8.0, floatConst2 = 4.0;\r
96 const bool BoolConst1 = true && true || false; \r
97 const bool BoolConst2 = false || !false && false; \r
99 void main(void)\r
102     int test_int1 =  42; \r
104     struct structMain {\r
105         float i;\r
106     } testStruct;\r
108     struct {    \r
109         structMain a;\r
110     } aStruct;\r
112     testStruct.i = 5.0 ; \r
113     struct_var.i = 5.0;  \r
115     structMain newStruct, newStruct1;\r
116     testStruct = newStruct; \r
117     newStruct = newStruct1;  \r
119     lightVar.light2.f = 1.1; \r
121     light1 ll1; \r
122     ll1.light2.a = 1;  \r
124      const struct const_struct {\r
125         float i;\r
126     } const_struct_inst = const_struct(1.0); \r
128     ll1 = ll2; \r
129     ll1.light2 = ll2.light2; \r
130     ll1.light2 = ll1.light2; \r
131     ll1.light2.f = ll2.light2.f;\r
132     ll1.light2.f = ll1.light2.f;\r
134     lightVar = ll2;\r
135     ll2 = lightVar;\r
137     light5 ll10;\r
139     light7 ll7[];\r
140     structMain newStruct2[2];\r
141     newStruct2[0].i = 1.1; \r
142     \r
143     ll7[0].light8.light9.light10.f = 1.1;\r
146     bool test_bool4 = false ; \r
148     bool test_bool5 = 1.2 > 3.0 ; \r
150     int test_int2 =  047; \r
151     int test_int4 =  0xa8;  // testing for hexadecimal numbers\r
153     float test_float1 = 1.5; \r
154     float test_float2 = .01;  \r
155     float test_float3 = 10.; \r
156     float test_float4 = 10.01; \r
157     float test_float5 = 23e+2; \r
158     float test_float6 = 23E-3; \r
159     float test_float8 = 23E2; \r
160     bool test_bool6 = BoolConst1 && ! (test_int1 != 0) && ! BoolConst1  && ! (FloatConst1 != 0.0) && (FloatConst1 != 0.0) && (test_float1 != 0.0); \r
162     vec4 color = vec4(0.0, 1.0, 0.0, 1.0); \r
163     vec4 color2 = vec4(0.0); \r
165     vec3 color4 = vec3(test_float8); \r
167     ivec4 test_int_vect1 = ivec4(1.0,1.0,1.0,1.0);  \r
168     ivec3 test_int_vec3 = ivec3(1, 1, 1) ; \r
170     bvec4 test_bool_vect1 = bvec4(1., 1., 1. , 1. ); \r
172     vec2 test_vec2 = vec2(1., 1.); \r
173     vec2 test_vec3 = vec2(1., 1);  \r
174     vec4 test_vec4 = vec4(test_int_vect1); \r
176     vec2 test_vec5 = vec2(color4);\r
177     vec3 test_vec7 = vec3(color);   \r
178     vec3 test_vec8 = vec3(test_vec2, test_float4);\r
179     vec3 test_vec9 = vec3(test_float4, test_vec2);\r
181     vec4 test_vec10 = vec4(test_vec9, 0.01); \r
182     vec4 test_vec11 = vec4(0.01, test_vec9); \r
184     vec4 test_vec12 = vec4(test_vec2, test_vec2); \r
186     mat2 test_mat2 = mat2(test_float3); \r
187     mat3 test_mat3 = mat3(test_float3); \r
188     mat4 test_mat4 = mat4(test_float3); \r
190     mat2 test_mat7 = mat2(test_vec2, test_vec2); \r
191     mat2 test_mat8 = mat2(01.01, 2.01, 3.01, 4.01); \r
193     mat3 test_mat9 = mat3(test_vec7, test_vec7, test_vec7); \r
194     mat4 test_mat10 = mat4(test_vec10, test_vec10, test_vec10, test_vec10); \r
195     test_mat10[1] = test_vec10; \r
196     \r
198     mat2 test_mat12 = mat2(test_vec2, 0.01, 0.01); \r
199     mat2 test_mat13 = mat2(0.01, 5., test_vec2); \r
200     mat2 test_mat15 = mat2(0.1, 5., test_vec2 ); \r
202     //mat2 test_mat16 = mat2(test_mat9); \r
203     //mat2 test_mat17 = mat2(test_mat10); \r
205     float freq1[2]; \r
206     float freq2[];\r
208     while(test_float1 < 1.0);\r
210     float freq2[]; \r
211     float freq2[25]; \r
212     freq2[1] = 1.9 ; \r
213     const int array_index = 2;\r
214     freq2[test_int1] = 1.9 ;\r
215     freq2[array_index] = 1.8;\r
216     \r
217     const int const_int = 5; \r
218    \r
219     test_float1 = varying_flt; \r
221     int out_int;\r
222     int intArray[];\r
223     test_function(test_int1, test_int1); \r
224     test_function(test_int1, intArray[2]); \r
226     vec3 vv = vec3(test_function1(test_int1, out_int));  \r
227     bool bool_var = true;\r
228     int test_int6 = int(bool_var); \r
229     test_float1 = float(bool_var); \r
230     test_float1 = float(test_int6); \r
231     test_int6 = int(test_float1); \r
232     bool_var = bool(test_int6); \r
233     bool_var = bool(test_float1); \r
234     test_float1 = float(test_vec9); \r
235     \r
236     test_vec2.x = 1.2; \r
237     test_vec2.y = 1.4; \r
238     test_vec2.xy; \r
241     color.zy = test_vec2; \r
243    test_vec2[1] = 1.1;  \r
244     \r
245      test_mat2[0][0] = 1.1; \r
247     test_float1 += 1.0; \r
248     test_float1 -= 1.0;\r
249     test_float1 *= 1.0;\r
250     test_float1 /= 1.0;\r
252     test_mat12 *= test_mat13 ; \r
253     test_mat12  *= test_float1;\r
254     test_vec2 *= test_float1; \r
255     test_vec2 *= test_mat12; \r
256     test_float1++; \r
257     test_float1--; \r
258     --test_float1; \r
259     ++test_float1; \r
260     test_float1; \r
261     test_int1++; \r
262     test_int1--; \r
264     test_vec2 = test_vec2 + test_float1;   \r
265     test_vec2 = test_float1 + test_vec2;   \r
267     test_mat12 = test_mat12 * test_mat13; \r
268     test_vec2 = test_vec2 * test_vec5; \r
269  \r
270     test_vec2++; \r
271     test_mat2++;\r
273     bool test_bool2 = test_float2 > test_float3;  \r
275     bool test_bool3 = test_int1 > test_int6 ; \r
277     test_bool3 = test_vec2 == test_vec5; \r
279     test_bool2 = test_bool3 && test_bool4; \r
280     test_bool2 = test_bool3 || test_bool4; \r
281     test_bool2 = test_bool3 ^^ test_bool4; \r
283     test_bool2 = !test_bool3;  \r
285     test_bool3 = !(test_int1 > test_int6) ; \r
287     test_float1 = test_int1 > test_int6 ? test_float2 : test_float3;  \r
288     test_vec2 = test_int1 > test_int6 ? test_vec2 : test_vec5;  \r
289     if(test_bool2)  \r
290         test_float1++;\r
291     else\r
292         test_float1--;\r
294     if(test_float1 > test_float2)  \r
295         test_float1++;\r
297     if( test_bool2 )  \r
298     {\r
299         int if_int; \r
300         test_float1++;\r
301     }\r
303     if(test_bool2) \r
304        if(test_bool3)\r
305            if(test_bool3)\r
306               test_float1++;\r
308    for(int for_int=0; for_int < 5; for_int++) \r
309    {\r
310        // do nothing as such\r
311    }\r
314    for(; test_bool2; ) \r
315    {\r
316      int for_int;\r
317    }\r
319    for(; test_bool2 = (test_float1 > test_float2); ) \r
320    {\r
321    }\r
323    for(int for_int1; test_bool2; ) \r
324    {\r
325      int for_int;\r
326    }\r
328    for(; test_bool2; test_float1++) \r
329    {\r
330      int test_float;  \r
331    }\r
333    while(bool b = (test_float1 > test_float2)) \r
334    {\r
335        break;\r
336        continue;  \r
337    }\r
340    for(;;) { \r
341        for(;;)\r
342        {\r
343            break;\r
344        }\r
345    }\r
348    while( test_bool2 )  \r
349    {\r
350        break;  \r
351    }\r
353    do {\r
354        int dowhile_int;\r
355        dowhile_int = 3;\r
356    } while(test_bool2);  \r
359     // VERTEX SHADER ONLY VARIABLES\r
360     gl_PointSize = 4.0;  \r
361     gl_ClipVertex = vec4(2.0, 3.0, 1.0, 1.1);  \r
363     gl_Position = vec4(2.0, 3.0, 1.0, 1.1);\r
364     gl_Position = gl_Vertex;\r
367     // VERTEX SHADER BUILT-IN ATTRIBUTES\r
369     vec4 builtInV4 = gl_Color + gl_SecondaryColor + gl_Vertex + gl_MultiTexCoord0 + gl_MultiTexCoord1 + gl_MultiTexCoord2 +  gl_MultiTexCoord3 +  gl_MultiTexCoord4 +  gl_MultiTexCoord5 +  gl_MultiTexCoord6 +  gl_MultiTexCoord7;\r
370     \r
372     int builtInI = gl_MaxLights + gl_MaxClipPlanes + gl_MaxTextureUnits + gl_MaxTextureCoords + gl_MaxVertexAttribs + gl_MaxVertexUniformComponents + gl_MaxVaryingFloats + gl_MaxVertexTextureImageUnits + gl_MaxCombinedTextureImageUnits + gl_MaxTextureImageUnits + gl_MaxFragmentUniformComponents + gl_MaxDrawBuffers ;\r
373     \r
375     mat4 builtInM4 = gl_ModelViewMatrix + gl_ModelViewProjectionMatrix + gl_ProjectionMatrix;\r
377     gl_NormalMatrix;\r
379     gl_TextureMatrix[gl_MaxTextureCoords-1];\r
380     gl_TextureMatrix;\r
381     gl_NormalScale ;\r
383     gl_DepthRange.near ;\r
385     test_float1 = gl_DepthRange.near; \r
386     test_float1 = gl_DepthRange.far; \r
387     test_float1 = gl_DepthRange.diff;\r
389     gl_ClipPlane[gl_MaxClipPlanes-1] ;\r
391     gl_Point.size; \r
392     gl_Point.sizeMin;\r
393     gl_Point.sizeMax; \r
394     gl_Point.fadeThresholdSize ;\r
395     gl_Point.distanceConstantAttenuation;\r
396     gl_Point.distanceLinearAttenuation ;\r
397     gl_Point.distanceQuadraticAttenuation;\r
399     gl_MaterialParameters test; \r
400     gl_FrontMaterial.emission;\r
402     color = gl_FrontMaterial.emission; \r
403     color = gl_FrontMaterial.ambient; \r
404     color = gl_FrontMaterial.diffuse;\r
405     color = gl_FrontMaterial.specular;\r
406     test_float1 = gl_FrontMaterial.shininess; \r
408     gl_LightSourceParameters lightSource;\r
410     float builtInFloat1 = gl_LightSource[0].spotExponent;\r
411     color = gl_LightSource[0].ambient; \r
412     color = lightSource.ambient; \r
413     color = lightSource.diffuse; \r
414     color = lightSource.specular; \r
415     color = lightSource.position; \r
416     color = lightSource.halfVector; \r
417     color4 = lightSource.spotDirection; \r
418     test_float1 = lightSource.spotExponent; \r
419     test_float1 = lightSource.spotCutoff; \r
420     test_float1 = lightSource.spotCosCutoff; \r
421     test_float1 = lightSource.constantAttenuation; \r
422     test_float1 = lightSource.linearAttenuation; \r
423     test_float1 = lightSource.quadraticAttenuation; \r
425     color = gl_LightModel.ambient;\r
427     gl_LightModelParameters lightModel; \r
428     color = gl_LightModel.ambient; \r
429     color = lightModel.ambient; \r
431     color = gl_FrontLightModelProduct.sceneColor ;\r
433     gl_LightModelProducts lightModelProd; \r
435     color = lightModelProd.sceneColor; \r
436     color = gl_FrontLightModelProduct.sceneColor; \r
438     color = gl_FrontLightProduct[0].ambient; \r
439     color = gl_FrontLightProduct[0].ambient; \r
440     gl_LightProducts lightProd;\r
442     color =  lightProd.ambient; \r
443     color =  lightProd.diffuse;\r
444     color =  lightProd.specular;\r
447     color = gl_TextureEnvColor[gl_MaxTextureUnits-1];\r
448     \r
449     color = gl_EyePlaneS[gl_MaxTextureCoords-1] ;\r
451     color = gl_EyePlaneT[gl_MaxTextureCoords-1]; \r
453     color = gl_EyePlaneR[gl_MaxTextureCoords-1];\r
455     color = gl_EyePlaneQ[gl_MaxTextureCoords-1];\r
457     color = gl_ObjectPlaneS[gl_MaxTextureCoords-1];\r
459     color = gl_ObjectPlaneT[gl_MaxTextureCoords-1] ;\r
461     color = gl_ObjectPlaneR[gl_MaxTextureCoords-1];\r
463     color = gl_ObjectPlaneQ[gl_MaxTextureCoords-1]; \r
465     test_float1 = gl_Fog.density ;\r
466     test_float1 = gl_Fog.start ;\r
467     test_float1 = gl_Fog.end  ;\r
468     test_float1 = gl_Fog.scale ;\r
469     color = gl_Fog.color ;\r
471     gl_FrontColor =  vec4(1.0, 1.0, 1.0, 1.0); \r
472     gl_BackColor =  vec4(1.0, 1.0, 1.0, 1.0);  \r
473     gl_FrontSecondaryColor =  vec4(1.0, 1.0, 1.0, 1.0); \r
474     gl_BackSecondaryColor =  vec4(1.0, 1.0, 1.0, 1.0); \r
477     // VARYING VARIABLES AVAILABLE IN FRAGMENT AND VERTEX SHADERS BOTH\r
478     gl_TexCoord[0] =  vec4(1.0, 1.0, 1.0, 1.0);  \r
479     gl_FogFragCoord =  1.0;  \r
483 void test_function(const in int in_int, inout int out_int)\r
485     out_int = 5; \r
486     int i = 5;\r
487     return ;\r
490 int test_function1(in int in_int1, inout int , out int)\r
492    float ff;\r
493    in_int1 = 5;  \r
494    return in_int1;\r
497 void test_function3(light3 ll)\r
499     ll.i = 5.0;  \r
500     varying_flt = 1.2;\r
503 void test_function4(light5 ll20)\r
505     ll20.i = 10.0; \r
508 void test_function5(light1 struct_light1)\r
510     struct_light1.light2.a = 1; \r
511     light5 ll5;\r
512     struct_light1.light2.f = ll5.i;\r
513     struct_light1.light2.f++;\r
514     struct_light1.light2.a++;\r
517 light6 test_function6(int a)  \r
519     int x;\r
520     light6 funcStruct;\r
521     light7 funcStruct1;\r
522     -x;\r
523     x = x - x ; \r
524     mat2 m;\r
525     m++;\r
526     -m; \r
527     (m)++; \r
528     return funcStruct; \r
531 float test_function7(light1 ll1, int light1 )  \r
533     float f;\r
534     \r
535     struct ss1 {\r
536         int a;\r
537     };\r
539     for(;;) {\r
540         for(;;) {\r
541             if(true)\r
542                 break;  \r
543             if(true)\r
544                 break;  \r
545             if(true)\r
546                 break;  \r
547         }\r
548         break;\r
549     }\r
551     for(;;);  \r
552     return float(1);\r