diff options
Diffstat (limited to '3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/comp/local-invocation-index.comp')
-rw-r--r-- | 3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/comp/local-invocation-index.comp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/comp/local-invocation-index.comp b/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/comp/local-invocation-index.comp new file mode 100644 index 00000000000..f8c1550eab7 --- /dev/null +++ b/3rdparty/bgfx/3rdparty/spirv-cross/reference/shaders-msl/comp/local-invocation-index.comp @@ -0,0 +1,26 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include <metal_stdlib> +#include <simd/simd.h> + +using namespace metal; + +struct myBlock +{ + int a; + float b[1]; +}; + +// Implementation of the GLSL mod() function, which is slightly different than Metal fmod() +template<typename Tx, typename Ty> +inline Tx mod(Tx x, Ty y) +{ + return x - y * floor(x / y); +} + +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); +} + |