SPIRV-Cross/reference/shaders-msl-no-opt/comp/int16min-literal.comp
Hans-Kristian Arntzen 4de9d6c2b6 MSL: Handle implicit integer promotion rules.
MSL inherits the behavior of C where arithmetic on small types are
implicitly converted to int. SPIR-V does not have this behavior, so make
sure that arithmetic results are handled correctly.
2022-10-31 13:33:46 +01:00

25 lines
383 B
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct UBO
{
half b;
};
struct SSBO
{
half a;
};
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
kernel void main0(constant UBO& _12 [[buffer(0)]], device SSBO& _24 [[buffer(1)]])
{
short v = as_type<short>(_12.b);
v = short(v ^ short(-32768));
_24.a = as_type<half>(v);
}