ec054dad7f
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.
25 lines
695 B
Plaintext
25 lines
695 B
Plaintext
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
// Returns 2D texture coords corresponding to 1D texel buffer coords
|
|
static inline __attribute__((always_inline))
|
|
uint2 spvTexelBufferCoord(uint tc)
|
|
{
|
|
return uint2(tc % 4096, tc / 4096);
|
|
}
|
|
|
|
struct cb
|
|
{
|
|
float value;
|
|
};
|
|
|
|
kernel void main0(constant cb& _6 [[buffer(0)]], texture2d<float, access::write> _buffer [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
|
|
{
|
|
_buffer.write(float4(_6.value), spvTexelBufferCoord(((32u * gl_WorkGroupID.x) + gl_LocalInvocationIndex)));
|
|
}
|
|
|