SPIRV-Cross/reference/shaders-msl/comp/writable-ssbo.comp
Bill Hollings ec054dad7f MSL: Support synthetic functions in function constants.
Emit synthetic functions before function constants.
Support use of spvQuantizeToF16() in function constants for numerical
behavior consistency with the op code.
Ensure subnormal results from OpQuantizeToF16 are flushed to zero per SPIR-V spec.

Adjust SPIRV-Cross unit test reference shaders to accommodate these changes.
Any MSL reference shader that inclues a synthetic function is affected,
since the location it is emitted has changed.
2021-09-28 19:10:16 -04:00

27 lines
546 B
Plaintext

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
// 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);
}
struct myBlock
{
int a;
float b;
};
kernel void main0(device myBlock& myStorage [[buffer(0)]])
{
myStorage.a = (myStorage.a + 1) % 256;
myStorage.b = mod(myStorage.b + 0.0199999995529651641845703125, 1.0);
}