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

145 lines
4.2 KiB
Plaintext

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wunused-variable"
#include <metal_stdlib>
#include <simd/simd.h>
template <typename T, size_t Num>
struct unsafe_array
{
T __Elements[Num ? Num : 1];
constexpr size_t size() const thread { return Num; }
constexpr size_t max_size() const thread { return Num; }
constexpr bool empty() const thread { return Num == 0; }
constexpr size_t size() const device { return Num; }
constexpr size_t max_size() const device { return Num; }
constexpr bool empty() const device { return Num == 0; }
constexpr size_t size() const constant { return Num; }
constexpr size_t max_size() const constant { return Num; }
constexpr bool empty() const constant { return Num == 0; }
constexpr size_t size() const threadgroup { return Num; }
constexpr size_t max_size() const threadgroup { return Num; }
constexpr bool empty() const threadgroup { return Num == 0; }
thread T &operator[](size_t pos) thread
{
return __Elements[pos];
}
constexpr const thread T &operator[](size_t pos) const thread
{
return __Elements[pos];
}
device T &operator[](size_t pos) device
{
return __Elements[pos];
}
constexpr const device T &operator[](size_t pos) const device
{
return __Elements[pos];
}
constexpr const constant T &operator[](size_t pos) const constant
{
return __Elements[pos];
}
threadgroup T &operator[](size_t pos) threadgroup
{
return __Elements[pos];
}
constexpr const threadgroup T &operator[](size_t pos) const threadgroup
{
return __Elements[pos];
}
};
using namespace metal;
struct SSBO
{
int4 ints;
uint4 uints;
};
// Implementation of the signed GLSL findMSB() function
template<typename T>
<<<<<<< HEAD
inline T spvFindSMSB(T x)
=======
static inline __attribute__((always_inline))
T findSMSB(T x)
>>>>>>> 22755a0c... Update the Metal shaders to account for changes in the shader compilation.
{
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>
<<<<<<< HEAD
inline T spvFindUMSB(T x)
=======
static inline __attribute__((always_inline))
T findUMSB(T x)
>>>>>>> 22755a0c... Update the Metal shaders to account for changes in the shader compilation.
{
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>
<<<<<<< HEAD
inline T sign(T x)
=======
static inline __attribute__((always_inline))
T sign(T x)
>>>>>>> 22755a0c... Update the Metal shaders to account for changes in the shader compilation.
{
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 = spvFindSMSB(int4(_20));
_4.uints = uint4(spvFindSMSB(int4(_20)));
_4.ints = int4(spvFindUMSB(uint4(_19)));
_4.uints = spvFindUMSB(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));
}