[PATCH 0/4] Weston: add support for YUV buffers

Gwenole Beauchesne gb.devel at gmail.com
Fri Apr 20 08:17:26 PDT 2012


Hi,

Here is a first round of patches for supporting YUV buffers in Weston.
It theoritically possible to support planar YUV from SHM buffers but I
have only tested with VA-API on GenX (NV12, YUV 4:2:0 and 4:2:2).

Some changes are needed in Mesa, but I wanted to get your opinion on
this model first. Rationale: a Wayland buffer is actually several individual
sub buffers (one for each plane) that can be passed to eglCreateImageKHR().
Some people would argue to use OES_EGL_image_external, but I wanted to make
the usage of shaders explicit. Besides, for other projects, there was also
a need to map individual planes as separate buffers so that to perform
some postprocessing with further shader code (noise reduction, sharpening, etc.).

So, I extended EGL_WAYLAND_BUFFER_WL spec to use a new attribute
that specifies that actual plane to map: EGL_WAYLAND_BUFFER_PLANE_WL. The
whole magic to calculate stride, offsets et al. is performed in Mesa with
the help of Wayland buffer layouts.

For rendering, you just need to create an EGLImage and the corresponding
texture for each plane of the YUV buffer. Then, you provide the shader
with the current restriction that EXT_texture_rg is required. i.e. single components
(e.g. Y) are mapped to GL_R8 [.r] and two components (e.g. UV for NV12) are mapped
to GL_RG8 [.r/.g]. I could have sticked to standard GL_LUMINANCE [.x] and
GL_LUMINANCE_ALPHA [.x/.w] but those tended to be deprecated in desktop GL IIRC
and I wanted a means that could let the user use single glsl source code for
rendering (depending on his winsys).

The other idea to hide stride, offsets into Mesa was that wl_drm_create_buffer_with_layout()
could also take a future "flags" argument that would denote interleaved frames
(top/bottom fields).

Issues:
- EXT_texture_rg requirement, could be fixed with an extra EGL attribute.
- Use shaders to render from YUV even if some HW could sample from YUV textures directly.

Regards,
Gwenole Beauchesne (4):
  compositor: prepare for multi-planar surfaces.
  compositor: factor out RGB shader.
  compositor: add YUV shaders.
  compositor: handle YUV buffers.

 src/compositor-drm.c     |   14 ++--
 src/compositor-wayland.c |    4 +-
 src/compositor.c         |  226 ++++++++++++++++++++++++++++++++++++----------
 src/compositor.h         |   12 ++-
 4 files changed, 197 insertions(+), 59 deletions(-)

-- 
1.7.5.4



More information about the wayland-devel mailing list