| 1 |
#version 310 es |
| 2 |
layout(local_size_x = 1) in; |
| 3 |
|
| 4 |
layout(std430, binding = 0) buffer SSBO |
| 5 |
{ |
| 6 |
float data; |
| 7 |
}; |
| 8 |
|
| 9 |
void test() |
| 10 |
{ |
| 11 |
// Test that variables local to a scope stay local. |
| 12 |
if (data != 0.0) |
| 13 |
{ |
| 14 |
float tmp = 10.0; |
| 15 |
data = tmp; |
| 16 |
} |
| 17 |
else |
| 18 |
{ |
| 19 |
float tmp = 15.0; |
| 20 |
data = tmp; |
| 21 |
} |
| 22 |
|
| 23 |
// Test that variable access propagates up to dominator |
| 24 |
if (data != 0.0) |
| 25 |
{ |
| 26 |
float e; |
| 27 |
if (data != 5.0) |
| 28 |
{ |
| 29 |
if (data != 6.0) |
| 30 |
e = 10.0; |
| 31 |
} |
| 32 |
else |
| 33 |
e = 20.0; |
| 34 |
} |
| 35 |
|
| 36 |
// Test that variables local to a switch block stay local. |
| 37 |
switch (int(data)) |
| 38 |
{ |
| 39 |
case 0: |
| 40 |
{ |
| 41 |
float tmp = 20.0; |
| 42 |
data = tmp; |
| 43 |
break; |
| 44 |
} |
| 45 |
|
| 46 |
case 1: |
| 47 |
{ |
| 48 |
float tmp = 30.0; |
| 49 |
data = tmp; |
| 50 |
break; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
// Check that multibranches propagate up to dominator. |
| 55 |
float f; |
| 56 |
switch (int(data)) |
| 57 |
{ |
| 58 |
case 0: |
| 59 |
{ |
| 60 |
f = 30.0; |
| 61 |
break; |
| 62 |
} |
| 63 |
|
| 64 |
case 1: |
| 65 |
{ |
| 66 |
f = 40.0; |
| 67 |
break; |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
// Check that loops work. |
| 72 |
// Interesting case here is propagating variable access from the continue block. |
| 73 |
float h; |
| 74 |
for (int i = 0; i < 20; i++, h += 10.0) |
| 75 |
; |
| 76 |
data = h; |
| 77 |
|
| 78 |
// Do the same with do-while, gotta test all the hard cases. |
| 79 |
float m; |
| 80 |
do |
| 81 |
{ |
| 82 |
} while (m != 20.0); |
| 83 |
data = m; |
| 84 |
} |
| 85 |
|
| 86 |
void main() |
| 87 |
{ |
| 88 |
// Test that we do the CFG analysis for all functions. |
| 89 |
test(); |
| 90 |
} |
| 91 |
|