| 1 |
#pragma clang diagnostic ignored "-Wmissing-prototypes" |
| 2 |
|
| 3 |
#include <metal_stdlib> |
| 4 |
#include <simd/simd.h> |
| 5 |
|
| 6 |
using namespace metal; |
| 7 |
|
| 8 |
struct SSBO |
| 9 |
{ |
| 10 |
float4 in_data[1]; |
| 11 |
}; |
| 12 |
|
| 13 |
struct SSBO2 |
| 14 |
{ |
| 15 |
float4 out_data[1]; |
| 16 |
}; |
| 17 |
|
| 18 |
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); |
| 19 |
|
| 20 |
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() |
| 21 |
template<typename Tx, typename Ty> |
| 22 |
inline Tx mod(Tx x, Ty y) |
| 23 |
{ |
| 24 |
return x - y * floor(x / y); |
| 25 |
} |
| 26 |
|
| 27 |
kernel void main0(const device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) |
| 28 |
{ |
| 29 |
uint ident = gl_GlobalInvocationID.x; |
| 30 |
float4 v = mod(_23.in_data[ident], _33.out_data[ident]); |
| 31 |
_33.out_data[ident] = v; |
| 32 |
uint4 vu = as_type<uint4>(_23.in_data[ident]) % as_type<uint4>(_33.out_data[ident]); |
| 33 |
_33.out_data[ident] = as_type<float4>(vu); |
| 34 |
int4 vi = as_type<int4>(_23.in_data[ident]) % as_type<int4>(_33.out_data[ident]); |
| 35 |
_33.out_data[ident] = as_type<float4>(vi); |
| 36 |
} |
| 37 |
|