yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
90afccfb
main
1#version 430 2 3const int a = 1 ; 4const int b = 2 ; 5const int c = a + b ;// 3 6const int d = c - a ;// 2 7const float e = float (d );// 2.0 8const float f = e * float (c );// 6.0 9const float g = f /float (d );// 3.0 10 11const vec2 pytho = vec2 (3.0 ,4.0 ); 12 13in vec4 inv ; 14out vec4 FragColor ; 15out vec2 out2 ; 16out vec4 out3 ; 17out vec4 out4 ; 18out ivec4 out5 ; 19out vec3 out6 ; 20out vec4 out7 ; 21out vec4 out8 ; 22out vec4 out9 ; 23out vec4 out10 ; 24out vec4 out11 ; 25out ivec2 out12 ; 26out uvec3 out13 ; 27 28void main () 29{ 30vec4 dx = dFdx (inv ); 31const ivec4 v = ivec4 (a ,b ,c ,d ); 32vec4 array2 [v .y ];// 2 33const ivec4 u = ~v ; 34 35const float h = degrees (g );// 171.88 36 37FragColor = vec4 (e ,f ,g ,h );// 2, 6, 3, 171.88 38 39vec4 array3 [c ];// 3 40vec4 arrayMax [int (max (float (array2 .length ()),float (array3 .length ())))]; 41vec4 arrayMin [int (min (float (array2 .length ()),float (array3 .length ())))]; 42FragColor = vec4 (arrayMax .length (),arrayMin .length (),sin (3.14 ),cos (3.14 ));// 3, 2, .00159, -.999 43out2 = length (pytho )+ normalize (pytho )+ dFdx (pytho )+ dFdy (pytho )+ fwidth (pytho );// 5+3/5, 5+4/5 44out3 = vec4 (exp (3.0 ),log (10.0 ),exp2 (4.0 ),log2 (256.0 ));// 20.08, 2.3, 16, 8 45out4 = vec4 (sqrt (100.0 ),inversesqrt (100.0 ),abs (-4.7 ),abs (10.9 ));// 10, .1, 4.7, 10.9 46out5 = ivec4 (abs (-8 )+ sign (0 ),abs (17 ),sign (-12 ),sign (9 ));// 8, 17, -1, 1 47out6 = vec3 (sign (-8.8 ),sign (18.0 ),sign (0.0 ));// -1.0, 1.0, 0.0 48out7 = vec4 (floor (4.2 ),ceil (-4.1 ),trunc (5.9 ),trunc (-5.9 ));// 4, -4, 5, -5 49out8 = vec4 (round (4.4 ),round (4.6 ),roundEven (4.5 ),roundEven (-5.5 ));// 4, 5, 4, -6 50out9 = vec4 (roundEven (7.5 ),roundEven (-4.5 ),fract (2.345 ),fract (-2.6 ));// 8, -4, .345, 0.4 51out10 = vec4 (isinf (4.0 /0.0 ),isinf (-3.0 /0.0 ),isinf (0.0 /0.0 ),isinf (-93048593405938405938405.0 ));// true, true, false, false -> 1.0, 1.0, 0.0, 0.0 52out11 = vec4 (isnan (4.0 /0.0 ),isnan (-3.0 /0.0 ),isnan (0.0 /0.0 ),isnan (-93048593405938405938405.0 ));// false, false, true, false -> 0.0, 1.0, 0.0, 0.0 53out11 = vec4 (tan (0.8 ),atan (1.029 ),atan (8.0 ,10.0 ),atan (10000.0 ));// 1.029, 0.8, 0.6747, 1.57 54out11 = vec4 (asin (0.0 ),asin (0.5 ),acos (0.0 ),acos (0.5 ));// 0.0, .523599, 1.57, 1.047 55 56const vec4 v1 = vec4 (1.0 ,0.0 ,0.5 ,-0.2 ); 57const vec4 v2 = vec4 (0.2 ,0.3 ,0.4 ,0.5 ); 58out11 = atan (v1 ,v2 );// 1.373401, 0.0, 0.896055, -0.380506 59 60const ivec2 v3 = ivec2 (15.0 ,17.0 ); 61const ivec2 v4 = ivec2 (17.0 ,15.0 ); 62out12 = min (v3 ,16 );// 15, 16 63out12 = max (v3 ,v4 );// 17, 17 64out2 = pow (vec2 (v3 ),vec2 (2.5 ,3.0 ));// 871.4, 4913 65out13 = clamp (uvec3 (1 ,20 ,50 ),10u ,30u );// 10, 20, 30 66out2 = mix (vec2 (3.0 ,4.0 ),vec2 (5.0 ,6.0 ),bvec2 (false, true));// 3.0, 6.0 67out2 = mix (vec2 (3.0 ,4.0 ),vec2 (5.0 ,6.0 ),0.25 );// 3.5, 4.5 68out2 = step (0.5 ,vec2 (0.2 ,0.6 ));// 0.0, 1.0 69out11 = smoothstep (50.0 ,60.0 ,vec4 (40.0 ,51.0 ,55.0 ,70.0 ));// 0.0, 0.028, 0.5, 1.0 70out11 = vec4 (sinh (1.0 ),cosh (1.0 ),tanh (1.0 ),sinh (0.0 ));// 1.175201, 1.543081, 0.761594, 0.0 71out11 = vec4 (asinh (1.0 ),acosh (1.0 ),atanh (0.5 ),acosh (2.0 ));// 0.881374, 0.0, 0.549306, 1.316958 72out12 = ivec2 (floatBitsToInt (1.0 ),floatBitsToInt (-2.0 ));// 1065353216, -1073741824 73out13 = uvec3 (floatBitsToUint (1.0 ),floatBitsToUint (0.0 ),floatBitsToUint (-0.0 ));// 1065353216, 0, 2147483648 74out2 = vec2 (intBitsToFloat (1065353216 ),uintBitsToFloat (3221225472u ));// 1.0, -2.0 75} 76 77const struct S { 78vec3 v3 ; 79ivec2 iv2 ; 80mat2x4 m ; 81}s = S (vec3 (3.0 ),ivec2 (3 ,a + b ),mat2x4 (1.0 ,2.0 ,3.0 ,4.0 ,5.0 ,6.0 ,7.0 ,8.0 )); 82 83void foo () 84{ 85float a [s .iv2 .y ];// 3 element array 86a [0 ]= s .m [1 ].z ;// 7.0 87b %0 ;// int 88b /0 ; 89e /0 ;- e /0 ;0.0 /0.0 ; 90const uint ua = 5 ; 91const uvec2 ub = uvec2 (6 ,7 ); 92const uint uc = 8 ; 93ub %4u ; 940u %uc ; 95ub %0u ; 96} 97 98const mat2 m2 = mat2 (2 ,3 ,4 ,5 ); 99const mat3 m3 = mat3 (m2 ); 100const int mc = int (m3 [2 ][2 ]); 101float a1 [mc ]; 102float a2 [int (m3 [2 ][1 ])+ 2 ];// size 2 103float a3 [int (m3 [1 ][0 ])];// size 4 104const vec2 v2 = vec2 (1 ,2 ); 105const vec3 v3 = vec3 (3 ,4 ,5 ); 106float a4 [uint (mat3 (v2 ,v3 ,v2 ,v2 )[2 ][2 ])];// size 2 107 108void foo2 () 109{ 110a1 [0 ];// array size 1 111a2 [0 ];// array size 2 112a3 [0 ];// array size 4 113a4 [0 ];// array size 2 114v2 [-1 ];// ERROR 115v3 [4 ];// ERROR 116m3 [0 ][-2 ];// ERROR 117m2 [-1 ][1 ];// ERROR 118m3 [1 ][3 ];// ERROR 119m3 [3 ][1 ];// ERROR 120int p ; 121p = -2147483647 /-1 ; 122p = -2147483648 /-1 ; 123p = 2147483647 /-1 ; 124float f = vec4 (7.8 < 2.4 ?-1.333 :1.444 ).a ; 125f = vec4 (inv .x < 2.4 ?-1.0 :1.0 ).a ;// not folded, ensuring no propagation 126} 127 128const mat2 mm2 = mat2 (1.0 ,2.0 ,3.0 ,4.0 ); 129const mat3x2 mm32 = mat3x2 (10.0 ,11.0 ,12.0 ,13.0 ,14.0 ,15.0 ); 130const mat2 m22 = mat2 (vec4 (1.0 ,2.0 ,3.0 ,4.0 )); 131const mat3x4 mm34 = mat3x4 (7.0 ); 132const vec4 mv4 = vec4 (m22 ); 133 134void foo3 () 135{ 136mat3x2 r32 = mm2 * mm32 ; 137} 138 139struct cag { 140int i ; 141float f ; 142bool b ; 143}; 144const cag a0 [3 ]= cag [3 ](cag (3 ,2.0 , true),cag (1 ,5.0 , true),cag (1 ,9.0 , false)); 145 146void foo4 () 147{ 148int a = int (a0 [2 ].f ); 149} 150 151const bool cval1 = all (bvec4 (true, true, true, true)); 152const bool cval2 = all (bvec4 (false, false, false, false)); 153const bool cval3 = all (bvec4 (true, true, false, true)); 154const bool cval4 = any (bvec4 (true, true, true, true)); 155const bool cval5 = any (bvec4 (false, false, false, false)); 156const bool cval6 = any (bvec4 (false, true, false, false));