Commit graph

6 commits

Author SHA1 Message Date
Daniel Stone 820f3ae866 gl-renderer: Add support for WL_SHM_FORMAT_YUV444
We support this as an explicit YUV fallback path in gl-renderer's dmabuf
EGLImage import path, so might as well support it in the SHM path, given
it's just YUV420 with no subsampling.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-05-20 11:24:41 +00:00
Pekka Paalanen f6acdc5db0 tests: free pixman image in yuv-buffer-test
Fixes all ASan reported leaks in this test when using AMD Mesa driver.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-06-28 14:21:27 +03:00
Pekka Paalanen f6a8aa15f5 tests: add XYUV8888 to yuv-test
This will hit the XYUV shader variant in GL-renderer that was not
covered in the test suite before.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:36:46 +02:00
Pekka Paalanen 4b301fe7f2 Add weston-drm-fourcc.h
This header is for sharing fallback definitions for drm_fourcc.h. A new
test in tests/yuv-buffer-test.c is going to be needing XYUV8888 format,
and more new formats will be expected with HDR supports.

Share these fallback definitions in one place instead of copying them
all over.

All users of drm_fourcc.h are converted to include weston-drm-fourcc.h
instead for consistency: have the same definitions available everywhere.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 14:35:03 +02:00
Harish Krupo 7ef26886f5 gl-renderer: implement intermediate framebuffer (shadow)
Proper color management will need blending done with linear light pixel
values, that is, EOTF applied before blending, and then inverse-EOTF
applied for scanout after blending. The simplest way to set that up is
to use an intemediate framebuffer a.k.a shadow buffer containing the
composited image in linear light values, then blit from that to the
actual framebuffer.

This patch implements the shadow buffer, but the linear light
blending is left for another patch. This allows GL-renderer to turn
WESTON_CAP_COLOR_OPS on.

Half-float is chosen as the buffer format because linear light values
require more bits to encode with sufficient precision than the usual
non-linear pixel values.

v2: Use /* */ instead of // (Pekka)
    Rename fbo and tex to shadow_{fbo,tex} (Pekka)
    Check for OpenGLES capabilities before creating
    shadow_{tex,fbo} (Pekka)

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>

v3: Rebased.
    Simplified GL version checks (Sebastian)
    Apply changes from "libweston: add color ops cap and bool renderer
    shadow buffer"
    Renamed supports_half_float_texture to has_gl_half_float to
    follow the existing naming pattern.
    Introduce gl_renderer_create_shadow_16f().
    Undo moving of glViewport() call.
    Replace half_float_texture_enabled with shadow_exists().
    Introduce struct gl_output_state_shadow.
    Assert no resizing with shadow.
    Fix triangle fan debug.
    Rename repaint_from_texture() to blit_shadow_to_output().
    Rewrite commit message because linear light blending is not
    implemented in this patch.
    Fix blit_shadow_to_output() for scaled/transformed outputs and
    remove redundant code.
    Fix has_gl_half_float determination.

v4: Disable blending in blit_shadow. (Daniel)
    Port to gl_renderer_get_program().
    Make a generic fbo-texture struct with parameterized format. (Daniel)
    Change has_gl_half_float into gl_half_float_type.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2021-02-25 13:16:02 +02:00
Pekka Paalanen ae12b9596d tests: add yuv-buffer test
This adds a test to ensure that the wl_shm formats YUV420, NV12 and YUYV
are decoded and converted to RGB correctly in GL-renderer.

The test deliberately uses a 256 x 256 test image so that effects from
width vs. pitch vs. stride cannot be observed, and row padding is zero.
Also padding between planes is zero. Attempting to use a test image with
less "round" dimensions lead to stride mismatch in GL-renderer, likely
due to GL_UNPACK_ALIGNMENT being left at value 4. It is unclear if YUV
wl_shm buffers' row stride needs to be aligned to 4 bytes or not, so I
did not pursue fixing it. GL-renderer seems to be confusing width, pitch
and stride even further, and not e.g. allow padding with ARGB buffers.
See also: https://gitlab.freedesktop.org/wayland/weston/-/issues/354

Furthermore, the test arranges so that each 2x2 pixel block has the same
color. This avoids having to consider chroma siting when sub-sampling.
This way all the test cases can use the same reference image.

The source image chocolate-cake.png is taken and copyright by Pekka
Paalanen, hereby licensed as
http://creativecommons.org/licenses/by-sa/4.0/ .

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2020-12-17 09:34:09 +00:00