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