我该如何转换:
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))
);
以便我可以在Metal
中使用它?我试过了:
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))
};
并没有得到任何错误。但是,当我尝试访问它时:
float3 a = GDFVectors[0];
我会收到此错误:
错误:在计算
中不能有全局构造函数(llvm.global_ctors)
我知道我初始化给我问题的float3
数组的方式。但我不知道如何解决这个问题。