Metal RGB to YUV conversion compute shader

后端 未结 1 1961
刺人心
刺人心 2021-01-22 05:40

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;         


        
相关标签:
1条回答
  • 2021-01-22 05:54

    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.

    0 讨论(0)
提交回复
热议问题