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.
30 lines
894 B
Plaintext
30 lines
894 B
Plaintext
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
|
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
#include <metal_atomic>
|
|
|
|
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 u0_counters
|
|
{
|
|
uint c;
|
|
};
|
|
|
|
kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d<uint, access::write> u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
|
|
{
|
|
uint _29 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed);
|
|
float4 r0;
|
|
r0.x = as_type<float>(_29);
|
|
u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(((uint(as_type<int>(r0.x)) * 1u) + (uint(0) >> 2u))));
|
|
}
|
|
|