[英]OSX - Convert GLSL 'InOut' to Metal
I am trying to convert the GLSL
function below: 我正在尝试转换下面的
GLSL
函数:
float pMod1(inout float p, float size) {
float halfsize = size*0.5;
float c = floor((p + halfsize)/size);
p = mod(p + halfsize, size) - halfsize;
return c;
}
to use in Metal
用于
Metal
static float pMod1( thread float &p, float size) {
float halfsize = size*0.5;
float c = floor((p + halfsize)/size);
p = mod(p + halfsize, size) - halfsize;
return c;
}
Then use it: 然后使用它:
static float map( float3 p )
{
p.x = pMod1(p.x,10);
...
}
and I got an error: 我得到一个错误:
Non-cont reference cannot bind to vector element
非续引用不能绑定到矢量元素
InOut
in Metal
? InOut
in Metal
的等效限定符? I found the solution: 我找到了解决方案:
first you have to define it: 首先,您必须定义它:
#define _inout(T) T
Then use it in your function: 然后在您的函数中使用它:
static float somefunction( _inout(float) p)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.