SPIRV-Cross/shaders-msl-no-opt/packing/matrix-3x4-std140.comp

86 lines
1.4 KiB
Plaintext
Raw Normal View History

#version 450
layout(local_size_x = 1) in;
#define T mat3x4
#define PACKING std140
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();
}