krafix
krafix copied to clipboard
Unable to pass vec4[] uniform as function argument in Metal
Source glsl:
uniform vec4 shirr[7];
vec3 shIrradiance(const vec3 nor) {
vec3 cl00 = vec3(shirr[0].x, shirr[0].y, shirr[0].z);
// ...
}
void main() {
// ...
shIrradiance(n);
}
Output metal:
struct Material_mesh_frag_main_uniforms
{
float4 shirr[7];
// ...
};
float3 shIrradiance(thread const float3& nor, thread spvUnsafeArray<float4, 7> (&shirr))
{
//...
}
fragment Material_mesh_frag_main_out Material_mesh_frag_main(Material_mesh_frag_main_in in [[stage_in]], constant Material_mesh_frag_main_uniforms& uniforms [[buffer(0)]])
{
//...
// Error:
// No matching function for call to 'shIrradiance'
// Candidate function not viable: 2nd argument ('const constant spvUnsafeArray<float4, 7>') is in address space constant, but parameter must be in address space 0
shIrradiance(n, uniforms.shirr);
}
This one still stands based on my initial testing.
Workaround:
uniform vec4 shirr[7];
vec3 shIrradiance(const vec3 nor, const vec4 shirr[7]) {
vec3 cl00 = vec3(shirr[0].x, shirr[0].y, shirr[0].z);
// ...
}
void main() {
// ...
shIrradiance(n, shirr);
}
Was fixed in b3c5f72.