Merge pull request #2908 from Biswa96/cmake-spirv-remap
[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(push_constant) uniform pcbnd2 {  // ERROR, can't be array\r
50     float a;\r
51 } pcbnd2inst[2];\r
52 layout(std430, push_constant) uniform pcb1 { int a; } pcb1inst;\r
53 layout(push_constant) uniform pcb2 {\r
54     int a;\r
55 };                                            // Okay now to have no instance name\r
56 \r
57 layout(input_attachment_index = 2) uniform subpassInput subD;\r
58 layout(input_attachment_index = 3) uniform texture2D subDbad1;          // ERROR, not a texture\r
59 layout(input_attachment_index = 4) writeonly uniform image2D subDbad2;  // ERROR, not an image\r
60 uniform subpassInput subDbad3;                                          // ERROR, need attachment number\r
61 layout(input_attachment_index = 2) uniform subpassInputMS subDMS;\r
62 \r
63 void foo()\r
64 {\r
65     vec4 v = subpassLoad(subD);\r
66     v += subpassLoadMS(subD);      // ERROR, no such function\r
67     v += subpassLoad(subD, 2);     // ERROR, no such sig.\r
68     v += subpassLoad(subDMS, 2);\r
69     v += subpassLoadMS(subDMS, 2); // ERROR, no such function\r
70 }\r
71 \r
72 subroutine int fooS;                              // ERROR, not in SPV\r
73 subroutine int fooSub();                          // ERROR, not in SPV\r
74 \r
75 uniform vec4 dv4;                                 // ERROR, no default uniforms\r
76 \r
77 void fooTex()\r
78 {\r
79     texture(t2d, vec2(1.0));                 // ERROR, need a sampler, not a pure texture\r
80     imageStore(t2d, ivec2(4, 5), vec4(1.2)); // ERROR, need an image, not a pure texture\r
81 }\r
82 \r
83 precision highp float;\r
84 \r
85 layout(location=0) in vec2 vTexCoord;\r
86 layout(location=0) out vec4 FragColor;\r
87 \r
88 vec4 userTexture(mediump sampler2D samp, vec2 coord)\r
89 {\r
90     return texture(samp, coord);\r
91 }\r
92 \r
93 bool cond;\r
94 \r
95 void callUserTexture()\r
96 {\r
97     userTexture(sampler2D(t2d,s), vTexCoord);                            // ERROR, not point of use\r
98     userTexture((sampler2D(t2d,s)), vTexCoord);                          // ERROR, not point of use\r
99     userTexture((sampler2D(t2d,s), sampler2D(t2d,s)), vTexCoord);        // ERROR, not point of use\r
100     userTexture(cond ? sampler2D(t2d,s) : sampler2D(t2d,s), vTexCoord);  // ERROR, no ?:, not point of use\r
101 \r
102     gl_NumSamples;   // ERROR, not for Vulkan\r
103 }\r
104 \r
105 void noise()\r
106 {\r
107     noise1(dv4);\r
108     noise2(4.0);\r
109     noise3(vec2(3));\r
110     noise4(dv4);\r
111 }\r