SPIRV-Cross/reference/shaders-msl-no-opt/asm/comp/glsl-signed-operations.asm.comp

74 lines
2.1 KiB
Plaintext
Raw Normal View History

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBO
{
int4 ints;
uint4 uints;
};
// Implementation of the signed GLSL findMSB() function
template<typename T>
T findSMSB(T x)
{
T v = select(x, T(-1) - x, x < T(0));
return select(clz(T(0)) - (clz(v) + T(1)), T(-1), v == T(0));
}
// Implementation of the unsigned GLSL findMSB() function
template<typename T>
T findUMSB(T x)
{
return select(clz(T(0)) - (clz(x) + T(1)), T(-1), x == T(0));
}
// Implementation of the GLSL sign() function for integer types
template<typename T, typename E = typename enable_if<is_integral<T>::value>::type>
T sign(T x)
{
return select(select(select(x, T(0), x == T(0)), T(1), x > T(0)), T(-1), x < T(0));
}
kernel void main0(device SSBO& _4 [[buffer(0)]])
{
int4 _19 = _4.ints;
uint4 _20 = _4.uints;
_4.ints = abs(_19);
_4.uints = uint4(abs(_19));
_4.ints = abs(int4(_20));
_4.uints = uint4(abs(int4(_20)));
_4.ints = sign(_19);
_4.uints = uint4(sign(_19));
_4.ints = sign(int4(_20));
_4.uints = uint4(sign(int4(_20)));
_4.ints = findSMSB(int4(_20));
_4.uints = uint4(findSMSB(int4(_20)));
_4.ints = int4(findUMSB(uint4(_19)));
_4.uints = findUMSB(uint4(_19));
_4.ints = min(_19, _19);
_4.uints = uint4(min(_19, int4(_20)));
_4.ints = min(int4(_20), int4(_20));
_4.uints = uint4(min(int4(_20), _19));
_4.ints = int4(min(uint4(_19), _20));
_4.uints = min(uint4(_19), _20);
_4.ints = int4(min(_20, uint4(_19)));
_4.uints = min(_20, uint4(_19));
_4.ints = max(_19, _19);
_4.uints = uint4(max(_19, _19));
_4.ints = max(int4(_20), _19);
_4.uints = uint4(max(int4(_20), _19));
_4.ints = int4(max(uint4(_19), _20));
_4.uints = max(uint4(_19), uint4(_19));
_4.ints = int4(max(_20, uint4(_19)));
_4.uints = max(_20, uint4(_19));
_4.ints = clamp(int4(_20), int4(_20), int4(_20));
_4.uints = uint4(clamp(int4(_20), int4(_20), int4(_20)));
_4.ints = int4(clamp(uint4(_19), uint4(_19), uint4(_19)));
_4.uints = clamp(uint4(_19), uint4(_19), uint4(_19));
}