#pragma clang diagnostic ignored "-Wmissing-prototypes" #include #include using namespace metal; template struct SpvHalfTypeSelector; template <> struct SpvHalfTypeSelector { public: using H = half; }; template struct SpvHalfTypeSelector> { using H = vec; }; template::H> [[clang::optnone]] F spvQuantizeToF16(F fval) { H hval = H(fval); hval = select(copysign(H(0), hval), hval, isnormal(hval) || isinf(hval) || isnan(hval)); return F(hval); } struct SSBO0 { float scalar; float2 vec2_val; float3 vec3_val; float4 vec4_val; }; kernel void main0(device SSBO0& _12 [[buffer(0)]]) { _12.scalar = spvQuantizeToF16(_12.scalar); _12.vec2_val = spvQuantizeToF16(_12.vec2_val); _12.vec3_val = spvQuantizeToF16(_12.vec3_val); _12.vec4_val = spvQuantizeToF16(_12.vec4_val); }