yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
3357d870
main
1#version 450 2 3struct T { 4float f1 ; 5float f2 ; 6}; 7 8out B1 {precise T s ;float x ;}partial_precise_block ; 9precise out B2 {T s ;float x ;}all_precise_block ; 10 11float struct_member () { 12float a = 1.0 ; 13float b = 2.0 ; 14float c = 3.0 ; 15float d = 4.0 ; 16 17precise float result ; 18 19T S ,S2 ,S3 ; 20 21S2 .f1 = a + 0.2 ;// NoContraction 22S2 .f2 = b + 0.2 ;// NOT NoContraction 23S3 .f1 = a + b ;// NOT NoContraction 24S = S2 ;// "precise" propagated through parent object nodes 25result = S .f1 + 0.1 ;// the ADD operation should be NoContraction 26 27return result ; 28} 29 30float complex_array_struct () { 31precise float result ; 32struct T1 { 33float t1_array [3 ]; 34float t1_scalar ; 35 }; 36struct T2 { 37T1 t1a [5 ]; 38T1 t1b [6 ]; 39T1 t1c [7 ]; 40 }; 41struct T3 {float f ;T2 t2 ;vec4 v ;int p ;}; 42T3 t3 [10 ]; 43for (int i = 0 ;i < 10 ;i ++ ) { 44t3 [i ].f = i /3.0 ;// Not NoContraction 45t3 [i ].v = vec4 (i * 1.5 );// NoContraction 46t3 [i ].p = i + 1 ; 47for (int j = 0 ;j < 5 ;j ++ ) { 48for (int k = 0 ;k < 3 ;k ++ ) { 49t3 [i ].t2 .t1a [j ].t1_array [k ]= i * j + k ;// Not NoContraction 50 } 51t3 [i ].t2 .t1a [j ].t1_scalar = j * 2.0 /i ;// Not NoContration 52 } 53 54for (int j = 0 ;j < 6 ;j ++ ) { 55for (int k = 0 ;k < 3 ;k ++ ) { 56t3 [i ].t2 .t1b [j ].t1_array [k ]= i * j + k ;// Not NoContraction 57 } 58t3 [i ].t2 .t1b [j ].t1_scalar = j * 2.0 /i ;// NoContraction 59 } 60 61for (int j = 0 ;j < 6 ;j ++ ) { 62for (int k = 0 ;k < 3 ;k ++ ) { 63t3 [i ].t2 .t1c [j ].t1_array [k ]= i * j + k ;// Not NoContraction because all operands are integers 64 } 65t3 [i ].t2 .t1c [j ].t1_scalar = j * 2.0 /i ;// Not NoContraction 66 } 67 } 68int i = 2 ; 69result = t3 [5 ].t2 .t1c [6 ].t1_array [1 ] 70+ t3 [2 ].t2 .t1b [1 ].t1_scalar 71+ t3 [i - 1 ].v .xy .x ;// NoContraction 72return result ; 73} 74 75float out_block () { 76float a = 0.1 ; 77float b = 0.2 ; 78partial_precise_block .s .f1 = a + b ;// NoContraction 79partial_precise_block .s .f2 = a - b ;// NoContraction 80partial_precise_block .x = a * b ;// Not NoContraction 81 82all_precise_block .s .f1 = a + b + 1.0 ;// NoContraction 83all_precise_block .s .f2 = a - b - 1.0 ;// NoContraction 84all_precise_block .x = a * b * 2.0 ;// Also NoContraction 85 86return a + b ;// Not NoContraction 87} 88 89void main (){}