bc646574a6
This provides a few functions normally available in OpenCL to the SPIR-V shader environment. These functions happen to be available in Metal as well. No GLSL, unfortunately. Intel has yet to publish a `GL_INTEL_shader_integer_functions2` spec.
32 lines
638 B
Plaintext
32 lines
638 B
Plaintext
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct foo
|
|
{
|
|
uint a;
|
|
uint b;
|
|
int c;
|
|
int d;
|
|
};
|
|
|
|
kernel void main0(device foo& _4 [[buffer(0)]])
|
|
{
|
|
_4.a = clz(_4.a);
|
|
_4.a = ctz(_4.a);
|
|
_4.a = absdiff(_4.c, _4.d);
|
|
_4.a = absdiff(_4.a, _4.b);
|
|
_4.c = addsat(_4.c, _4.d);
|
|
_4.a = addsat(_4.a, _4.b);
|
|
_4.c = hadd(_4.c, _4.d);
|
|
_4.a = hadd(_4.a, _4.b);
|
|
_4.c = rhadd(_4.c, _4.d);
|
|
_4.a = rhadd(_4.a, _4.b);
|
|
_4.c = subsat(_4.c, _4.d);
|
|
_4.a = subsat(_4.a, _4.b);
|
|
_4.c = int(short(_4.c)) * int(short(_4.d));
|
|
_4.a = uint(ushort(_4.a)) * uint(ushort(_4.b));
|
|
}
|
|
|