310.vert 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. #version 310 es
  2. shared vec4 s; // ERROR
  3. layout(local_size_x = 2) out; // ERROR
  4. buffer vec4 v; // ERROR
  5. in int ini;
  6. layout(location = 2) uniform mat4 x;
  7. layout(location = 3) uniform mat4 y;
  8. layout(location = 2) out mat4 xi;
  9. layout(location = 3) out mat4 yi; // ERROR, locations conflict with xi
  10. void main()
  11. {
  12. uvec2 u2;
  13. u2 = uaddCarry(u2, u2, u2);
  14. uint u1;
  15. u1 = usubBorrow(u1, u1, u1);
  16. uvec4 u4;
  17. umulExtended(u4, u4, u4, u4);
  18. ivec4 i4;
  19. imulExtended(i4, i4, i4, i4);
  20. int i1;
  21. i1 = bitfieldExtract(i1, 4, 5);
  22. uvec3 u3;
  23. u3 = bitfieldExtract(u3, 4, 5);
  24. ivec3 i3;
  25. i3 = bitfieldInsert(i3, i3, 4, 5);
  26. u1 = bitfieldInsert(u1, u1, 4, 5);
  27. ivec2 i2;
  28. i2 = bitfieldReverse(i2);
  29. u4 = bitfieldReverse(u4);
  30. i1 = bitCount(i1);
  31. i3 = bitCount(u3);
  32. i2 = findLSB(i2);
  33. i4 = findLSB(u4);
  34. i1 = findMSB(i1);
  35. i2 = findMSB(u2);
  36. vec3 v3;
  37. v3 = frexp(v3, i3);
  38. vec2 v2;
  39. v2 = ldexp(v2, i2);
  40. mediump vec4 v4;
  41. u1 = packUnorm4x8(v4);
  42. u1 = packSnorm4x8(v4);
  43. v4 = unpackUnorm4x8(u1);
  44. v4 = unpackSnorm4x8(u1);
  45. }
  46. precision highp sampler2DMS;
  47. precision highp isampler2DMS;
  48. precision highp usampler2DMS;
  49. uniform sampler2DMS s2dms;
  50. uniform isampler2DMS is2dms;
  51. uniform usampler2DMS us2dms;
  52. uniform usampler2DMSArray us2dmsa; // ERROR
  53. void foo()
  54. {
  55. ivec2 v2;
  56. v2 = textureSize(s2dms);
  57. v2 = textureSize(us2dms);
  58. vec4 v4 = texelFetch(s2dms, v2, 2);
  59. ivec4 iv4 = texelFetch(is2dms, v2, 2);
  60. textureSamples(s2dms); // ERROR
  61. float f;
  62. frexp(f, ini); // ERROR, i not writable
  63. }
  64. out bool outb; // ERROR
  65. out sampler2D outo; // ERROR
  66. out float outa[4];
  67. out float outaa[4][2]; // ERROR
  68. struct S { float f; };
  69. out S outs;
  70. out S[4] outasa; // ERROR
  71. out S outsa[4]; // ERROR
  72. struct SA { float f[4]; };
  73. out SA outSA; // ERROR
  74. struct SS { float f; S s; };
  75. out SS outSS; // ERROR
  76. layout(std430) uniform U430 { int a; } U430i; // ERROR
  77. layout(std430) buffer B430 { int a; } B430i;
  78. #ifndef GL_OES_shader_io_blocks
  79. #error GL_OES_shader_io_blocks not defined
  80. #endif
  81. #extension GL_OES_shader_io_blocks : enable
  82. out outbname {
  83. int a;
  84. out vec4 v;
  85. highp sampler2D s; // ERROR, opaque type
  86. } outbinst;
  87. out outbname2 {
  88. layout(location = 12) int aAnon;
  89. layout(location = 13) vec4 vAnon;
  90. };
  91. layout(location = 12) out highp int aliased; // ERROR, aliasing location
  92. in inbname { int a; } inbinst; // ERROR, no in block in vertex shader
  93. out gl_PerVertex { // ERROR, has extra member
  94. highp vec4 gl_Position;
  95. highp vec4 t;
  96. };
  97. void foo_IO()
  98. {
  99. int sum = gl_VertexID +
  100. gl_InstanceID;
  101. gl_Position = vec4(1.0);
  102. gl_PointSize = 2.0; // ERROR, removed by redeclaration
  103. }
  104. out gl_PerVertex { // ERROR, already used and already redeclared
  105. highp vec4 gl_Position;
  106. highp vec4 t;
  107. };
  108. smooth out smo { // ERROR, no smooth on a block
  109. int i;
  110. } smon;
  111. flat out fmo { // ERROR, no flat on a block
  112. int i;
  113. } fmon;
  114. centroid out cmo { // ERROR, no centroid on a block
  115. int i;
  116. } cmon;
  117. invariant out imo { // ERROR, no invariant on a block
  118. int i;
  119. } imon;
  120. in vec2 inf, ing;
  121. uniform ivec2 offsets[4];
  122. uniform sampler2D sArray[4];
  123. uniform int sIndex;
  124. layout(binding = 0) uniform atomic_uint auArray[2];
  125. uniform ubName { int i; } ubInst[4];
  126. buffer bbName { int i; } bbInst[4];
  127. highp uniform writeonly image2D iArray[5];
  128. const ivec2 constOffsets[4] = ivec2[4](ivec2(0.1), ivec2(0.2), ivec2(0.3), ivec2(0.4));
  129. void pfooBad()
  130. {
  131. precise vec2 h; // ERROR reserved
  132. h = fma(inf, ing, h); // ERROR, not available
  133. sArray[sIndex + 1]; // ERRRO, not supported
  134. auArray[sIndex + 1];
  135. ubInst[1];
  136. bbInst[2];
  137. ubInst[sIndex + 1]; // ERROR, not supported
  138. bbInst[sIndex]; // ERROR, not supported
  139. iArray[2];
  140. iArray[sIndex * 2]; // ERROR, not supported
  141. textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf)); // ERROR, offset not constant
  142. textureGatherOffsets(sArray[0], vec2(0.1), constOffsets); // ERROR, not available
  143. }
  144. #extension GL_OES_gpu_shader5 : enable
  145. void pfoo()
  146. {
  147. precise vec2 h;
  148. h = fma(inf, ing, h);
  149. sArray[sIndex + 1];
  150. ubInst[sIndex + 1];
  151. bbInst[sIndex - 2]; // ERROR, still not supported
  152. iArray[2];
  153. iArray[sIndex - 2];
  154. textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf));
  155. textureGatherOffsets(sArray[0], vec2(0.1), constOffsets);
  156. textureGatherOffsets(sArray[0], vec2(0.1), offsets); // ERROR, offset not constant
  157. }
  158. uniform samplerBuffer badSamp1; // ERROR, reserved
  159. uniform isamplerBuffer badSamp2; // ERROR, reserved
  160. uniform usamplerBuffer badSamp3; // ERROR, reserved
  161. uniform writeonly imageBuffer badSamp4; // ERROR, reserved
  162. uniform writeonly iimageBuffer badSamp5; // ERROR, reserved
  163. uniform writeonly uimageBuffer badSamp6; // ERROR, reserved
  164. #extension GL_OES_texture_buffer : enable
  165. #extension GL_EXT_texture_buffer : enable
  166. uniform samplerBuffer noPreSamp1; // ERROR, no default precision
  167. uniform isamplerBuffer noPreSamp2; // ERROR, no default precision
  168. uniform usamplerBuffer noPreSamp3; // ERROR, no default precision
  169. uniform writeonly imageBuffer noPreSamp4; // ERROR, no default precision
  170. uniform writeonly iimageBuffer noPreSamp5; // ERROR, no default precision
  171. uniform writeonly uimageBuffer noPreSamp6; // ERROR, no default precision
  172. precision highp samplerBuffer;
  173. precision highp isamplerBuffer;
  174. precision highp usamplerBuffer;
  175. precision highp imageBuffer;
  176. precision highp iimageBuffer;
  177. precision highp uimageBuffer;
  178. #ifdef GL_OES_texture_buffer
  179. uniform samplerBuffer bufSamp1;
  180. uniform isamplerBuffer bufSamp2;
  181. uniform usamplerBuffer bufSamp3;
  182. #endif
  183. #ifdef GL_EXT_texture_buffer
  184. uniform writeonly imageBuffer bufSamp4;
  185. uniform writeonly iimageBuffer bufSamp5;
  186. uniform writeonly uimageBuffer bufSamp6;
  187. #endif
  188. void bufferT()
  189. {
  190. highp int s1 = textureSize(bufSamp1);
  191. highp int s2 = textureSize(bufSamp2);
  192. highp int s3 = textureSize(bufSamp3);
  193. highp int s4 = imageSize(bufSamp4);
  194. highp int s5 = imageSize(bufSamp5);
  195. highp int s6 = imageSize(bufSamp6);
  196. highp vec4 f1 = texelFetch(bufSamp1, s1);
  197. highp ivec4 f2 = texelFetch(bufSamp2, s2);
  198. highp uvec4 f3 = texelFetch(bufSamp3, s3);
  199. }
  200. uniform writeonly imageCubeArray badCA1; // ERROR, reserved
  201. uniform writeonly iimageCubeArray badCA2; // ERROR, reserved
  202. uniform writeonly uimageCubeArray badCA3; // ERROR, reserved
  203. uniform samplerCubeArray badCA4; // ERROR, reserved
  204. uniform samplerCubeArrayShadow badCA5; // ERROR, reserved
  205. uniform isamplerCubeArray badCA6; // ERROR, reserved
  206. uniform usamplerCubeArray badCA7; // ERROR, reserved
  207. #extension GL_OES_texture_cube_map_array : enable
  208. uniform writeonly imageCubeArray noPreCA1; // ERROR, no default precision
  209. uniform writeonly iimageCubeArray noPreCA2; // ERROR, no default precision
  210. uniform writeonly uimageCubeArray noPreCA3; // ERROR, no default precision
  211. uniform samplerCubeArray noPreCA4; // ERROR, no default precision
  212. uniform samplerCubeArrayShadow noPreCA5; // ERROR, no default precision
  213. uniform isamplerCubeArray noPreCA6; // ERROR, no default precision
  214. uniform usamplerCubeArray noPreCA7; // ERROR, no default precision
  215. precision highp imageCubeArray ;
  216. precision highp iimageCubeArray ;
  217. precision highp uimageCubeArray ;
  218. precision highp samplerCubeArray ;
  219. precision highp samplerCubeArrayShadow;
  220. precision highp isamplerCubeArray ;
  221. precision highp usamplerCubeArray ;
  222. uniform writeonly imageCubeArray CA1;
  223. uniform writeonly iimageCubeArray CA2;
  224. uniform writeonly uimageCubeArray CA3;
  225. layout(rgba16f) uniform readonly imageCubeArray rCA1;
  226. layout(rgba32i) uniform readonly iimageCubeArray rCA2;
  227. layout(r32ui) uniform readonly uimageCubeArray rCA3;
  228. #ifdef GL_OES_texture_cube_map_array
  229. uniform samplerCubeArray CA4;
  230. uniform samplerCubeArrayShadow CA5;
  231. uniform isamplerCubeArray CA6;
  232. uniform usamplerCubeArray CA7;
  233. #endif
  234. void CAT()
  235. {
  236. highp ivec3 s4 = textureSize(CA4, 1);
  237. highp ivec3 s5 = textureSize(CA5, 1);
  238. highp ivec3 s6 = textureSize(CA6, 1);
  239. highp ivec3 s7 = textureSize(CA7, 1);
  240. highp vec4 t4 = texture(CA4, vec4(0.5));
  241. highp float t5 = texture(CA5, vec4(0.5), 3.0);
  242. highp ivec4 t6 = texture(CA6, vec4(0.5));
  243. highp uvec4 t7 = texture(CA7, vec4(0.5));
  244. highp vec4 L4 = textureLod(CA4, vec4(0.5), 0.24);
  245. highp ivec4 L6 = textureLod(CA6, vec4(0.5), 0.26);
  246. highp uvec4 L7 = textureLod(CA7, vec4(0.5), 0.27);
  247. highp vec4 g4 = textureGrad(CA4, vec4(0.5), vec3(0.1), vec3(0.2));
  248. highp ivec4 g6 = textureGrad(CA6, vec4(0.5), vec3(0.1), vec3(0.2));
  249. highp uvec4 g7 = textureGrad(CA7, vec4(0.5), vec3(0.1), vec3(0.2));
  250. highp vec4 gath4 = textureGather(CA4, vec4(0.5));
  251. highp vec4 gathC4 = textureGather(CA4, vec4(0.5), 2);
  252. highp ivec4 gath6 = textureGather(CA6, vec4(0.5));
  253. highp ivec4 gathC6 = textureGather(CA6, vec4(0.5), 1);
  254. highp uvec4 gath7 = textureGather(CA7, vec4(0.5));
  255. highp uvec4 gathC7 = textureGather(CA7, vec4(0.5), 0);
  256. highp vec4 gath5 = textureGather(CA5, vec4(0.5), 2.5);
  257. highp ivec3 s1 = imageSize(CA1);
  258. highp ivec3 s2 = imageSize(CA2);
  259. highp ivec3 s3 = imageSize(CA3);
  260. imageStore(CA1, s3, vec4(1));
  261. imageStore(CA2, s3, ivec4(1));
  262. imageStore(CA3, s3, uvec4(1));
  263. highp vec4 cl1 = imageLoad(rCA1, s3);
  264. highp ivec4 cl2 = imageLoad(rCA2, s3);
  265. highp uvec4 cl3 = imageLoad(rCA3, s3);
  266. }
  267. uniform sampler2DMSArray bad2DMS; // ERROR, reserved
  268. uniform isampler2DMSArray bad2DMSi; // ERROR, reserved
  269. uniform usampler2DMSArray bad2DMSu; // ERROR, reserved
  270. #extension GL_OES_texture_storage_multisample_2d_array : enable
  271. #ifdef GL_OES_texture_storage_multisample_2d_array
  272. uniform sampler2DMSArray noPrec2DMS; // ERROR, no default
  273. uniform isampler2DMSArray noPrec2DMSi; // ERROR, no default
  274. uniform usampler2DMSArray noPrec2DMSu; // ERROR, no default
  275. #endif
  276. precision highp sampler2DMSArray;
  277. precision highp isampler2DMSArray;
  278. precision highp usampler2DMSArray;
  279. uniform sampler2DMSArray samp2DMSA;
  280. uniform isampler2DMSArray samp2DMSAi;
  281. uniform usampler2DMSArray samp2DMSAu;
  282. void MSA()
  283. {
  284. vec4 tf = texelFetch(samp2DMSA, ivec3(5), 2);
  285. ivec4 tfi = texelFetch(samp2DMSAi, ivec3(5), 2);
  286. uvec4 tfu = texelFetch(samp2DMSAu, ivec3(5), 2);
  287. ivec3 tfs = textureSize(samp2DMSA);
  288. ivec3 tfsi = textureSize(samp2DMSAi);
  289. ivec3 tfsb = textureSize(samp2DMSAi, 4); // ERROR, no lod
  290. ivec3 tfsu = textureSize(samp2DMSAu);
  291. }
  292. #ifdef GL_OES_shader_image_atomic
  293. #extension GL_OES_shader_image_atomic : enable
  294. #endif
  295. uniform layout(r32f) highp image2D im2Df;
  296. uniform layout(r32ui) highp uimage2D im2Du;
  297. uniform layout(r32i) highp iimage2D im2Di;
  298. uniform ivec2 P;
  299. void goodImageAtom()
  300. {
  301. float datf;
  302. int dati;
  303. uint datu;
  304. imageAtomicAdd( im2Di, P, dati);
  305. imageAtomicAdd( im2Du, P, datu);
  306. imageAtomicMin( im2Di, P, dati);
  307. imageAtomicMin( im2Du, P, datu);
  308. imageAtomicMax( im2Di, P, dati);
  309. imageAtomicMax( im2Du, P, datu);
  310. imageAtomicAnd( im2Di, P, dati);
  311. imageAtomicAnd( im2Du, P, datu);
  312. imageAtomicOr( im2Di, P, dati);
  313. imageAtomicOr( im2Du, P, datu);
  314. imageAtomicXor( im2Di, P, dati);
  315. imageAtomicXor( im2Du, P, datu);
  316. imageAtomicExchange(im2Di, P, dati);
  317. imageAtomicExchange(im2Du, P, datu);
  318. imageAtomicExchange(im2Df, P, datf);
  319. imageAtomicCompSwap(im2Di, P, 3, dati);
  320. imageAtomicCompSwap(im2Du, P, 5u, datu);
  321. }
  322. sample out vec4 colorSampInBad; // ERROR, reserved
  323. #extension GL_OES_shader_multisample_interpolation : enable
  324. sample out vec4 colorSample;
  325. flat sample out vec4 colorfsi;
  326. sample out vec3 sampInArray[4];
  327. in vec4 inv4;
  328. void badInterp()
  329. {
  330. interpolateAtCentroid(inv4); // ERROR, wrong stage
  331. interpolateAtSample(inv4, 1); // ERROR, need extension
  332. interpolateAtOffset(inv4, vec2(0.2)); // ERROR, need extension
  333. }