yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
a4ea1313
vulkan-sdk-1.4.363.0
1#version 430 2 3#extension GL_3DL_array_objects : enable 4 5int a = 0xffffffff ; // 32 bits, a gets the value -1 6int b = 0xffffffffU ; // ERROR: can't convert uint to int 7uint c = 0xffffffff ; // 32 bits, c gets the value 0xFFFFFFFF 8uint d = 0xffffffffU ; // 32 bits, d gets the value 0xFFFFFFFF 9int e = - 1 ; // the literal is "1", then negation is performed, 10// and the resulting non-literal 32-bit signed 11// bit pattern of 0xFFFFFFFF is assigned, giving e 12// the value of -1. 13uint f = - 1u ; // the literal is "1u", then negation is performed, 14// and the resulting non-literal 32-bit unsigned 15// bit pattern of 0xFFFFFFFF is assigned, giving f 16// the value of 0xFFFFFFFF. 17int g = 3000000000 ; // a signed decimal literal taking 32 bits, 18// setting the sign bit, g gets -1294967296 19int h = 0xA0000000 ; // okay, 32-bit signed hexadecimal 20int i = 5000000000 ; // ERROR: needs more than 32 bits 21int j = 0xFFFFFFFFF ; // ERROR: needs more that 32 bits 22int k = 0x80000000 ; // k gets -2147483648 == 0x80000000 23int l = 2147483648 ; // l gets -2147483648 (the literal set the sign bit) 24 25float fa , fb = 1.5 ; // single-precision floating-point 26double fc , fd = 2.0LF ; // double-precision floating-point 27 28vec2 texcoord1 , texcoord2 ; 29vec3 position ; 30vec4 myRGBA ; 31ivec2 textureLookup ; 32bvec3 less ; 33 34mat2 mat2D ; 35mat3 optMatrix ; 36mat4 view , projection ; 37mat4x4 view ; // an alternate way of declaring a mat4 38mat3x2 m ; // a matrix with 3 columns and 2 rows 39dmat4 highPrecisionMVP ; 40dmat2x4 dm ; 41 42struct light { 43float intensity ; 44vec3 position ; 45} lightVar ; 46 47struct S { float f ; } ; 48 49struct T { 50//S; // Error: anonymous structures disallowed 51//struct { ... }; // Error: embedded structures disallowed 52S s ; // Okay: nested structures with name are allowed 53} ; 54 55float frequencies [ 3 ] ; 56uniform vec4 lightPosition [ 4 ] ; 57light lights [] ; 58const int numLights = 2 ; 59light lights [ numLights ] ; 60 61in vec3 normal ; 62centroid in vec2 TexCoord ; 63invariant centroid in vec4 Color ; 64noperspective in float temperature ; 65flat in vec3 myColor ; 66noperspective centroid in vec2 myTexCoord ; 67 68uniform vec4 lightPosition ; 69uniform vec3 color = vec3 ( 0.7 , 0.7 , 0.2 ) ; // value assigned at link time 70 71in Material { 72smooth in vec4 Color1 ; // legal, input inside in block 73smooth vec4 Color2 ; // legal, 'in' inherited from 'in Material' 74vec2 TexCoordA ; // legal, TexCoord is an input 75uniform float Atten ; // illegal, mismatched storage qualifier 76 77} ; 78 79in Light { 80vec4 LightPos ; 81vec3 LightColor ; 82} ; 83in ColoredTexture { 84vec4 Color ; 85vec2 TexCoord ; 86} Materiala ; // instance name 87vec3 Color ; // different Color than Material.Color 88 89in vec4 gl_FragCoord ; // redeclaration that changes nothing is allowed 90 91// All the following are allowed redeclaration that change behavior 92layout ( origin_upper_left ) in vec4 gl_FragCoord ; 93layout ( pixel_center_integer ) in vec4 gl_FragCoord ; 94layout ( origin_upper_left , pixel_center_integer ) in vec4 gl_FragCoord ; 95 96layout ( early_fragment_tests ) in ; 97 98// compute shader: 99layout ( local_size_x = 32 , local_size_y = 32 ) in ; 100layout ( local_size_x = 8 ) in ; 101 102layout ( location = 3 ) out vec4 color ; 103layout ( location = 3 , index = 1 ) out vec4 factor ; 104layout ( location = 2 ) out vec4 colors [ 3 ] ; 105 106layout ( depth_greater ) out float gl_FragDepth ; 107 108// redeclaration that changes nothing is allowed 109out float gl_FragDepth ; 110 111// assume it may be modified in any way 112layout ( depth_any ) out float gl_FragDepth ; 113 114// assume it may be modified such that its value will only increase 115layout ( depth_greater ) out float gl_FragDepth ; 116 117// assume it may be modified such that its value will only decrease 118layout ( depth_less ) out float gl_FragDepth ; 119 120// assume it will not be modified 121layout ( depth_unchanged ) out float gl_FragDepth ; 122 123in vec4 gl_Color ; // predeclared by the fragment language 124flat in vec4 gl_Color ; // redeclared by user to be flat 125 126 127float [ 5 ] foo ( float [ 5 ]) 128{ 129return float [ 5 ]( 3.4 , 4.2 , 5.0 , 5.2 , 1.1 ) ; 130} 131 132precision highp float ; 133precision highp int ; 134precision mediump int ; 135precision highp float ; 136 137void main () 138{ 139{ 140float a [ 5 ] = float [ 5 ]( 3.4 , 4.2 , 5.0 , 5.2 , 1.1 ) ; 141} 142{ 143float a [ 5 ] = float []( 3.4 , 4.2 , 5.0 , 5.2 , 1.1 ) ; // same thing 144} 145{ 146vec4 a [ 3 ][ 2 ] ; // size-3 array of size-2 array of vec4 147vec4 [ 2 ] a1 [ 3 ] ; // size-3 array of size-2 array of vec4 148vec4 [ 3 ][ 2 ] a2 ; // size-3 array of size-2 array of vec4 149vec4 b [ 2 ] = vec4 [ 2 ]( vec4 ( 0.0 ) , vec4 ( 0.1 )) ; 150vec4 [ 3 ][ 2 ] a3 = vec4 [ 3 ][ 2 ]( b , b , b ) ; // constructor 151void foo ( vec4 [ 3 ][ 2 ]) ; // prototype with unnamed parameter 152vec4 a4 [ 3 ][ 2 ] = { vec4 [ 2 ]( vec4 ( 0.0 ) , vec4 ( 1.0 )) , 153vec4 [ 2 ]( vec4 ( 0.0 ) , vec4 ( 1.0 )) , 154vec4 [ 2 ]( vec4 ( 0.0 ) , vec4 ( 1.0 )) } ; 155} 156{ 157float a [ 5 ] ; 158{ 159float b [] = a ; // b is explicitly size 5 160} 161{ 162float b [ 5 ] = a ; // means the same thing 163} 164{ 165float b [] = float []( 1 , 2 , 3 , 4 , 5 ) ; // also explicitly sizes to 5 166} 167a . length () ; // returns 5 168} 169{ 170vec4 a [ 3 ][ 2 ] ; 171a . length () ; // this is 3 172a [ x ] . length () ; // this is 2 173} 174// for an array b containing a member array a: 175b [ ++ x ] . a . length () ; // b is never dereferenced, but �++x� is evaluated 176 177// for an array s of a shader storage object containing a member array a: 178s [ x ] . a . length () ; // s is dereferenced; x needs to be a valid index 179// 180//All of the following declarations result in a compile-time error. 181//float a[2] = { 3.4, 4.2, 5.0 }; // illegal 182//vec2 b = { 1.0, 2.0, 3.0 }; // illegal 183//mat3x3 c = { vec3(0.0), vec3(1.0), vec3(2.0), vec3(3.0) }; // illegal 184//mat2x2 d = { 1.0, 0.0, 0.0, 1.0 }; // illegal, can't flatten nesting 185//struct { 186// float a; 187// int b; 188//} e = { 1.2, 2, 3 }; // illegal 189 190struct { 191float a ; 192int b ; 193} e = { 1.2 , 2 } ; // legal, all types match 194 195struct { 196float a ; 197int b ; 198} e = { 1 , 3 } ; // legal, first initializer is converted 199 200//All of the following declarations result in a compile-time error. 201//int a = true; // illegal 202//vec4 b[2] = { vec4(0.0), 1.0 }; // illegal 203//mat4x2 c = { vec3(0.0), vec3(1.0) }; // illegal 204 205//struct S1 { 206// vec4 a; 207// vec4 b; 208//}; 209 210//struct { 211// float s; 212// float t; 213//} d[] = { S1(vec4(0.0), vec4(1.1)) }; // illegal 214 215{ 216float a [] = float []( 3.4 , 4.2 , 5.0 , 5.2 , 1.1 ) ; 217float b [] = { 3.4 , 4.2 , 5.0 , 5.2 , 1.1 } ; 218float c [] = a ; // c is explicitly size 5 219float d [ 5 ] = b ; // means the same thing 220} 221{ 222const vec3 zAxis = vec3 ( 0.0 , 0.0 , 1.0 ) ; 223const float ceiling = a + b ; // a and b not necessarily constants 224} 225{ 226in vec4 position ; 227in vec3 normal ; 228in vec2 texCoord [ 4 ] ; 229} 230{ 231lowp float color ; 232out mediump vec2 P ; 233lowp ivec2 foo ( lowp mat3 ) ; 234highp mat4 m ; 235} 236 237}