310.frag 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. #version 310 es
  2. highp float nodef3(float); // ERROR, no default precision
  3. precision mediump float;
  4. precision highp usampler2D;
  5. precision highp sampler2D;
  6. precision highp isampler2DArray;
  7. layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; // ERROR, not supported
  8. layout(location = 2) in vec3 v3;
  9. layout(location = 2) in mat4 yi; // ERROR, locations conflict with xi
  10. uniform sampler2D arrayedSampler[5];
  11. uniform usampler2D usamp2d;
  12. uniform usampler2DRect samp2dr; // ERROR, reserved
  13. uniform isampler2DArray isamp2DA;
  14. in vec2 c2D;
  15. uniform int i;
  16. void main()
  17. {
  18. vec4 v = texture(arrayedSampler[i], c2D); // ERROR
  19. ivec2 offsets[4];
  20. const ivec2 constOffsets[4] = ivec2[4](ivec2(1,2), ivec2(3,4), ivec2(15,16), ivec2(-2,0));
  21. uvec4 uv4 = textureGatherOffsets(samp2dr, c2D, offsets, 2); // ERROR, not supported
  22. vec4 v4 = textureGather(arrayedSampler[0], c2D);
  23. ivec4 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 3);
  24. iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), i); // ERROR, last argument not const
  25. iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 4); // ERROR, last argument out of range
  26. iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 1+2);
  27. iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(0.5));
  28. iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(i)); // ERROR, offset not constant
  29. }
  30. out vec4 outp;
  31. void foo23()
  32. {
  33. const ivec2[3] offsets = ivec2[3](ivec2(1,2), ivec2(3,4), ivec2(15,16));
  34. textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), ivec2(c2D)); // ERROR, offset not constant
  35. textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), offsets[1]);
  36. textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), offsets[2]); // ERROR, offset out of range
  37. textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), ivec2(-10, 20)); // ERROR, offset out of range
  38. if (gl_HelperInvocation)
  39. ++outp;
  40. int sum = gl_MaxVertexImageUniforms +
  41. gl_MaxFragmentImageUniforms +
  42. gl_MaxComputeImageUniforms +
  43. gl_MaxCombinedImageUniforms +
  44. gl_MaxCombinedShaderOutputResources;
  45. bool b1, b2, b3, b;
  46. b1 = mix(b2, b3, b);
  47. uvec3 um3 = mix(uvec3(i), uvec3(i), bvec3(b));
  48. ivec4 im4 = mix(ivec4(i), ivec4(i), bvec4(b));
  49. }
  50. layout(binding=3) uniform sampler2D s1;
  51. layout(binding=3) uniform sampler2D s2; // ERROR: overlapping bindings? Don't see that in the 310 spec.
  52. highp layout(binding=2) uniform writeonly image2D i2D;
  53. layout(binding=4) uniform readonly image3D i3D; // ERROR, no default precision
  54. layout(binding=5) uniform imageCube iCube; // ERROR, no default precision
  55. layout(binding=6) uniform image2DArray i2DA; // ERROR, no default precision
  56. layout(binding=6) uniform coherent volatile restrict image2D i2Dqualified; // ERROR, no default precision
  57. layout(binding = 1) uniform bb {
  58. int foo;
  59. layout(binding = 2) float f; // ERROR
  60. } bbi;
  61. in centroid vec4 centroidIn;
  62. layout(location = 200000) uniform vec4 bigl; // ERROR, location too big
  63. layout(early_fragment_tests) in;
  64. layout(location = 40) out vec4 bigout1; // ERROR, too big
  65. layout(location = 40) out vec4 bigout2; // ERROR, overlap
  66. layout(location = -2) out vec4 neg; // ERROR, negative
  67. layout(std430) buffer b430 {
  68. int i;
  69. } b430i;
  70. layout(shared) uniform bshar {
  71. int i;
  72. } bshari;
  73. in smooth vec4 smoothIn;
  74. in flat int flatIn;
  75. uniform sampler2DMS s2dms; // ERROR, no default precision qualifier
  76. void foots()
  77. {
  78. highp ivec2 v2 = textureSize(s1, 2);
  79. highp ivec3 v3 = textureSize(isamp2DA, 3);
  80. v2 = textureSize(s2dms);
  81. v2 = imageSize(i2D);
  82. v3 = imageSize(i3D);
  83. v2 = imageSize(iCube);
  84. v3 = imageSize(i2DA);
  85. v2 = imageSize(i2Dqualified);
  86. }
  87. out bool bout; // ERROR
  88. highp out image2D imageOut; // ERROR
  89. out mat2x3 mout; // ERROR
  90. in bool inb; // ERROR
  91. in sampler2D ino; // ERROR
  92. in float ina[4];
  93. in float inaa[4][2]; // ERROR
  94. struct S { float f; };
  95. in S ins;
  96. in S[4] inasa; // ERROR
  97. in S insa[4]; // ERROR
  98. struct SA { float f[4]; };
  99. in SA inSA; // ERROR
  100. struct SS { float f; S s; };
  101. in SS inSS; // ERROR
  102. #ifndef GL_EXT_shader_io_blocks
  103. #error GL_EXT_shader_io_blocks not defined
  104. #endif
  105. #extension GL_EXT_shader_io_blocks : enable
  106. out outbname { int a; } outbinst; // ERROR, not out block in fragment shader
  107. in inbname {
  108. int a;
  109. vec4 v;
  110. struct { int b; } s; // ERROR, nested struct definition
  111. } inbinst;
  112. in inbname2 {
  113. layout(location = 12) int aAnon;
  114. layout(location = 13) centroid in vec4 vAnon;
  115. };
  116. in layout(location = 13) vec4 aliased; // ERROR, aliased
  117. in inbname2 { // ERROR, reuse of block name
  118. int aAnon;
  119. centroid in vec4 vAnon;
  120. };
  121. in badmember { // ERROR, aAnon already in global scope
  122. int aAnon;
  123. };
  124. int inbname; // ERROR, redefinition of block name
  125. vec4 vAnon; // ERROR, anon in global scope; redefinition
  126. in arrayed {
  127. float f;
  128. } arrayedInst[4];
  129. void fooIO()
  130. {
  131. vec4 v = inbinst.v + vAnon;
  132. v *= arrayedInst[2].f;
  133. v *= arrayedInst[i].f;
  134. }
  135. in vec4 gl_FragCoord;
  136. layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; // ERROR, non-ES
  137. layout(early_fragment_tests) in;
  138. out float gl_FragDepth;
  139. layout(depth_any) out float gl_FragDepth; // ERROR, non-ES
  140. void foo_IO()
  141. {
  142. gl_FragDepth = 0.2; // ERROR, early_fragment_tests declared
  143. gl_Layer; // ERROR, not present
  144. gl_PrimitiveID; // ERROR, not present
  145. bool f = gl_FrontFacing;
  146. }
  147. out float gl_FragDepth;
  148. #extension GL_OES_geometry_shader : enable
  149. void foo_GS()
  150. {
  151. highp int l = gl_Layer;
  152. highp int p = gl_PrimitiveID;
  153. }
  154. in vec2 inf, ing;
  155. uniform ivec2 offsets[4];
  156. uniform sampler2D sArray[4];
  157. uniform int sIndex;
  158. layout(binding = 0) uniform atomic_uint auArray[2];
  159. uniform ubName { int i; } ubInst[4];
  160. buffer bbName { int i; } bbInst[4];
  161. highp uniform writeonly image2D iArray[5];
  162. const ivec2 constOffsets[4] = ivec2[4](ivec2(0.1), ivec2(0.2), ivec2(0.3), ivec2(0.4));
  163. void pfooBad()
  164. {
  165. precise vec2 h; // ERROR reserved
  166. h = fma(inf, ing, h); // ERROR, not available
  167. textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf)); // ERROR, offset not constant
  168. textureGatherOffsets(sArray[0], vec2(0.1), constOffsets); // ERROR, not available
  169. }
  170. #extension GL_OES_gpu_shader5 : enable
  171. void pfoo()
  172. {
  173. precise vec2 h;
  174. h = fma(inf, ing, h);
  175. textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf));
  176. textureGatherOffsets(sArray[0], vec2(0.1), constOffsets);
  177. textureGatherOffsets(sArray[0], vec2(0.1), offsets); // ERROR, offset not constant
  178. }
  179. #extension GL_EXT_texture_cube_map_array : enable
  180. precision highp imageCubeArray ;
  181. precision highp iimageCubeArray ;
  182. precision highp uimageCubeArray ;
  183. precision highp samplerCubeArray ;
  184. precision highp samplerCubeArrayShadow;
  185. precision highp isamplerCubeArray ;
  186. precision highp usamplerCubeArray ;
  187. uniform writeonly imageCubeArray CA1;
  188. uniform writeonly iimageCubeArray CA2;
  189. uniform writeonly uimageCubeArray CA3;
  190. #ifdef GL_EXT_texture_cube_map_array
  191. uniform samplerCubeArray CA4;
  192. uniform samplerCubeArrayShadow CA5;
  193. uniform isamplerCubeArray CA6;
  194. uniform usamplerCubeArray CA7;
  195. #endif
  196. void CAT()
  197. {
  198. highp vec4 b4 = texture(CA4, vec4(0.5), 0.24);
  199. highp ivec4 b6 = texture(CA6, vec4(0.5), 0.26);
  200. highp uvec4 b7 = texture(CA7, vec4(0.5), 0.27);
  201. }
  202. void badSample()
  203. {
  204. lowp int a1 = gl_SampleID; // ERROR, need extension
  205. mediump vec2 a2 = gl_SamplePosition; // ERROR, need extension
  206. highp int a3 = gl_SampleMaskIn[0]; // ERROR, need extension
  207. gl_SampleMask[0] = a3; // ERROR, need extension
  208. mediump int n = gl_NumSamples; // ERROR, need extension
  209. }
  210. #ifdef GL_OES_sample_variables
  211. #extension GL_OES_sample_variables : enable
  212. #endif
  213. void goodSample()
  214. {
  215. lowp int a1 = gl_SampleID;
  216. mediump vec2 a2 = gl_SamplePosition;
  217. highp int a3 = gl_SampleMaskIn[0];
  218. gl_SampleMask[0] = a3;
  219. mediump int n1 = gl_MaxSamples;
  220. mediump int n2 = gl_NumSamples;
  221. }
  222. uniform layout(r32f) highp image2D im2Df;
  223. uniform layout(r32ui) highp uimage2D im2Du;
  224. uniform layout(r32i) highp iimage2D im2Di;
  225. uniform ivec2 P;
  226. void badImageAtom()
  227. {
  228. float datf;
  229. int dati;
  230. uint datu;
  231. imageAtomicAdd( im2Di, P, dati); // ERROR, need extension
  232. imageAtomicAdd( im2Du, P, datu); // ERROR, need extension
  233. imageAtomicMin( im2Di, P, dati); // ERROR, need extension
  234. imageAtomicMin( im2Du, P, datu); // ERROR, need extension
  235. imageAtomicMax( im2Di, P, dati); // ERROR, need extension
  236. imageAtomicMax( im2Du, P, datu); // ERROR, need extension
  237. imageAtomicAnd( im2Di, P, dati); // ERROR, need extension
  238. imageAtomicAnd( im2Du, P, datu); // ERROR, need extension
  239. imageAtomicOr( im2Di, P, dati); // ERROR, need extension
  240. imageAtomicOr( im2Du, P, datu); // ERROR, need extension
  241. imageAtomicXor( im2Di, P, dati); // ERROR, need extension
  242. imageAtomicXor( im2Du, P, datu); // ERROR, need extension
  243. imageAtomicExchange(im2Di, P, dati); // ERROR, need extension
  244. imageAtomicExchange(im2Du, P, datu); // ERROR, need extension
  245. imageAtomicExchange(im2Df, P, datf); // ERROR, need extension
  246. imageAtomicCompSwap(im2Di, P, 3, dati); // ERROR, need extension
  247. imageAtomicCompSwap(im2Du, P, 5u, datu); // ERROR, need extension
  248. }
  249. #ifdef GL_OES_shader_image_atomic
  250. #extension GL_OES_shader_image_atomic : enable
  251. #endif
  252. uniform layout(rgba32f) highp image2D badIm2Df; // ERROR, needs readonly or writeonly
  253. uniform layout(rgba8ui) highp uimage2D badIm2Du; // ERROR, needs readonly or writeonly
  254. uniform layout(rgba16i) highp iimage2D badIm2Di; // ERROR, needs readonly or writeonly
  255. void goodImageAtom()
  256. {
  257. float datf;
  258. int dati;
  259. uint datu;
  260. imageAtomicAdd( im2Di, P, dati);
  261. imageAtomicAdd( im2Du, P, datu);
  262. imageAtomicMin( im2Di, P, dati);
  263. imageAtomicMin( im2Du, P, datu);
  264. imageAtomicMax( im2Di, P, dati);
  265. imageAtomicMax( im2Du, P, datu);
  266. imageAtomicAnd( im2Di, P, dati);
  267. imageAtomicAnd( im2Du, P, datu);
  268. imageAtomicOr( im2Di, P, dati);
  269. imageAtomicOr( im2Du, P, datu);
  270. imageAtomicXor( im2Di, P, dati);
  271. imageAtomicXor( im2Du, P, datu);
  272. imageAtomicExchange(im2Di, P, dati);
  273. imageAtomicExchange(im2Du, P, datu);
  274. imageAtomicExchange(im2Df, P, datf);
  275. imageAtomicCompSwap(im2Di, P, 3, dati);
  276. imageAtomicCompSwap(im2Du, P, 5u, datu);
  277. imageAtomicMax(badIm2Di, P, dati); // ERROR, not an allowed layout() on the image
  278. imageAtomicMax(badIm2Du, P, datu); // ERROR, not an allowed layout() on the image
  279. imageAtomicExchange(badIm2Df, P, datf); // ERROR, not an allowed layout() on the image
  280. }
  281. sample in vec4 colorSampInBad; // ERROR, reserved
  282. centroid out vec4 colorCentroidBad; // ERROR
  283. flat out vec4 colorBadFlat; // ERROR
  284. smooth out vec4 colorBadSmooth; // ERROR
  285. noperspective out vec4 colorBadNo; // ERROR
  286. flat centroid in vec2 colorfc;
  287. in float scalarIn;
  288. void badInterp()
  289. {
  290. interpolateAtCentroid(colorfc); // ERROR, need extension
  291. interpolateAtSample(colorfc, 1); // ERROR, need extension
  292. interpolateAtOffset(colorfc, vec2(0.2)); // ERROR, need extension
  293. }
  294. #if defined GL_OES_shader_multisample_interpolation
  295. #extension GL_OES_shader_multisample_interpolation : enable
  296. #endif
  297. sample in vec4 colorSampIn;
  298. sample out vec4 colorSampleBad; // ERROR
  299. flat sample in vec4 colorfsi;
  300. sample in vec3 sampInArray[4];
  301. void interp()
  302. {
  303. float res;
  304. vec2 res2;
  305. vec3 res3;
  306. vec4 res4;
  307. res2 = interpolateAtCentroid(colorfc);
  308. res4 = interpolateAtCentroid(colorSampIn);
  309. res4 = interpolateAtCentroid(colorfsi);
  310. res = interpolateAtCentroid(scalarIn);
  311. res3 = interpolateAtCentroid(sampInArray); // ERROR
  312. res3 = interpolateAtCentroid(sampInArray[2]);
  313. res2 = interpolateAtCentroid(sampInArray[2].xy); // ERROR
  314. res3 = interpolateAtSample(sampInArray, 1); // ERROR
  315. res3 = interpolateAtSample(sampInArray[i], 0);
  316. res2 = interpolateAtSample(sampInArray[2].xy, 2); // ERROR
  317. res = interpolateAtSample(scalarIn, 1);
  318. res3 = interpolateAtOffset(sampInArray, vec2(0.2)); // ERROR
  319. res3 = interpolateAtOffset(sampInArray[2], vec2(0.2));
  320. res2 = interpolateAtOffset(sampInArray[2].xy, vec2(0.2)); // ERROR, no swizzle
  321. res = interpolateAtOffset(scalarIn + scalarIn, vec2(0.2)); // ERROR, no binary ops other than dereference
  322. res = interpolateAtOffset(scalarIn, vec2(0.2));
  323. float f;
  324. res = interpolateAtCentroid(f); // ERROR, not interpolant
  325. res4 = interpolateAtSample(outp, 0); // ERROR, not interpolant
  326. }
  327. layout(blend_support_softlight) out; // ERROR, need extension
  328. #ifdef GL_KHR_blend_equation_advanced
  329. #extension GL_KHR_blend_equation_advanced : enable
  330. #endif
  331. layout(blend_support_multiply) out;
  332. layout(blend_support_screen) out;
  333. layout(blend_support_overlay) out;
  334. layout(blend_support_darken, blend_support_lighten) out;
  335. layout(blend_support_colordodge) layout(blend_support_colorburn) out;
  336. layout(blend_support_hardlight) out;
  337. layout(blend_support_softlight) out;
  338. layout(blend_support_difference) out;
  339. layout(blend_support_exclusion) out;
  340. layout(blend_support_hsl_hue) out;
  341. layout(blend_support_hsl_saturation) out;
  342. layout(blend_support_hsl_color) out;
  343. layout(blend_support_hsl_luminosity) out;
  344. layout(blend_support_all_equations) out;
  345. layout(blend_support_hsl_luminosity) out; // okay to repeat
  346. layout(blend_support_hsl_luminosity) in; // ERROR, only on "out"
  347. layout(blend_support_hsl_luminosity) out vec4; // ERROR, only on standalone
  348. layout(blend_support_hsl_luminosity) out vec4 badout; // ERROR, only on standalone
  349. layout(blend_support_hsl_luminosity) struct badS {int i;}; // ERROR, only on standalone
  350. layout(blend_support_hsl_luminosity) void blendFoo() { } // ERROR, only on standalone
  351. void blendFoo(layout(blend_support_hsl_luminosity) vec3 v) { } // ERROR, only on standalone
  352. layout(blend_support_flizbit) out; // ERROR, no flizbit
  353. out vec4 outAA[2][2]; // ERROR
  354. void devi()
  355. {
  356. gl_DeviceIndex; // ERROR, no extension
  357. gl_ViewIndex; // ERROR, no extension
  358. }
  359. #ifdef GL_EXT_device_group
  360. #extension GL_EXT_device_group : enable
  361. #endif
  362. #ifdef GL_EXT_device_group
  363. #extension GL_EXT_multiview : enable
  364. #endif
  365. void devie()
  366. {
  367. gl_DeviceIndex;
  368. gl_ViewIndex;
  369. }