yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
08d61df0
16.6.0
1#version 430 2 3#extension GL_3DL_array_objects : enable 4 5out Vertex { 6vec4 Position ; // API transform/feedback will use �Vertex.Position� 7vec2 Texture ; 8} Coords ; // shader will use �Coords.Position� 9 10out Vertex2 { 11vec4 Color ; // API will use �Color� 12} ; 13 14uniform Transform { // API uses �Transform[2]� to refer to instance 2 15mat4 ModelViewMatrix ; 16mat4 ModelViewProjectionMatrix ; 17vec4 a [] ; // array will get implicitly sized 18float Deformation ; 19} transforms [ 4 ] ; 20 21layout ( location = 3 ) in vec4 normal ; 22layout ( location = 6 ) in vec4 colors [ 3 ] ; 23layout ( location = 9 ) in mat4 transforms2 [ 2 ] ; 24 25layout ( location = 3 ) struct S { 26vec3 a1 ; 27mat2 b ; 28vec4 c [ 2 ] ; 29} s ; 30 31layout ( triangles , invocations = 6 ) in ; 32 33layout ( lines ) in ; // legal for Color2, input size is 2, matching Color2 34 35layout ( triangle_strip , max_vertices = 60 ) out ; // order does not matter 36layout ( max_vertices = 60 ) out ; // redeclaration okay 37layout ( triangle_strip ) out ; // redeclaration okay 38//layout(points) out; // error, contradicts triangle_strip 39//layout(max_vertices = 30) out; // error, contradicts 60 40 41layout ( stream = 1 ) out ; 42 43layout ( stream = 1 ) out ; // default is now stream 1 44out vec4 var1 ; // var1 gets default stream (1) 45layout ( stream = 2 ) out Block1 { // "Block1" belongs to stream 2 46layout ( stream = 2 ) vec4 var2 ; // redundant block member stream decl 47layout ( stream = 3 ) vec2 var3 ; // ILLEGAL (must match block stream) 48vec3 var4 ; // belongs to stream 2 49} ; 50layout ( stream = 0 ) out ; // default is now stream 0 51out vec4 var5 ; // var5 gets default stream (0) 52out Block2 { // "Block2" gets default stream (0) 53vec4 var6 ; 54} ; 55layout ( stream = 3 ) out vec4 var7 ; // var7 belongs to stream 3 56 57layout ( shared , column_major ) uniform ; 58layout ( shared , column_major ) buffer ; 59 60layout ( row_major , column_major ) 61 62layout ( shared , row_major ) uniform ; // default is now shared and row_major 63 64layout ( std140 ) uniform Transform2 { // layout of this block is std140 65mat4 M1 ; // row_major 66layout ( column_major ) mat4 M2 ; // column major 67mat3 N1 ; // row_major 68} ; 69 70layout ( column_major ) uniform T3 { // shared and column_major 71mat4 M13 ; // column_major 72layout ( row_major ) mat4 m14 ; // row major 73mat3 N12 ; // column_major 74} ; 75 76// in one compilation unit... 77layout ( binding = 3 ) uniform sampler2D s17 ; // s bound to unit 3 78 79// in another compilation unit... 80uniform sampler2D s17 ; // okay, s still bound at 3 81 82// in another compilation unit... 83//layout(binding=4) uniform sampler2D s; // ERROR: contradictory bindings 84 85layout ( binding = 2 , offset = 4 ) uniform atomic_uint a2 ; 86 87layout ( binding = 2 ) uniform atomic_uint bar ; 88 89layout ( binding = 2 , offset = 4 ) uniform atomic_uint ; 90 91layout ( binding = 2 ) uniform atomic_uint bar ; // offset is 4 92layout ( offset = 8 ) uniform atomic_uint bar23 ; // error, no default binding 93 94layout ( binding = 3 , offset = 4 ) uniform atomic_uint a2 ; // offset = 4 95layout ( binding = 2 ) uniform atomic_uint b2 ; // offset = 0 96layout ( binding = 3 ) uniform atomic_uint c2 ; // offset = 8 97layout ( binding = 2 ) uniform atomic_uint d2 ; // offset = 4 98 99//layout (offset=4) // error, must include binding 100//layout (binding=1, offset=0) a; // okay 101//layout (binding=2, offset=0) b; // okay 102//layout (binding=1, offset=0) c; // error, offsets must not be shared 103// // between a and c 104//layout (binding=1, offset=2) d; // error, overlaps offset 0 of a 105 106flat in vec4 gl_FrontColor ; // input to geometry shader, no �gl_in[]� 107flat out vec4 gl_FrontColor ; // output from geometry shader 108 109invariant gl_Position ; // make existing gl_Position be invariant 110 111out vec3 ColorInv ; 112invariant ColorIvn ; // make existing Color be invariant 113 114invariant centroid out vec3 Color4 ; 115precise out vec4 position ; 116 117out vec3 Color5 ; 118precise Color5 ; // make existing Color be precise 119in vec4 a , b , c , d ; 120precise out vec4 v ; 121 122coherent buffer Block { 123readonly vec4 member1 ; 124vec4 member2 ; 125} ; 126 127buffer Block2a { 128coherent readonly vec4 member1A ; 129coherent vec4 member2A ; 130} ; 131 132shared vec4 shv ; 133 134vec4 funcA ( restrict image2D a ) { } 135 136vec4 funcB ( image2D a ) { } 137layout ( rgba32f ) uniform image2D img1 ; 138layout ( rgba32f ) coherent uniform image2D img2 ; 139 140float func ( float e , float f , float g , float h ) 141{ 142return ( e * f ) + ( g * h ) ; // no constraint on order or 143// operator consistency 144} 145 146float func2 ( float e , float f , float g , float h ) 147{ 148precise float result = ( e * f ) + ( g * h ) ; // ensures same precision for 149// the two multiplies 150return result ; 151} 152 153float func3 ( float i , float j , precise out float k ) 154{ 155k = i * i + j ; // precise, due to <k> declaration 156} 157 158void main () 159{ 160vec3 r = vec3 ( a * b ) ; // precise, used to compute v.xyz 161vec3 s = vec3 ( c * d ) ; // precise, used to compute v.xyz 162v . xyz = r + s ; // precise 163v . w = ( a . w * b . w ) + ( c . w * d . w ) ; // precise 164v . x = func ( a . x , b . x , c . x , d . x ) ; // values computed in func() 165// are NOT precise 166v . x = func2 ( a . x , b . x , c . x , d . x ) ; // precise! 167func3 ( a . x * b . x , c . x * d . x , v . x ) ; // precise! 168 169funcA ( img1 ) ; // OK, adding "restrict" is allowed, ERROR, changing formats 170funcB ( img2 ) ; // illegal, stripping "coherent" is not, ERROR, changing formats 171 172{ 173struct light { 174float intensity ; 175vec3 position ; 176} ; 177 178light lightVar = light ( 3.0 , vec3 ( 1.0 , 2.0 , 3.0 )) ; 179} 180{ 181const float c [ 3 ] = float [ 3 ]( 5.0 , 7.2 , 1.1 ) ; 182const float d [ 3 ] = float []( 5.0 , 7.2 , 1.1 ) ; 183 184float g ; 185float a [ 5 ] = float [ 5 ]( g , 1 , g , 2.3 , g ) ; 186float b [ 3 ] ; 187 188b = float [ 3 ]( g , g + 1.0 , g + 2.0 ) ; 189} 190{ 191vec4 b [ 2 ] = { vec4 ( 1.0 ) , vec4 ( 1.0 ) } ; 192vec4 [ 3 ][ 2 ]( b , b , b ) ; // constructor 193vec4 [][ 2 ]( b , b , b ) ; // constructor, valid, size deduced 194vec4 [ 3 ][]( b , b , b ) ; // compile-time error, invalid type constructed 195} 196}