Skip to content

gallium/dri: Enable Y21x and Y41x formats, improve YUYV and UYVY formats

Ian Romanick requested to merge idr/mesa:review/yuv-formats-iris into main

There are four main parts of this MR.

The first four commits are just some small cleanups that I noticed while implementing the rest.

  • util/format: Delete trailing whitespace
  • util/format: Add missing documentation for pixel block depth
  • dri: Fix typo before __DRI_IMAGE_COMPONENTS defines
  • egl/dri2: Bump libdrm version requirement to 2.4.97

The next four commits enable Y410, Y412, and Y416 formats in Gallium drivers. These are non-subsampled, non-planar, YUV + alpha formats. These formats are pretty straightforward. I had to enhance nir_lower_tex because there was no way to get a component ordering that would match the expectations of the existing lowerings.

  • nir/lower_tex: Add support for lowering Y41x formats
  • util/format: Add Y41x formats
  • egl/dri2: Add Y41x formats
  • gallium/dri: Add Y41x formats

The next three commits enable Y210, Y212, and Y216 formats in Gallium drivers. These are subsampled (each pixel has either U or V), non-planar, YUV formats.

  • util/format: Add Y21x formats
  • egl/dri2: Add Y21x formats
  • gallium/dri: Add Y21x formats

Finally, the last three commits improve the support for YUYV formats. These are subsampled (each pixel has either U or V), non-planar, YUV formats. Currently, these are lowered to use two samplers. One sampler is used for Y, and the other sampler is used for UV. This is done to get the correct sampling rate (and filtering) on each component. There is quite a bit of hardware that also supports a subsampled RGB format R8G8_R8B8. In this format, every pixel has R and one of G or B. This format can be used to handle YUYV (and UYVY) with a single sampler. YUV to RGB colorspace conversion is still performed in the shader.

  • intel/isl: Add mappings for PIPE_FORMAT_R8G8_R8B8_UNORM and PIPE_FORMAT_G8R8_B8R8_UNORM
  • mesa: Add R8G8_R8B8 and G8R8_B8R8 formats
  • nir/lower_tex: Add support for lowering YUYV formats

The core Mesa changes for the last part are... a bit sketchy. I basically beat on it with a hammer until it compiled and linked. I would definitely appreciate any feedback on improving that part.

I know that @tpalli and @anholt have worked on a bunch of YUV stuff in the Gallium / DRI layer. Grepping through driver code, it looks like only radeonsi and nouveau (NV50+?) will be affected by the last changes. Hopefully @mareko and @imirkin can give at least that part a look or a test drive. r600 supports R8G8_R8B8, but it appears to also natively supports YUYV.

Edited by Ian Romanick

Merge request reports