2017-05-19 22:14:08 +00:00
|
|
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
|
2017-01-27 01:22:31 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
2017-05-19 22:14:08 +00:00
|
|
|
// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
|
2017-01-27 01:22:31 +00:00
|
|
|
template<typename Tx, typename Ty>
|
2019-08-29 21:39:06 +00:00
|
|
|
inline Tx mod(Tx x, Ty y)
|
2017-01-27 01:22:31 +00:00
|
|
|
{
|
|
|
|
return x - y * floor(x / y);
|
|
|
|
}
|
|
|
|
|
2021-09-28 23:10:16 +00:00
|
|
|
struct myBlock
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
float b[1];
|
|
|
|
};
|
|
|
|
|
2017-01-27 01:22:31 +00:00
|
|
|
kernel void main0(device myBlock& myStorage [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
|
|
|
|
{
|
|
|
|
myStorage.a = (myStorage.a + 1) % 256;
|
|
|
|
myStorage.b[gl_LocalInvocationIndex] = mod(myStorage.b[gl_LocalInvocationIndex] + 0.0199999995529651641845703125, 1.0);
|
|
|
|
}
|
|
|
|
|