SPIRV-Cross/reference/shaders-hlsl-no-opt/asm/comp/glsl-signed-operations.asm.comp
Hans-Kristian Arntzen eeb3f24991 Properly deal with sign-dependent GLSL opcodes.
The GLSLstd450 spec is very lax about input signs, so we need to do the
bitcasting dance to implement it correctly.
2019-03-27 12:20:53 +01:00

46 lines
1.7 KiB
Plaintext

RWByteAddressBuffer _4 : register(u0);
void comp_main()
{
int4 _19 = int4(_4.Load4(0));
uint4 _20 = _4.Load4(16);
_4.Store4(0, uint4(abs(_19)));
_4.Store4(16, uint4(abs(_19)));
_4.Store4(0, uint4(abs(int4(_20))));
_4.Store4(16, uint4(abs(int4(_20))));
_4.Store4(0, uint4(sign(_19)));
_4.Store4(16, uint4(sign(_19)));
_4.Store4(0, uint4(sign(int4(_20))));
_4.Store4(16, uint4(sign(int4(_20))));
_4.Store4(0, uint4(firstbithigh(int4(_20))));
_4.Store4(16, uint4(firstbithigh(int4(_20))));
_4.Store4(0, uint4(int4(firstbithigh(uint4(_19)))));
_4.Store4(16, firstbithigh(uint4(_19)));
_4.Store4(0, uint4(min(_19, _19)));
_4.Store4(16, uint4(min(_19, int4(_20))));
_4.Store4(0, uint4(min(int4(_20), int4(_20))));
_4.Store4(16, uint4(min(int4(_20), _19)));
_4.Store4(0, uint4(int4(min(uint4(_19), _20))));
_4.Store4(16, min(uint4(_19), _20));
_4.Store4(0, uint4(int4(min(_20, uint4(_19)))));
_4.Store4(16, min(_20, uint4(_19)));
_4.Store4(0, uint4(max(_19, _19)));
_4.Store4(16, uint4(max(_19, _19)));
_4.Store4(0, uint4(max(int4(_20), _19)));
_4.Store4(16, uint4(max(int4(_20), _19)));
_4.Store4(0, uint4(int4(max(uint4(_19), _20))));
_4.Store4(16, max(uint4(_19), uint4(_19)));
_4.Store4(0, uint4(int4(max(_20, uint4(_19)))));
_4.Store4(16, max(_20, uint4(_19)));
_4.Store4(0, uint4(clamp(int4(_20), int4(_20), int4(_20))));
_4.Store4(16, uint4(clamp(int4(_20), int4(_20), int4(_20))));
_4.Store4(0, uint4(int4(clamp(uint4(_19), uint4(_19), uint4(_19)))));
_4.Store4(16, clamp(uint4(_19), uint4(_19), uint4(_19)));
}
[numthreads(1, 1, 1)]
void main()
{
comp_main();
}