| 1 |
#version 310 es |
| 2 |
layout(local_size_x = 1) in; |
| 3 |
|
| 4 |
layout(std140, binding = 1) uniform UBO |
| 5 |
{ |
| 6 |
int index0; |
| 7 |
int index1; |
| 8 |
}; |
| 9 |
|
| 10 |
layout(binding = 0, std430) buffer SSBO |
| 11 |
{ |
| 12 |
layout(column_major) mat4 mcol; |
| 13 |
layout(row_major) mat4 mrow; |
| 14 |
|
| 15 |
layout(column_major) mat2 mcol2x2; |
| 16 |
layout(row_major) mat2 mrow2x2; |
| 17 |
|
| 18 |
layout(column_major) mat2x3 mcol2x3; |
| 19 |
layout(row_major) mat2x3 mrow2x3; |
| 20 |
|
| 21 |
layout(column_major) mat3x2 mcol3x2; |
| 22 |
layout(row_major) mat3x2 mrow3x2; |
| 23 |
}; |
| 24 |
|
| 25 |
void col_to_row() |
| 26 |
{ |
| 27 |
// Load column-major, store row-major. |
| 28 |
mrow = mcol; |
| 29 |
mrow2x2 = mcol2x2; |
| 30 |
mrow2x3 = mcol2x3; |
| 31 |
mrow3x2 = mcol3x2; |
| 32 |
} |
| 33 |
|
| 34 |
void row_to_col() |
| 35 |
{ |
| 36 |
// Load row-major, store column-major. |
| 37 |
mcol = mrow; |
| 38 |
mcol2x2 = mrow2x2; |
| 39 |
mcol2x3 = mrow2x3; |
| 40 |
mcol3x2 = mrow3x2; |
| 41 |
} |
| 42 |
|
| 43 |
void write_dynamic_index_row() |
| 44 |
{ |
| 45 |
mrow[index0][index1] = 1.0; |
| 46 |
mrow2x2[index0][index1] = 2.0; |
| 47 |
mrow2x3[index0][index1] = 3.0; |
| 48 |
mrow3x2[index0][index1] = 4.0; |
| 49 |
|
| 50 |
mrow[index0] = vec4(1.0); |
| 51 |
mrow2x2[index0] = vec2(2.0); |
| 52 |
mrow2x3[index0] = vec3(3.0); |
| 53 |
mrow3x2[index0] = vec2(4.0); |
| 54 |
} |
| 55 |
|
| 56 |
void write_dynamic_index_col() |
| 57 |
{ |
| 58 |
mcol[index0][index1] = 1.0; |
| 59 |
mcol2x2[index0][index1] = 2.0; |
| 60 |
mcol2x3[index0][index1] = 3.0; |
| 61 |
mcol3x2[index0][index1] = 4.0; |
| 62 |
|
| 63 |
mcol[index0] = vec4(1.0); |
| 64 |
mcol2x2[index0] = vec2(2.0); |
| 65 |
mcol2x3[index0] = vec3(3.0); |
| 66 |
mcol3x2[index0] = vec2(4.0); |
| 67 |
} |
| 68 |
|
| 69 |
void read_dynamic_index_row() |
| 70 |
{ |
| 71 |
float a0 = mrow[index0][index1]; |
| 72 |
float a1 = mrow2x2[index0][index1]; |
| 73 |
float a2 = mrow2x3[index0][index1]; |
| 74 |
float a3 = mrow3x2[index0][index1]; |
| 75 |
|
| 76 |
vec4 v0 = mrow[index0]; |
| 77 |
vec2 v1 = mrow2x2[index0]; |
| 78 |
vec3 v2 = mrow2x3[index0]; |
| 79 |
vec2 v3 = mrow3x2[index0]; |
| 80 |
} |
| 81 |
|
| 82 |
void read_dynamic_index_col() |
| 83 |
{ |
| 84 |
float a0 = mcol[index0][index1]; |
| 85 |
float a1 = mcol2x2[index0][index1]; |
| 86 |
float a2 = mcol2x3[index0][index1]; |
| 87 |
float a3 = mcol3x2[index0][index1]; |
| 88 |
|
| 89 |
vec4 v0 = mcol[index0]; |
| 90 |
vec2 v1 = mcol2x2[index0]; |
| 91 |
vec3 v2 = mcol2x3[index0]; |
| 92 |
vec2 v3 = mcol3x2[index0]; |
| 93 |
} |
| 94 |
|
| 95 |
void main() |
| 96 |
{ |
| 97 |
row_to_col(); |
| 98 |
col_to_row(); |
| 99 |
write_dynamic_index_row(); |
| 100 |
write_dynamic_index_col(); |
| 101 |
read_dynamic_index_row(); |
| 102 |
read_dynamic_index_col(); |
| 103 |
} |
| 104 |
|