2023-09-18 18:11:07 +00:00
|
|
|
// language: metal1.0
|
2021-05-29 01:49:50 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
2022-02-21 21:22:54 +00:00
|
|
|
using metal::uint;
|
|
|
|
|
2022-01-06 01:15:09 +00:00
|
|
|
struct _mslBufferSizes {
|
2022-02-21 21:22:54 +00:00
|
|
|
uint size3;
|
2022-01-06 01:15:09 +00:00
|
|
|
};
|
|
|
|
|
2021-11-09 14:24:41 +00:00
|
|
|
struct type_2 {
|
2023-05-12 12:38:50 +00:00
|
|
|
float inner[10];
|
2021-05-29 01:49:50 +00:00
|
|
|
};
|
2023-01-12 17:26:28 +00:00
|
|
|
struct FooStruct {
|
2021-12-27 02:57:47 +00:00
|
|
|
metal::packed_float3 v3_;
|
|
|
|
float v1_;
|
|
|
|
};
|
2022-01-06 01:15:09 +00:00
|
|
|
typedef metal::float2 type_6[1];
|
2022-01-21 17:30:18 +00:00
|
|
|
struct type_8 {
|
|
|
|
metal::float4 inner[20];
|
2022-01-06 01:15:09 +00:00
|
|
|
};
|
2022-06-27 22:56:10 +00:00
|
|
|
struct type_11 {
|
|
|
|
metal::float2x4 inner[2];
|
|
|
|
};
|
|
|
|
struct type_12 {
|
|
|
|
type_11 inner[2];
|
|
|
|
};
|
|
|
|
struct type_14 {
|
|
|
|
metal::float4x2 inner[2];
|
|
|
|
};
|
|
|
|
struct type_15 {
|
|
|
|
type_14 inner[2];
|
|
|
|
};
|
2023-04-05 15:38:03 +00:00
|
|
|
constant bool Foo_1 = true;
|
2021-05-29 01:49:50 +00:00
|
|
|
|
2022-04-11 11:43:28 +00:00
|
|
|
void test_msl_packed_vec3_as_arg(
|
|
|
|
metal::float3 arg
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_msl_packed_vec3_(
|
2023-01-12 17:26:28 +00:00
|
|
|
device FooStruct& alignment
|
2022-04-11 11:43:28 +00:00
|
|
|
) {
|
2023-04-19 13:16:46 +00:00
|
|
|
int idx = 1;
|
2022-04-11 11:43:28 +00:00
|
|
|
alignment.v3_ = metal::float3(1.0);
|
|
|
|
alignment.v3_[0] = 1.0;
|
|
|
|
alignment.v3_[0] = 2.0;
|
2023-09-07 20:22:44 +00:00
|
|
|
int _e16 = idx;
|
|
|
|
alignment.v3_[_e16] = 3.0;
|
2023-01-12 17:26:28 +00:00
|
|
|
FooStruct data = alignment;
|
2023-06-12 15:02:27 +00:00
|
|
|
metal::float3 l0_ = data.v3_;
|
|
|
|
metal::float2 l1_ = metal::float3(data.v3_).zx;
|
2022-04-11 11:43:28 +00:00
|
|
|
test_msl_packed_vec3_as_arg(data.v3_);
|
2023-06-12 15:02:27 +00:00
|
|
|
metal::float3 mvm0_ = metal::float3(data.v3_) * metal::float3x3 {};
|
|
|
|
metal::float3 mvm1_ = metal::float3x3 {} * metal::float3(data.v3_);
|
|
|
|
metal::float3 svm0_ = data.v3_ * 2.0;
|
|
|
|
metal::float3 svm1_ = 2.0 * data.v3_;
|
2022-04-11 11:43:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 14:24:41 +00:00
|
|
|
kernel void main_(
|
2023-02-21 03:56:24 +00:00
|
|
|
metal::uint3 __local_invocation_id [[thread_position_in_threadgroup]]
|
2023-01-25 17:00:11 +00:00
|
|
|
, threadgroup type_2& wg
|
2021-11-24 22:36:57 +00:00
|
|
|
, threadgroup metal::atomic_uint& at_1
|
2023-01-12 17:26:28 +00:00
|
|
|
, device FooStruct& alignment [[user(fake0)]]
|
2022-03-06 17:08:40 +00:00
|
|
|
, device type_6 const& dummy [[user(fake0)]]
|
2022-04-13 01:54:42 +00:00
|
|
|
, constant type_8& float_vecs [[user(fake0)]]
|
2022-06-27 22:56:10 +00:00
|
|
|
, constant metal::float3& global_vec [[user(fake0)]]
|
|
|
|
, constant metal::float3x2& global_mat [[user(fake0)]]
|
|
|
|
, constant type_12& global_nested_arrays_of_matrices_2x4_ [[user(fake0)]]
|
|
|
|
, constant type_15& global_nested_arrays_of_matrices_4x2_ [[user(fake0)]]
|
2022-02-04 21:31:16 +00:00
|
|
|
, constant _mslBufferSizes& _buffer_sizes [[user(fake0)]]
|
2021-05-29 01:49:50 +00:00
|
|
|
) {
|
2023-02-21 03:56:24 +00:00
|
|
|
if (metal::all(__local_invocation_id == metal::uint3(0u))) {
|
2023-01-25 17:00:11 +00:00
|
|
|
wg = {};
|
|
|
|
metal::atomic_store_explicit(&at_1, 0, metal::memory_order_relaxed);
|
|
|
|
}
|
|
|
|
metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup);
|
2023-04-19 13:16:46 +00:00
|
|
|
float Foo = 1.0;
|
|
|
|
bool at = true;
|
2022-04-11 11:43:28 +00:00
|
|
|
test_msl_packed_vec3_(alignment);
|
2023-09-07 20:22:44 +00:00
|
|
|
metal::float4x2 _e5 = global_nested_arrays_of_matrices_4x2_.inner[0].inner[0];
|
|
|
|
metal::float4 _e10 = global_nested_arrays_of_matrices_2x4_.inner[0].inner[0][0];
|
|
|
|
wg.inner[7] = (_e5 * _e10).x;
|
|
|
|
metal::float3x2 _e16 = global_mat;
|
|
|
|
metal::float3 _e18 = global_vec;
|
|
|
|
wg.inner[6] = (_e16 * _e18).x;
|
|
|
|
float _e26 = dummy[1].y;
|
|
|
|
wg.inner[5] = _e26;
|
|
|
|
float _e32 = float_vecs.inner[0].w;
|
|
|
|
wg.inner[4] = _e32;
|
|
|
|
float _e37 = alignment.v1_;
|
|
|
|
wg.inner[3] = _e37;
|
|
|
|
float _e43 = alignment.v3_[0];
|
|
|
|
wg.inner[2] = _e43;
|
2022-03-06 17:08:40 +00:00
|
|
|
alignment.v1_ = 4.0;
|
2022-02-04 21:31:16 +00:00
|
|
|
wg.inner[1] = static_cast<float>(1 + (_buffer_sizes.size3 - 0 - 8) / 8);
|
2021-11-24 22:36:57 +00:00
|
|
|
metal::atomic_store_explicit(&at_1, 2u, metal::memory_order_relaxed);
|
2022-04-11 11:43:28 +00:00
|
|
|
return;
|
2021-05-29 01:49:50 +00:00
|
|
|
}
|