36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
#include <metal_stdlib>
|
|
|
|
using namespace metal;
|
|
|
|
template<typename T, size_t N>
|
|
struct tint_array {
|
|
const constant T& operator[](size_t i) const constant { return elements[i]; }
|
|
device T& operator[](size_t i) device { return elements[i]; }
|
|
const device T& operator[](size_t i) const device { return elements[i]; }
|
|
thread T& operator[](size_t i) thread { return elements[i]; }
|
|
const thread T& operator[](size_t i) const thread { return elements[i]; }
|
|
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
|
|
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
|
|
T elements[N];
|
|
};
|
|
|
|
template<typename T>
|
|
T tint_dot3(vec<T,3> a, vec<T,3> b) {
|
|
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
|
|
}
|
|
struct g {
|
|
/* 0x0000 */ packed_uint3 a;
|
|
/* 0x000c */ tint_array<int8_t, 4> tint_pad;
|
|
};
|
|
|
|
struct h {
|
|
/* 0x0000 */ uint a;
|
|
};
|
|
|
|
kernel void tint_symbol(const constant g* tint_symbol_1 [[buffer(0)]], device h* tint_symbol_2 [[buffer(1)]]) {
|
|
uint const l = tint_dot3(uint3((*(tint_symbol_1)).a), uint3((*(tint_symbol_1)).a));
|
|
(*(tint_symbol_2)).a = (*(tint_symbol_1)).a[0];
|
|
return;
|
|
}
|
|
|