Search code examples
metalgpucore-video

yuv10 bits texture in Metal


I'm trying to convert my openGL shaders into metal shaders for converting yuv10 bits texture to rgba texture.

With openGL I was using this GLSL code from this link

I did the conversion, but the result is not the one I expected.

I think it is because I use

 tex2d.sample(sampler2d, x, y).rgba;

instead of

texelFetch(tex, ivec2(sourceColumnIndexY, texcoordDenorm.y)

Is there any equivalent to texelFetch in Metal ?


Solution

  • You don't really explain in what way "the result is not the one I expected". You also didn't explain things like what Metal pixel format you're using for the input texture.

    Anyway, the Metal function that corresponds to texelFetch() is simply the read() member function of the texture types. For example, texture2d<T> has these two member functions:

    Tv read(uint2 coord, uint lod = 0) const
    Tv read(ushort2 coord, ushort lod = 0) const
    

    where Tv is the 4-component vector whose component type is T.