SPIRV-Cross/shaders-msl-no-opt/packing/matrix-2x3-scalar.comp
2019-07-22 11:30:03 +02:00

87 lines
1.5 KiB
Plaintext

#version 450
#extension GL_EXT_scalar_block_layout : require
layout(local_size_x = 1) in;
#define T mat2x3
#define PACKING scalar
layout(set = 0, binding = 0, PACKING) buffer SSBOCol
{
layout(column_major) T col_major0;
layout(column_major) T col_major1;
};
layout(set = 0, binding = 1, PACKING) buffer SSBORow
{
layout(row_major) T row_major0;
layout(row_major) T row_major1;
};
void load_store_to_variable_col_major()
{
// Load to variable.
T loaded = col_major0;
// Store from variable.
col_major1 = loaded;
}
void load_store_to_variable_row_major()
{
// Load to variable.
T loaded = row_major0;
// Store to variable.
row_major0 = loaded;
}
void copy_col_major_to_col_major()
{
// Copy col -> col
col_major0 = col_major1;
}
void copy_row_major_to_col_major()
{
// Copy row -> col
col_major0 = row_major0;
}
void copy_col_major_to_row_major()
{
// Copy col -> row
row_major0 = col_major0;
}
void copy_row_major_to_row_major()
{
// Copy row -> row
row_major0 = row_major1;
}
void copy_columns()
{
// Copy columns/rows.
col_major0[1] = row_major0[1];
row_major0[1] = col_major0[1];
}
void copy_elements()
{
// Copy individual elements.
col_major0[0][1] = row_major0[0][1];
row_major0[0][1] = col_major0[0][1];
}
void main()
{
load_store_to_variable_col_major();
load_store_to_variable_row_major();
copy_col_major_to_col_major();
copy_col_major_to_row_major();
copy_row_major_to_col_major();
copy_row_major_to_row_major();
copy_columns();
copy_elements();
}