[Mesa-dev] [PATCH 0/7] mesa/st: support for YUV EGLImages

Rob Clark robdclark at gmail.com
Thu Sep 8 20:30:33 UTC 2016


Since original RFC:
 + fixed up TODOs, review comments, and added support for NIR path as
   well as TGSI
 + Change how we pick which samplers to use for the U/V plane(s), to
   fill in any holes in SamplersUsed
 + changed CSC constants to match ITU-R BT.601 conversion (to align
   with what nir_lower_tex does and piglit expects)
 + added support for YVU420 (simply swaps 2nd and 3rd plane and treats
   as YUV420), since android wants this format for sw decoders
 + Added support for the rest of the shader stages.  Although as far
   as I can tell, android only needs it in FS (and the use-case for
   using a YUV external EGLImage in, for example, a VS is rather
   dubious.  Maybe we want one or two of the prep/cleanup patches
   anyways, but I'm fine with stashing the last patches on a branch
   somewhere until someone comes up with an actual use-case.

>From original cover-letter:

So, android and blob GLES drivers were left unchecked for too long, and
now we are stuck with this annoying OES_EGL_image_external extension and
the expectation that the driver can import multi-planar YUV buffers (via,
for example, EGL_EXT_image_dma_buf_import), despite the fact that nearly
all hardware out there needs this lowered to multiple samplers (one per
plane) and colorspace conversion in the shader.  It would be nice to
ignore this (mis)feature, except that by now it is required by android.

This patchset adds a TGSI lowering pass to handle 2 or 3 planar YUV.
And associated logic in mesa/st to append additional sampler view/state
to handle the additional planes.  There is no change needed in the
individual gallium drivers (provided you support R8 and R8G8).  The
extra logic and shader variants only kick in when the shader uses
samplerExternalOES.

I've got some simple test code, which uses gbm to create dmabuf's
so it should run on any driver:

 https://github.com/robclark/kmscube/commits/yuv-cube

You can find the latest versions of the patches here:

 https://github.com/freedreno/mesa/commits/wip-yuv


Rob Clark (7):
  mesa/st: add lowering pass for YUV samplers
  mesa/st: add nir pass to lower tex_src_plane
  mesa/st: support lowering multi-planar YUV
  mesa/st: a bit of basic_variant refactoring
  mesa/st: pass st_compute_program to st_get_cp_variant
  mesa/st: pass prog to st_get_basic_variant()
  mesa/st: support for YUV in VS/VS/GS/TCS/TEC..

 src/gallium/auxiliary/util/u_inlines.h             |   4 +-
 src/gallium/include/pipe/p_state.h                 |   9 +
 src/gallium/include/state_tracker/st_api.h         |   3 +
 src/gallium/state_trackers/dri/dri2.c              | 119 +++++-
 src/gallium/state_trackers/dri/dri_screen.c        |  11 +
 src/mesa/Makefile.sources                          |   3 +
 src/mesa/main/mtypes.h                             |  16 +
 src/mesa/program/ir_to_mesa.cpp                    |   1 +
 src/mesa/state_tracker/st_atom_sampler.c           |  41 +-
 src/mesa/state_tracker/st_atom_shader.c            |  27 +-
 src/mesa/state_tracker/st_atom_texture.c           |  58 +++
 src/mesa/state_tracker/st_cb_eglimage.c            |  18 +
 src/mesa/state_tracker/st_context.c                |  27 +-
 src/mesa/state_tracker/st_glsl_to_nir.cpp          |   1 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp         |   4 +
 src/mesa/state_tracker/st_manager.c                |   1 +
 src/mesa/state_tracker/st_nir.h                    |   3 +
 .../state_tracker/st_nir_lower_tex_src_plane.c     | 120 ++++++
 src/mesa/state_tracker/st_program.c                | 150 +++++--
 src/mesa/state_tracker/st_program.h                |  60 ++-
 src/mesa/state_tracker/st_texture.h                |  21 +
 src/mesa/state_tracker/st_tgsi_lower_yuv.c         | 447 +++++++++++++++++++++
 src/mesa/state_tracker/st_tgsi_lower_yuv.h         |  34 ++
 23 files changed, 1109 insertions(+), 69 deletions(-)
 create mode 100644 src/mesa/state_tracker/st_nir_lower_tex_src_plane.c
 create mode 100644 src/mesa/state_tracker/st_tgsi_lower_yuv.c
 create mode 100644 src/mesa/state_tracker/st_tgsi_lower_yuv.h

-- 
2.7.4



More information about the mesa-dev mailing list