Merge pull request #2891 from dneto0/hlsl-namespace
[platform/upstream/glslang.git] / Test / 400.frag
1 #version 400 core
2
3 in vec2 c2D;
4 flat in int i;
5 out vec4 outp;
6 uniform sampler2D arrayedSampler[5];
7 uniform usampler2DRect samp2dr;
8 uniform isampler2DArray isamp2DA;
9
10 void main()
11 {
12     vec4 v;
13     v = texture(arrayedSampler[i], c2D);
14     outp.x = gl_ClipDistance[1];
15
16     ivec2 offsets[4];
17     const ivec2 constOffsets[4] = ivec2[4](ivec2(1,2), ivec2(3,4), ivec2(15,16), ivec2(-2,0));
18     uvec4 uv4 = textureGatherOffsets(samp2dr, c2D, offsets, 2);  // ERROR, offsets not constant
19     uv4 = textureGatherOffsets(samp2dr, c2D, constOffsets, 2);
20     vec4 v4 = textureGather(arrayedSampler[0], c2D);
21     ivec4 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 3);
22     iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), i);  // ERROR, last argument not const
23     iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 4);  // ERROR, last argument out of range
24     iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 1+2);
25     iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(i));
26
27     vec4 c = gl_FragCoord;
28 }
29
30 layout(location = 4) in vec4 vl; // ERROR, not supported
31
32 #ifdef GL_ARB_separate_shader_objects
33 #extension GL_ARB_separate_shader_objects : enable
34 #endif
35
36 layout(location = 6) in vec4 vl2;
37
38 layout(location = 3) uniform vec3 uv3;
39
40 layout(location = 5) in vec4 gl_Color;      // ERROR, layout
41 noperspective in float gl_ClipDistance[4];  // ERROR, can't change qualifier
42
43 layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;  // ERROR, declared after use
44
45 uniform sampler2DRectShadow u2drs;
46
47 void foo23()
48 {
49     const ivec2[3] offsets = ivec2[3](ivec2(1,2), ivec2(3,4), ivec2(15,16));
50
51     textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), ivec2(c2D));     // ERROR, offset not constant
52     textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[1]);
53     textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), offsets[2]);     // ERROR, offset out of range
54     textureProjGradOffset(u2drs, outp, vec2(0.0), vec2(0.0), ivec2(-10, 20)); // ERROR, offset out of range
55 }
56
57 patch in vec4 patchIn;              // ERROR
58 patch out vec4 patchOut;            // ERROR
59
60 void foo24()
61 {
62     dvec3 df, di;
63     df = modf(dvec3(outp.xyz), di);
64 }
65
66 in float in1;
67 in vec2 in2;
68 in vec3 in3;
69 in vec4 in4;
70
71 void foodc1()
72 {
73     vec2 v2 = dFdxFine(in2);           // ERROR
74     vec3 v3 = dFdyCoarse(in3);         // ERROR
75     vec4 v4 = fwidthCoarse(in4) + fwidthFine(in4);   // ERROR
76 }
77
78 #extension GL_ARB_derivative_control : enable
79
80 void foodc2()
81 {
82     vec2 v2 = dFdxFine(in2);
83     vec3 v3 = dFdyCoarse(in3);
84     vec4 v4 = fwidthCoarse(in4) + fwidthFine(in4);
85
86     uint u1;
87     ivec3 i3;
88     ivec2 i2;
89     v2 = frexp(v2, i2);
90     v3 = ldexp(v3, i3);
91
92     u1 = packUnorm4x8(v4);
93     u1 = packSnorm4x8(v4);
94     v4 = unpackUnorm4x8(u1);
95     v4 = unpackSnorm4x8(u1);
96
97     double d;
98     uvec2 u2;
99     d = packDouble2x32(u2);
100     u2 = unpackDouble2x32(d);
101 }
102 \r
103 sample in vec4 colorSampIn;\r
104 sample out vec4 colorSampleBad;     // ERROR\r
105 noperspective in vec4 colorfsi;\r
106 sample in vec3 sampInArray[4];\r
107 smooth in float scalarIn;\r
108 flat centroid in vec2 colorfc;\r
109 \r
110 struct S {\r
111     float x;\r
112 };\r
113 \r
114 in S s1;\r
115 sample S s2;\r
116 \r
117 void interp()\r
118 {\r
119     interpolateAtCentroid(colorfc);\r
120     interpolateAtCentroid(colorSampIn);\r
121     interpolateAtCentroid(colorfsi);\r
122     interpolateAtCentroid(scalarIn);\r
123     interpolateAtCentroid(sampInArray);         // ERROR\r
124     interpolateAtCentroid(sampInArray[2]);\r
125     interpolateAtCentroid(sampInArray[2].xy);   // ERROR\r
126 \r
127     interpolateAtSample(sampInArray, 1);        // ERROR\r
128     interpolateAtSample(sampInArray[i], 0);\r
129     interpolateAtSample(s1.x, 2);\r
130     interpolateAtSample(scalarIn, 1);\r
131 \r
132     interpolateAtOffset(sampInArray, vec2(0.2));         // ERROR\r
133     interpolateAtOffset(sampInArray[2], vec2(0.2));\r
134     interpolateAtOffset(sampInArray[2].xy, vec2(0.2));   // ERROR, no swizzle\r
135     interpolateAtOffset(scalarIn + scalarIn, vec2(0.2)); // ERROR, no binary ops other than dereference\r
136     interpolateAtOffset(s2.x, vec2(0.2));      // ERROR\r
137 \r
138     float f;\r
139     interpolateAtCentroid(f);           // ERROR, not interpolant\r
140     interpolateAtSample(outp, 0);       // ERROR, not interpolant\r
141 }\r
142 \r
143 uniform sampler1D samp1D;\r
144 uniform isampler2D isamp2D;\r
145 uniform usampler3D usamp3D;\r
146 uniform samplerCube sampCube; \r
147 uniform isampler1DArray isamp1DA;\r
148 uniform usampler2DArray usamp2DA;\r
149 uniform isamplerCubeArray isampCubeA;\r
150 \r
151 uniform sampler1DShadow samp1Ds;\r
152 uniform sampler2DShadow samp2Ds;\r
153 uniform samplerCubeShadow sampCubes;\r
154 uniform sampler1DArrayShadow samp1DAs;\r
155 uniform sampler2DArrayShadow samp2DAs;\r
156 uniform samplerCubeArrayShadow sampCubeAs;\r
157 \r
158 uniform samplerBuffer sampBuf;\r
159 uniform sampler2DRect sampRect;\r
160 \r
161 void qlod()\r
162 {\r
163     vec2 lod;\r
164     float pf;\r
165     vec2 pf2;\r
166     vec3 pf3;\r
167 \r
168     lod = textureQueryLod(samp1D, pf);\r
169     lod = textureQueryLod(isamp2D, pf2);\r
170     lod = textureQueryLod(usamp3D, pf3);\r
171     lod = textureQueryLod(sampCube, pf3);\r
172     lod = textureQueryLod(isamp1DA, pf);\r
173     lod = textureQueryLod(usamp2DA, pf2);\r
174     lod = textureQueryLod(isampCubeA, pf3);\r
175 \r
176     lod = textureQueryLod(samp1Ds, pf);\r
177     lod = textureQueryLod(samp2Ds, pf2);\r
178     lod = textureQueryLod(sampCubes, pf3);\r
179     lod = textureQueryLod(samp1DAs, pf);\r
180     lod = textureQueryLod(samp2DAs, pf2);\r
181     lod = textureQueryLod(sampCubeAs, pf3);\r
182 \r
183     lod = textureQueryLod(sampBuf, pf);     // ERROR\r
184     lod = textureQueryLod(sampRect, pf2);   // ERROR\r
185 }\r
186 \r
187 uniform uint uu;\r
188 out uint iout;\r
189 \r
190 void bitwiseConv()\r
191 {\r
192     iout = uu & i;\r
193     iout += uu ^ i;\r
194     iout += i | uu;\r
195 }\r
196 \r
197 subroutine(subT1, subT2);\r
198 subroutine float subT1() { return 1.0; }\r
199 subroutine float subT2() { return 1.0; }\r
200 \r
201 struct SKeyMem { int precise; } KeyMem;     // ERROR, keyword can't be a member\r