SPIRV-Cross/reference/shaders-msl-no-opt/packing/matrix-2x4-std140.comp
2019-09-24 18:13:04 -04:00

98 lines
3.5 KiB
Plaintext

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBOCol
{
float2x4 col_major0;
float2x4 col_major1;
};
struct SSBORow
{
float4x4 row_major0;
float4x4 row_major1;
};
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
static inline __attribute__((always_inline))
void load_store_to_variable_col_major(device SSBOCol& v_29)
{
float2x4 loaded = v_29.col_major0;
v_29.col_major1 = loaded;
}
static inline __attribute__((always_inline))
void load_store_to_variable_row_major(device SSBORow& v_41)
{
float2x4 loaded = transpose(float4x2(v_41.row_major0[0].xy, v_41.row_major0[1].xy, v_41.row_major0[2].xy, v_41.row_major0[3].xy));
v_41.row_major0[0].xy = float2(loaded[0][0], loaded[1][0]);
v_41.row_major0[1].xy = float2(loaded[0][1], loaded[1][1]);
v_41.row_major0[2].xy = float2(loaded[0][2], loaded[1][2]);
v_41.row_major0[3].xy = float2(loaded[0][3], loaded[1][3]);
}
static inline __attribute__((always_inline))
void copy_col_major_to_col_major(device SSBOCol& v_29)
{
v_29.col_major0 = v_29.col_major1;
}
static inline __attribute__((always_inline))
void copy_col_major_to_row_major(device SSBOCol& v_29, device SSBORow& v_41)
{
v_41.row_major0[0].xy = float2(v_29.col_major0[0][0], v_29.col_major0[1][0]);
v_41.row_major0[1].xy = float2(v_29.col_major0[0][1], v_29.col_major0[1][1]);
v_41.row_major0[2].xy = float2(v_29.col_major0[0][2], v_29.col_major0[1][2]);
v_41.row_major0[3].xy = float2(v_29.col_major0[0][3], v_29.col_major0[1][3]);
}
static inline __attribute__((always_inline))
void copy_row_major_to_col_major(device SSBOCol& v_29, device SSBORow& v_41)
{
v_29.col_major0 = transpose(float4x2(v_41.row_major0[0].xy, v_41.row_major0[1].xy, v_41.row_major0[2].xy, v_41.row_major0[3].xy));
}
static inline __attribute__((always_inline))
void copy_row_major_to_row_major(device SSBORow& v_41)
{
v_41.row_major0[0].xy = float4x2(v_41.row_major1[0].xy, v_41.row_major1[1].xy, v_41.row_major1[2].xy, v_41.row_major1[3].xy)[0];
v_41.row_major0[1].xy = float4x2(v_41.row_major1[0].xy, v_41.row_major1[1].xy, v_41.row_major1[2].xy, v_41.row_major1[3].xy)[1];
v_41.row_major0[2].xy = float4x2(v_41.row_major1[0].xy, v_41.row_major1[1].xy, v_41.row_major1[2].xy, v_41.row_major1[3].xy)[2];
v_41.row_major0[3].xy = float4x2(v_41.row_major1[0].xy, v_41.row_major1[1].xy, v_41.row_major1[2].xy, v_41.row_major1[3].xy)[3];
}
static inline __attribute__((always_inline))
void copy_columns(device SSBOCol& v_29, device SSBORow& v_41)
{
v_29.col_major0[1] = float4(v_41.row_major0[0][1], v_41.row_major0[1][1], v_41.row_major0[2][1], v_41.row_major0[3][1]);
v_41.row_major0[0][1] = v_29.col_major0[1].x;
v_41.row_major0[1][1] = v_29.col_major0[1].y;
v_41.row_major0[2][1] = v_29.col_major0[1].z;
v_41.row_major0[3][1] = v_29.col_major0[1].w;
}
static inline __attribute__((always_inline))
void copy_elements(device SSBOCol& v_29, device SSBORow& v_41)
{
v_29.col_major0[0].y = v_41.row_major0[1u][0];
v_41.row_major0[1u][0] = v_29.col_major0[0].y;
}
kernel void main0(device SSBOCol& v_29 [[buffer(0)]], device SSBORow& v_41 [[buffer(1)]])
{
load_store_to_variable_col_major(v_29);
load_store_to_variable_row_major(v_41);
copy_col_major_to_col_major(v_29);
copy_col_major_to_row_major(v_29, v_41);
copy_row_major_to_col_major(v_29, v_41);
copy_row_major_to_row_major(v_41);
copy_columns(v_29, v_41);
copy_elements(v_29, v_41);
}