2019-07-22 09:23:06 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
|
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
|
|
|
struct SSBOCol
|
|
|
|
{
|
|
|
|
float4x4 col_major0;
|
|
|
|
float4x4 col_major1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SSBORow
|
|
|
|
{
|
|
|
|
float4x4 row_major0;
|
|
|
|
float4x4 row_major1;
|
|
|
|
};
|
|
|
|
|
2019-09-24 22:13:04 +00:00
|
|
|
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void load_store_to_variable_col_major(device SSBOCol& _29)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
float4x4 loaded = _29.col_major0;
|
|
|
|
_29.col_major1 = loaded;
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void load_store_to_variable_row_major(device SSBORow& _41)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
float4x4 loaded = transpose(_41.row_major0);
|
|
|
|
_41.row_major0 = transpose(loaded);
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void copy_col_major_to_col_major(device SSBOCol& _29)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
_29.col_major0 = _29.col_major1;
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void copy_col_major_to_row_major(device SSBOCol& _29, device SSBORow& _41)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
_41.row_major0 = transpose(_29.col_major0);
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void copy_row_major_to_col_major(device SSBOCol& _29, device SSBORow& _41)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
_29.col_major0 = transpose(_41.row_major0);
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void copy_row_major_to_row_major(device SSBORow& _41)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
_41.row_major0 = _41.row_major1;
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void copy_columns(device SSBOCol& _29, device SSBORow& _41)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
_29.col_major0[1] = float4(_41.row_major0[0][1], _41.row_major0[1][1], _41.row_major0[2][1], _41.row_major0[3][1]);
|
|
|
|
_41.row_major0[0][1] = _29.col_major0[1].x;
|
|
|
|
_41.row_major0[1][1] = _29.col_major0[1].y;
|
|
|
|
_41.row_major0[2][1] = _29.col_major0[1].z;
|
|
|
|
_41.row_major0[3][1] = _29.col_major0[1].w;
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 19:11:19 +00:00
|
|
|
static inline __attribute__((always_inline))
|
2023-03-30 16:12:34 +00:00
|
|
|
void copy_elements(device SSBOCol& _29, device SSBORow& _41)
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
((device float*)&_29.col_major0[0])[1u] = ((device float*)&_41.row_major0[1u])[0];
|
|
|
|
((device float*)&_41.row_major0[1u])[0] = ((device float*)&_29.col_major0[0])[1u];
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|
2023-03-30 16:12:34 +00:00
|
|
|
kernel void main0(device SSBOCol& _29 [[buffer(0)]], device SSBORow& _41 [[buffer(1)]])
|
2019-07-22 09:23:06 +00:00
|
|
|
{
|
2023-03-30 16:12:34 +00:00
|
|
|
load_store_to_variable_col_major(_29);
|
|
|
|
load_store_to_variable_row_major(_41);
|
|
|
|
copy_col_major_to_col_major(_29);
|
|
|
|
copy_col_major_to_row_major(_29, _41);
|
|
|
|
copy_row_major_to_col_major(_29, _41);
|
|
|
|
copy_row_major_to_row_major(_41);
|
|
|
|
copy_columns(_29, _41);
|
|
|
|
copy_elements(_29, _41);
|
2019-07-22 09:23:06 +00:00
|
|
|
}
|
|
|
|
|