cl: Don't use device_infos if num_device_infos == 0
[piglit.git] / tests / glslparsertest / shaders / CorrectFull.vert
blobd64ec713d049afaeffa1f565e4a792cb7b948547
1 // [config]
2 // expect_result: pass
3 // glsl_version: 1.10
4 //
5 // [end config]
7 void test_function(const in int in_int, inout int out_int);
8 int test_function1(in int in_int, inout int out_int);
10 int test_function1(in int in_int1, inout int , out int);
11 int test_function1(in int in_int1, inout int , out int); 
13 uniform float array_float[2]; 
15 struct light1 
17    float intensity;
18    vec3 position;
19    int test_int[2];
20    struct nested
21    {
22       int a;
23       float f; 
24    } light2;
25 } lightVar;
26 light1 ll2;
28 varying struct light3 {
29     float i;
30 } ;
32 attribute struct light4 {
33     float i;
36 struct light5 {
37     float i ;
38     float a[2];
39 } light5_inst;
41 uniform light3 uniformLight3;
43 uniform struct light6 {  
44     float i;
46 uniform light6 uniformLight6; 
49 struct light7 {
50     struct {
51         struct {
52             struct {
53                 float f;
54             } light10;
55         } light9;
56      } light8;
57 } ;
60 light3 struct_var = light3(5.0); 
62 // Attribute variables can only be Global
63 attribute float flt_attrib;
64 attribute vec2 vec2_attrib;
65 attribute vec3 vec3_attrib;
66 attribute vec4 vec4_attrib; 
67 attribute mat2 mat2_attrib; 
68 attribute mat3 mat3_attrib; 
69 attribute mat4 mat4_attrib; 
71 uniform float flt_uniform; 
72 uniform vec3 uniform_vec3; 
73 uniform mat3 uniform_mat3; 
75 uniform sampler1D samp[];  
76 uniform sampler1D samp1;  
78 const struct light12 { 
79     int a;
80 } uniform_struct = light12(2);
82 varying vec3 varying_vec3; 
83 varying vec2 varying_vec2;  
84 varying vec4 varying_vec4;  
85 varying mat4 varying_mat4;  
86 varying mat2 varying_mat2;  
87 varying mat3 varying_mat3;  
88 varying float varying_flt;  
90 float frequencies[2]; 
92 void test_function2(int func_int)
96 void test_function3(light3);
97 void test_function4(light5 ll20);
98 void test_function5(light1);
99 light6 test_function6(int a);
101 const float FloatConst1 = 3.0 * 8.0, floatConst2 = 4.0;
102 const bool BoolConst1 = true && true || false; 
103 const bool BoolConst2 = false || !false && false; 
105 void main(void)
108     int test_int1 =  42; 
110     struct structMain {
111         float i;
112     } testStruct;
114     struct {    
115         structMain a;
116     } aStruct;
118     testStruct.i = 5.0 ; 
119     struct_var.i = 5.0;  
121     structMain newStruct, newStruct1;
122     testStruct = newStruct; 
123     newStruct = newStruct1;  
125     lightVar.light2.f = 1.1; 
127     light1 ll1; 
128     ll1.light2.a = 1;  
130      const struct const_struct {
131         float i;
132     } const_struct_inst = const_struct(1.0); 
134     ll1 = ll2; 
135     ll1.light2 = ll2.light2; 
136     ll1.light2 = ll1.light2; 
137     ll1.light2.f = ll2.light2.f;
138     ll1.light2.f = ll1.light2.f;
140     lightVar = ll2;
141     ll2 = lightVar;
143     light5 ll10;
145     light7 ll7[];
146     structMain newStruct2[2];
147     newStruct2[0].i = 1.1; 
148     
149     ll7[0].light8.light9.light10.f = 1.1;
152     bool test_bool4 = false ; 
154     bool test_bool5 = 1.2 > 3.0 ; 
156     int test_int2 =  047; 
157     int test_int4 =  0xa8;  // testing for hexadecimal numbers
159     float test_float1 = 1.5; 
160     float test_float2 = .01;  
161     float test_float3 = 10.; 
162     float test_float4 = 10.01; 
163     float test_float5 = 23e+2; 
164     float test_float6 = 23E-3; 
165     float test_float8 = 23E2; 
166     bool test_bool6 = BoolConst1 && ! (test_int1 != 0) && ! BoolConst1  && ! (FloatConst1 != 0.0) && (FloatConst1 != 0.0) && (test_float1 != 0.0); 
168     vec4 color = vec4(0.0, 1.0, 0.0, 1.0); 
169     vec4 color2 = vec4(0.0); 
171     vec3 color4 = vec3(test_float8); 
173     ivec4 test_int_vect1 = ivec4(1.0,1.0,1.0,1.0);  
174     ivec3 test_int_vec3 = ivec3(1, 1, 1) ; 
176     bvec4 test_bool_vect1 = bvec4(1., 1., 1. , 1. ); 
178     vec2 test_vec2 = vec2(1., 1.); 
179     vec2 test_vec3 = vec2(1., 1);  
180     vec4 test_vec4 = vec4(test_int_vect1); 
182     vec2 test_vec5 = vec2(color4);
183     vec3 test_vec7 = vec3(color);   
184     vec3 test_vec8 = vec3(test_vec2, test_float4);
185     vec3 test_vec9 = vec3(test_float4, test_vec2);
187     vec4 test_vec10 = vec4(test_vec9, 0.01); 
188     vec4 test_vec11 = vec4(0.01, test_vec9); 
190     vec4 test_vec12 = vec4(test_vec2, test_vec2); 
192     mat2 test_mat2 = mat2(test_float3); 
193     mat3 test_mat3 = mat3(test_float3); 
194     mat4 test_mat4 = mat4(test_float3); 
196     mat2 test_mat7 = mat2(test_vec2, test_vec2); 
197     mat2 test_mat8 = mat2(01.01, 2.01, 3.01, 4.01); 
199     mat3 test_mat9 = mat3(test_vec7, test_vec7, test_vec7); 
200     mat4 test_mat10 = mat4(test_vec10, test_vec10, test_vec10, test_vec10); 
201     test_mat10[1] = test_vec10; 
202     
204     mat2 test_mat12 = mat2(test_vec2, 0.01, 0.01); 
205     mat2 test_mat13 = mat2(0.01, 5., test_vec2); 
206     mat2 test_mat15 = mat2(0.1, 5., test_vec2 ); 
208     //mat2 test_mat16 = mat2(test_mat9); 
209     //mat2 test_mat17 = mat2(test_mat10); 
211     float freq1[2]; 
212     float freq2[];
214     while(test_float1 < 1.0);
216     float freq2[]; 
217     float freq2[25]; 
218     freq2[1] = 1.9 ; 
219     const int array_index = 2;
220     freq2[test_int1] = 1.9 ;
221     freq2[array_index] = 1.8;
222     
223     const int const_int = 5; 
224    
225     test_float1 = varying_flt; 
227     int out_int;
228     int intArray[];
229     test_function(test_int1, test_int1); 
230     test_function(test_int1, intArray[2]); 
232     vec3 vv = vec3(test_function1(test_int1, out_int));  
233     bool bool_var = true;
234     int test_int6 = int(bool_var); 
235     test_float1 = float(bool_var); 
236     test_float1 = float(test_int6); 
237     test_int6 = int(test_float1); 
238     bool_var = bool(test_int6); 
239     bool_var = bool(test_float1); 
240     test_float1 = float(test_vec9); 
241     
242     test_vec2.x = 1.2; 
243     test_vec2.y = 1.4; 
244     test_vec2.xy; 
247     color.zy = test_vec2; 
249    test_vec2[1] = 1.1;  
250     
251      test_mat2[0][0] = 1.1; 
253     test_float1 += 1.0; 
254     test_float1 -= 1.0;
255     test_float1 *= 1.0;
256     test_float1 /= 1.0;
258     test_mat12 *= test_mat13 ; 
259     test_mat12  *= test_float1;
260     test_vec2 *= test_float1; 
261     test_vec2 *= test_mat12; 
262     test_float1++; 
263     test_float1--; 
264     --test_float1; 
265     ++test_float1; 
266     test_float1; 
267     test_int1++; 
268     test_int1--; 
270     test_vec2 = test_vec2 + test_float1;   
271     test_vec2 = test_float1 + test_vec2;   
273     test_mat12 = test_mat12 * test_mat13; 
274     test_vec2 = test_vec2 * test_vec5; 
276     test_vec2++; 
277     test_mat2++;
279     bool test_bool2 = test_float2 > test_float3;  
281     bool test_bool3 = test_int1 > test_int6 ; 
283     test_bool3 = test_vec2 == test_vec5; 
285     test_bool2 = test_bool3 && test_bool4; 
286     test_bool2 = test_bool3 || test_bool4; 
287     test_bool2 = test_bool3 ^^ test_bool4; 
289     test_bool2 = !test_bool3;  
291     test_bool3 = !(test_int1 > test_int6) ; 
293     test_float1 = test_int1 > test_int6 ? test_float2 : test_float3;  
294     test_vec2 = test_int1 > test_int6 ? test_vec2 : test_vec5;  
295     if(test_bool2)  
296         test_float1++;
297     else
298         test_float1--;
300     if(test_float1 > test_float2)  
301         test_float1++;
303     if( test_bool2 )  
304     {
305         int if_int; 
306         test_float1++;
307     }
309     if(test_bool2) 
310        if(test_bool3)
311            if(test_bool3)
312               test_float1++;
314    for(int for_int=0; for_int < 5; for_int++) 
315    {
316        // do nothing as such
317    }
320    for(; test_bool2; ) 
321    {
322      int for_int;
323    }
325    for(; test_bool2 = (test_float1 > test_float2); ) 
326    {
327    }
329    for(int for_int1; test_bool2; ) 
330    {
331      int for_int;
332    }
334    for(; test_bool2; test_float1++) 
335    {
336      int test_float;  
337    }
339    while(bool b = (test_float1 > test_float2)) 
340    {
341        break;
342        continue;  
343    }
346    for(;;) { 
347        for(;;)
348        {
349            break;
350        }
351    }
354    while( test_bool2 )  
355    {
356        break;  
357    }
359    do {
360        int dowhile_int;
361        dowhile_int = 3;
362    } while(test_bool2);  
365     // VERTEX SHADER ONLY VARIABLES
366     gl_PointSize = 4.0;  
367     gl_ClipVertex = vec4(2.0, 3.0, 1.0, 1.1);  
369     gl_Position = vec4(2.0, 3.0, 1.0, 1.1);
370     gl_Position = gl_Vertex;
373     // VERTEX SHADER BUILT-IN ATTRIBUTES
375     vec4 builtInV4 = gl_Color + gl_SecondaryColor + gl_Vertex + gl_MultiTexCoord0 + gl_MultiTexCoord1 + gl_MultiTexCoord2 +  gl_MultiTexCoord3 +  gl_MultiTexCoord4 +  gl_MultiTexCoord5 +  gl_MultiTexCoord6 +  gl_MultiTexCoord7;
376     
378     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 ;
379     
381     mat4 builtInM4 = gl_ModelViewMatrix + gl_ModelViewProjectionMatrix + gl_ProjectionMatrix;
383     gl_NormalMatrix;
385     gl_TextureMatrix[gl_MaxTextureCoords-1];
386     gl_TextureMatrix;
387     gl_NormalScale ;
389     gl_DepthRange.near ;
391     test_float1 = gl_DepthRange.near; 
392     test_float1 = gl_DepthRange.far; 
393     test_float1 = gl_DepthRange.diff;
395     gl_ClipPlane[gl_MaxClipPlanes-1] ;
397     gl_Point.size; 
398     gl_Point.sizeMin;
399     gl_Point.sizeMax; 
400     gl_Point.fadeThresholdSize ;
401     gl_Point.distanceConstantAttenuation;
402     gl_Point.distanceLinearAttenuation ;
403     gl_Point.distanceQuadraticAttenuation;
405     gl_MaterialParameters test; 
406     gl_FrontMaterial.emission;
408     color = gl_FrontMaterial.emission; 
409     color = gl_FrontMaterial.ambient; 
410     color = gl_FrontMaterial.diffuse;
411     color = gl_FrontMaterial.specular;
412     test_float1 = gl_FrontMaterial.shininess; 
414     gl_LightSourceParameters lightSource;
416     float builtInFloat1 = gl_LightSource[0].spotExponent;
417     color = gl_LightSource[0].ambient; 
418     color = lightSource.ambient; 
419     color = lightSource.diffuse; 
420     color = lightSource.specular; 
421     color = lightSource.position; 
422     color = lightSource.halfVector; 
423     color4 = lightSource.spotDirection; 
424     test_float1 = lightSource.spotExponent; 
425     test_float1 = lightSource.spotCutoff; 
426     test_float1 = lightSource.spotCosCutoff; 
427     test_float1 = lightSource.constantAttenuation; 
428     test_float1 = lightSource.linearAttenuation; 
429     test_float1 = lightSource.quadraticAttenuation; 
431     color = gl_LightModel.ambient;
433     gl_LightModelParameters lightModel; 
434     color = gl_LightModel.ambient; 
435     color = lightModel.ambient; 
437     color = gl_FrontLightModelProduct.sceneColor ;
439     gl_LightModelProducts lightModelProd; 
441     color = lightModelProd.sceneColor; 
442     color = gl_FrontLightModelProduct.sceneColor; 
444     color = gl_FrontLightProduct[0].ambient; 
445     color = gl_FrontLightProduct[0].ambient; 
446     gl_LightProducts lightProd;
448     color =  lightProd.ambient; 
449     color =  lightProd.diffuse;
450     color =  lightProd.specular;
453     color = gl_TextureEnvColor[gl_MaxTextureUnits-1];
454     
455     color = gl_EyePlaneS[gl_MaxTextureCoords-1] ;
457     color = gl_EyePlaneT[gl_MaxTextureCoords-1]; 
459     color = gl_EyePlaneR[gl_MaxTextureCoords-1];
461     color = gl_EyePlaneQ[gl_MaxTextureCoords-1];
463     color = gl_ObjectPlaneS[gl_MaxTextureCoords-1];
465     color = gl_ObjectPlaneT[gl_MaxTextureCoords-1] ;
467     color = gl_ObjectPlaneR[gl_MaxTextureCoords-1];
469     color = gl_ObjectPlaneQ[gl_MaxTextureCoords-1]; 
471     test_float1 = gl_Fog.density ;
472     test_float1 = gl_Fog.start ;
473     test_float1 = gl_Fog.end  ;
474     test_float1 = gl_Fog.scale ;
475     color = gl_Fog.color ;
477     gl_FrontColor =  vec4(1.0, 1.0, 1.0, 1.0); 
478     gl_BackColor =  vec4(1.0, 1.0, 1.0, 1.0);  
479     gl_FrontSecondaryColor =  vec4(1.0, 1.0, 1.0, 1.0); 
480     gl_BackSecondaryColor =  vec4(1.0, 1.0, 1.0, 1.0); 
483     // VARYING VARIABLES AVAILABLE IN FRAGMENT AND VERTEX SHADERS BOTH
484     gl_TexCoord[0] =  vec4(1.0, 1.0, 1.0, 1.0);  
485     gl_FogFragCoord =  1.0;  
489 void test_function(const in int in_int, inout int out_int)
491     out_int = 5; 
492     int i = 5;
493     return ;
496 int test_function1(in int in_int1, inout int unused1, out int unused2)
498    float ff;
499    in_int1 = 5;  
500    return in_int1;
503 void test_function3(light3 ll)
505     ll.i = 5.0;  
506     varying_flt = 1.2;
509 void test_function4(light5 ll20)
511     ll20.i = 10.0; 
514 void test_function5(light1 struct_light1)
516     struct_light1.light2.a = 1; 
517     light5 ll5;
518     struct_light1.light2.f = ll5.i;
519     struct_light1.light2.f++;
520     struct_light1.light2.a++;
523 light6 test_function6(int a)  
525     int x;
526     light6 funcStruct;
527     light7 funcStruct1;
528     -x;
529     x = x - x ; 
530     mat2 m;
531     m++;
532     -m; 
533     (m)++; 
534     return funcStruct; 
537 float test_function7(light1 ll1, int light1 )  
539     float f;
540     
541     struct ss1 {
542         int a;
543     };
545     for(;;) {
546         for(;;) {
547             if(true)
548                 break;  
549             if(true)
550                 break;  
551             if(true)
552                 break;  
553         }
554         break;
555     }
557     for(;;);  
558     return float(1);