105 lines
2.0 KiB
Plaintext
105 lines
2.0 KiB
Plaintext
|
#version 310 es
|
||
|
layout(local_size_x = 1) in;
|
||
|
|
||
|
layout(std140, binding = 1) uniform UBO
|
||
|
{
|
||
|
int index0;
|
||
|
int index1;
|
||
|
};
|
||
|
|
||
|
layout(binding = 0, std430) buffer SSBO
|
||
|
{
|
||
|
layout(column_major) mat4 mcol;
|
||
|
layout(row_major) mat4 mrow;
|
||
|
|
||
|
layout(column_major) mat2 mcol2x2;
|
||
|
layout(row_major) mat2 mrow2x2;
|
||
|
|
||
|
layout(column_major) mat2x3 mcol2x3;
|
||
|
layout(row_major) mat2x3 mrow2x3;
|
||
|
|
||
|
layout(column_major) mat3x2 mcol3x2;
|
||
|
layout(row_major) mat3x2 mrow3x2;
|
||
|
};
|
||
|
|
||
|
void col_to_row()
|
||
|
{
|
||
|
// Load column-major, store row-major.
|
||
|
mrow = mcol;
|
||
|
mrow2x2 = mcol2x2;
|
||
|
mrow2x3 = mcol2x3;
|
||
|
mrow3x2 = mcol3x2;
|
||
|
}
|
||
|
|
||
|
void row_to_col()
|
||
|
{
|
||
|
// Load row-major, store column-major.
|
||
|
mcol = mrow;
|
||
|
mcol2x2 = mrow2x2;
|
||
|
mcol2x3 = mrow2x3;
|
||
|
mcol3x2 = mrow3x2;
|
||
|
}
|
||
|
|
||
|
void write_dynamic_index_row()
|
||
|
{
|
||
|
mrow[index0][index1] = 1.0;
|
||
|
mrow2x2[index0][index1] = 2.0;
|
||
|
mrow2x3[index0][index1] = 3.0;
|
||
|
mrow3x2[index0][index1] = 4.0;
|
||
|
|
||
|
mrow[index0] = vec4(1.0);
|
||
|
mrow2x2[index0] = vec2(2.0);
|
||
|
mrow2x3[index0] = vec3(3.0);
|
||
|
mrow3x2[index0] = vec2(4.0);
|
||
|
}
|
||
|
|
||
|
void write_dynamic_index_col()
|
||
|
{
|
||
|
mcol[index0][index1] = 1.0;
|
||
|
mcol2x2[index0][index1] = 2.0;
|
||
|
mcol2x3[index0][index1] = 3.0;
|
||
|
mcol3x2[index0][index1] = 4.0;
|
||
|
|
||
|
mcol[index0] = vec4(1.0);
|
||
|
mcol2x2[index0] = vec2(2.0);
|
||
|
mcol2x3[index0] = vec3(3.0);
|
||
|
mcol3x2[index0] = vec2(4.0);
|
||
|
}
|
||
|
|
||
|
void read_dynamic_index_row()
|
||
|
{
|
||
|
float a0 = mrow[index0][index1];
|
||
|
float a1 = mrow2x2[index0][index1];
|
||
|
float a2 = mrow2x3[index0][index1];
|
||
|
float a3 = mrow3x2[index0][index1];
|
||
|
|
||
|
vec4 v0 = mrow[index0];
|
||
|
vec2 v1 = mrow2x2[index0];
|
||
|
vec3 v2 = mrow2x3[index0];
|
||
|
vec2 v3 = mrow3x2[index0];
|
||
|
}
|
||
|
|
||
|
void read_dynamic_index_col()
|
||
|
{
|
||
|
float a0 = mcol[index0][index1];
|
||
|
float a1 = mcol2x2[index0][index1];
|
||
|
float a2 = mcol2x3[index0][index1];
|
||
|
float a3 = mcol3x2[index0][index1];
|
||
|
|
||
|
vec4 v0 = mcol[index0];
|
||
|
vec2 v1 = mcol2x2[index0];
|
||
|
vec3 v2 = mcol2x3[index0];
|
||
|
vec2 v3 = mcol3x2[index0];
|
||
|
}
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
row_to_col();
|
||
|
col_to_row();
|
||
|
write_dynamic_index_row();
|
||
|
write_dynamic_index_col();
|
||
|
read_dynamic_index_row();
|
||
|
read_dynamic_index_col();
|
||
|
}
|
||
|
|