I am trying to write a Metal compute shader for converting from RGB to YUV, but am getting build errors.
typedef struct {
float3x3 matrix;
float3 offset;
According to the Metal Shading Language Specification, the first parameter of all overloads of write
on texture2d<>
are 4-element vectors. This is the case even if the texture you're writing to has fewer than 4 components. So you can fix this by replacing the erroneous line with:
textureCbCr.write(half4(yuv.xyzz), uint2(gid.x / 2, gid.y / 2));
And the superfluous components will be masked out when performing the write.