问题
How can I convert this:
const vec3 GDFVectors[19] = vec3[](
normalize(vec3(1, 0, 0)),
normalize(vec3(0, 1, 0)),
normalize(vec3(0, 0, 1)),
normalize(vec3(1, 1, 1 )),
normalize(vec3(-1, 1, 1)),
normalize(vec3(1, -1, 1)),
normalize(vec3(1, 1, -1)),
normalize(vec3(0, 1, PHI+1)),
normalize(vec3(0, -1, PHI+1)),
normalize(vec3(PHI+1, 0, 1)),
normalize(vec3(-PHI-1, 0, 1)),
normalize(vec3(1, PHI+1, 0)),
normalize(vec3(-1, PHI+1, 0)),
normalize(vec3(0, PHI, 1)),
normalize(vec3(0, -PHI, 1)),
normalize(vec3(1, 0, PHI)),
normalize(vec3(-1, 0, PHI)),
normalize(vec3(PHI, 1, 0)),
normalize(vec3(-PHI, 1, 0))
);
so that I can use it in Metal
? I tried:
constant const float3 GDFVectors[19] = {
normalize(float3(1, 0, 0)),
normalize(float3(0, 1, 0)),
normalize(float3(0, 0, 1)),
normalize(float3(1, 1, 1 )),
normalize(float3(-1, 1, 1)),
normalize(float3(1, -1, 1)),
normalize(float3(1, 1, -1)),
normalize(float3(0, 1, PHI+1)),
normalize(float3(0, -1, PHI+1)),
normalize(float3(PHI+1, 0, 1)),
normalize(float3(-PHI-1, 0, 1)),
normalize(float3(1, PHI+1, 0)),
normalize(float3(-1, PHI+1, 0)),
normalize(float3(0, PHI, 1)),
normalize(float3(0, -PHI, 1)),
normalize(float3(1, 0, PHI)),
normalize(float3(-1, 0, PHI)),
normalize(float3(PHI, 1, 0)),
normalize(float3(-PHI, 1, 0))
};
and did not get any error. However when I try to access it:
float3 a = GDFVectors[0];
I will get this error:
error: cannot have global constructors (llvm.global_ctors) in compute
I know is the way I initialize the float3
array that give me issue. But I am not sure how to resolve this.
来源:https://stackoverflow.com/questions/43509957/metal-shading-language-multidimensional-array