1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#version 460
layout(location = 0) in vec4 a0; // accessed
layout(location = 1) in vec4 a1; // accessed
layout(location = 2) in vec4 a2; // accessed
layout(location = 3) in vec4 a3; // accessed
layout(location = 4) in vec4 a4; // accessed
layout(location = 5) in vec4 a5; // accessed
layout(location = 6) in vec4 a6; // accessed
layout(location = 7) in vec4 a7; // accessed
layout(location = 8) in vec4 a8; // accessed
layout(location = 9) in vec4 a9; // accessed
layout(location = 10) in vec4 a10; // accessed
layout(location = 11) in vec4 n0; // not accessed
layout(location = 12) in vec4 n1; // not accessed
layout(location = 13) in vec4 n2; // not accessed
layout(location = 14) in vec4 n3; // not accessed
layout(location = 15) in vec4 n4; // not accessed
layout(location = 16) in vec4 n5; // not accessed
layout(location = 17) in vec4 n6; // not accessed
layout(location = 18) in vec4 n7; // not accessed
layout(location = 19) in vec4 n8; // not accessed
layout(location = 20) in vec4 n9; // not accessed
void main() {
// empty case is live
switch (2) {
case 2: break;
case 1:
gl_Position = n0;
}
// empty default case is live
switch (3) {
default: break;
case 1:
gl_Position = n1;
}
// no live case
switch (3) {
case 2: // fallthrough
case 1:
gl_Position = n2;
}
// ensure break is handled correctly
switch (1) {
case -1:
gl_Position = n3;
break;
case 1:
gl_Position = a0;
break;
gl_Position = n4;
case 0:
gl_Position = n5;
}
const int cx = 1;
// signed/unsigned mismatch
switch (cx) {
case uint(1):
gl_Position = a1;
}
// signed/unsigned conversion
switch (-1) {
case ~uint(0):
gl_Position = a2;
}
// const variable case
switch (1) {
case cx:
gl_Position = a3;
break;
case -1:
gl_Position = n6;
}
// fallthrough with const variable
switch (cx) {
default: // fallthrough
case 2:
gl_Position = a4;
}
// non-trivial constant expression
switch (((cx + 1) * 2) - 3) {
case 1:
gl_Position = a5;
break;
case 2:
gl_Position = n7;
}
// expression as case
switch (5 + 3) {
case 6 + 2:
gl_Position = a6;
break;
case 5 + 2:
gl_Position = n8;
break;
}
int x = 2;
// liveness of non-const variables cannot be deduced
switch (x) {
case 1:
gl_Position = a7;
break;
case 2:
gl_Position = a8;
break;
}
// const and non-const expression
switch (cx + x) {
case 1:
gl_Position = a9;
break;
case 3:
gl_Position = a10;
break;
}
}
|