25bfefeccb561468f096ce50968b4bf0f16758f0
[platform/upstream/glslang.git] / Test / vulkan.frag
1 #version 450\r
2 \r
3 uniform sampler s;         // ERROR, no binding\r
4 uniform sampler sA[4];     // ERROR, no binding\r
5 uniform texture2D t2d;     // ERROR, no binding\r
6 uniform texture3D t3d[4];  // ERROR, no binding\r
7 int i;\r
8 uniform samplerShadow sShadow;\r
9 uniform texture3D t3d5[5];\r
10 writeonly uniform image2D i2d;\r
11 \r
12 void badConst()\r
13 {\r
14     sampler2D(t2d);       // ERROR, need 2 args\r
15     sampler2D(s, s);      // ERROR, wrong type\r
16     sampler2D(i, i);      // ERROR, wrong type\r
17     sampler2D(t2d, i);    // ERROR, wrong type\r
18     sampler2D(t2d, t2d);  // ERROR, wrong type\r
19     sampler2D(t2d, sA);   // ERROR, wrong type\r
20 \r
21     sampler3D[4](t3d5, sA[2]);    // ERROR, can't make array\r
22     sampler2D(i2d, s);            // ERROR, image instead of texture\r
23     sampler2D(t3d[1], s);         // ERROR, 3D not 2D\r
24     sampler2D(t2d, sShadow);\r
25     sampler2DShadow(t2d, s);\r
26 }\r
27 \r
28 sampler2D s2D = sampler2D(t2d, s);            // ERROR, no sampler constructor\r
29 sampler3D s3d[4] = sampler3D[4](t3d, sA[2]);  // ERROR, no sampler constructor\r
30 \r
31 out vec4 color; // ERROR, no location\r
32 \r
33 void main()\r
34 {\r
35     color = texture(s2D, vec2(0.5));\r
36     color += texture(s3d[i], vec3(0.5));\r
37 }\r
38 \r
39 layout(push_constant) buffer pcb {            // ERROR, not on a buffer\r
40     int a;\r
41 } pcbInst;\r
42 \r
43 layout(push_constant) uniform float pcfloat;  // ERROR 2X: not on a non-block, and non-opaque outside block\r
44 \r
45 layout(push_constant) uniform;                // ERROR, needs an object\r
46 layout(binding=2, push_constant) uniform pcbnd1 {  // ERROR, can't have binding\r
47     int a;\r
48 } pcbnd1inst;\r
49 layout(std430, push_constant) uniform pcb1 { int a; } pcb1inst;\r
50 layout(push_constant) uniform pcb2 {\r
51     int a;\r
52 };                                            // Okay now to have no instance name\r
53 \r
54 layout(input_attachment_index = 2) uniform subpassInput subD;\r
55 layout(input_attachment_index = 3) uniform texture2D subDbad1;          // ERROR, not a texture\r
56 layout(input_attachment_index = 4) writeonly uniform image2D subDbad2;  // ERROR, not an image\r
57 uniform subpassInput subDbad3;                                          // ERROR, need attachment number\r
58 layout(input_attachment_index = 2) uniform subpassInputMS subDMS;\r
59 \r
60 void foo()\r
61 {\r
62     vec4 v = subpassLoad(subD);\r
63     v += subpassLoadMS(subD);      // ERROR, no such function\r
64     v += subpassLoad(subD, 2);     // ERROR, no such sig.\r
65     v += subpassLoad(subDMS, 2);\r
66     v += subpassLoadMS(subDMS, 2); // ERROR, no such function\r
67 }\r
68 \r
69 subroutine int fooS;                              // ERROR, not in SPV\r
70 subroutine int fooSub();                          // ERROR, not in SPV\r
71 \r
72 uniform vec4 dv4;                                 // ERROR, no default uniforms\r
73 \r
74 void fooTex()\r
75 {\r
76     texture(t2d, vec2(1.0));                 // ERROR, need a sampler, not a pure texture\r
77     imageStore(t2d, ivec2(4, 5), vec4(1.2)); // ERROR, need an image, not a pure texture\r
78 }\r
79 \r
80 precision highp float;\r
81 \r
82 layout(location=0) in vec2 vTexCoord;\r
83 layout(location=0) out vec4 FragColor;\r
84 \r
85 vec4 userTexture(mediump sampler2D samp, vec2 coord)\r
86 {\r
87     return texture(samp, coord);\r
88 }\r
89 \r
90 bool cond;\r
91 \r
92 void callUserTexture()\r
93 {\r
94     userTexture(sampler2D(t2d,s), vTexCoord);                            // ERROR, not point of use\r
95     userTexture((sampler2D(t2d,s)), vTexCoord);                          // ERROR, not point of use\r
96     userTexture((sampler2D(t2d,s), sampler2D(t2d,s)), vTexCoord);        // ERROR, not point of use\r
97     userTexture(cond ? sampler2D(t2d,s) : sampler2D(t2d,s), vTexCoord);  // ERROR, no ?:, not point of use\r
98 \r
99     gl_NumSamples;   // ERROR, not for Vulkan\r
100 }\r
101 \r
102 void noise()\r
103 {\r
104     noise1(dv4);\r
105     noise2(4.0);\r
106     noise3(vec2(3));\r
107     noise4(dv4);\r
108 }\r