1
如何使用struct
来获取缓冲区值?例如:金属着色语言 - 使用Struct来获取缓冲区值
struct mouseInput
{
float x;
float y;
};
kernel void compute(texture2d<float, access::write> output [[texture(0)]],
constant float &time [[buffer(0)]],
constant mouseInput.x &mouseX [[buffer(1)]],///<--mouseX from swift
constant mouseInput.y &mouseY [[buffer(2)]],///<--mouseY from swift
uint2 gid [[thread_position_in_grid]]) {
...
}
然后我可以访问mouseInput.x
和Metal
等等任何地方。最接近的是this thread但是我不确定如何将其转化为我的用途。