According to Apple's Metal shading language specification, texture cubes have a read method,
read(uint2 coord, uint face, uint lod = 0) const
However, when I try to build this shader, I get a compiler error,
fragment half4 passFragment(VertexInOut inFrag [[stage_in]],
texturecube<float, access::read> tex [[ texture(0) ]])
{
float4 out = tex.read(uint2(0,0), uint(0));
return half4(out);
}
The error is,
No member named 'read' in 'metal::texturecube<float, metal::access::read>'
If I remove the access qualifier, then I get,
No member named 'read' in 'metal::texturecube<float, metal::access::sample>'
I also tried changing the type from float to int or short, but I get the same error. Frustrating that there's no header to look at...
Any ideas?
It appears that texturecube::read()
is only available on macOS.
There are, in fact, headers available. Look in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/clang/3.5/include/metal.
In the metal_texture header, you'll see that the declaration of read()
is inside of a preprocessor conditional (#if
) and is only declared if the macro __HAVE_TEXTURE_CUBE_READ__
is defined. On macOS, that's defined in the metal_config header. On iOS, it's not defined.