gl-renderer: add support for (a|x)bgr16161616 shm formats

These formats are useful because they are often easier to produce
on CPU than half-float formats, and abgr16161616 has both >= 10bpc
color channels and adequate alpha, unlike abgr2101010.

The 16-bpc textures created from buffers with these formats require
the GL_EXT_texture_norm16 extension.

As WL_SHM_FORMAT_ABGR16161616 was introduced in libwayland 1.20,
update Weston's build requirements and CI.

The formats also needed to be registered in the pixel format table,
and defined in a fallback path if recent libdrm is not available.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
This commit is contained in:
Manuel Stoeckl 2022-01-04 14:32:44 -05:00 committed by Daniel Stone
parent 30de938624
commit b0ed4a2e3b
7 changed files with 48 additions and 4 deletions

View File

@ -43,7 +43,7 @@
variables:
FDO_UPSTREAM_REPO: wayland/weston
FDO_REPO_SUFFIX: "$BUILD_OS/$BUILD_ARCH"
FDO_DISTRIBUTION_TAG: '2021-11-25.0-dmabuf-feedback'
FDO_DISTRIBUTION_TAG: '2022-01-22.0-for-axbgr16161616'
include:

View File

@ -94,7 +94,7 @@ fi
# Build and install Wayland; keep this version in sync with our dependency
# in meson.build.
git clone --branch 1.18.0 --depth=1 https://gitlab.freedesktop.org/wayland/wayland
git clone --branch 1.20.0 --depth=1 https://gitlab.freedesktop.org/wayland/wayland
cd wayland
git show -s HEAD
mkdir build

View File

@ -332,6 +332,15 @@ static const struct pixel_format_info pixel_format_table[] = {
BITS_RGBA_FIXED(10, 10, 10, 2),
.opaque_substitute = DRM_FORMAT_BGRX1010102,
},
{
DRM_FORMAT(XBGR16161616),
BITS_RGBA_FIXED(16, 16, 16, 0),
},
{
DRM_FORMAT(ABGR16161616),
BITS_RGBA_FIXED(16, 16, 16, 16),
.opaque_substitute = DRM_FORMAT_XBGR16161616,
},
{
DRM_FORMAT(YUYV),
SAMPLER_TYPE(EGL_TEXTURE_Y_XUXV_WL),

View File

@ -156,6 +156,7 @@ struct gl_renderer {
bool has_texture_type_2_10_10_10_rev;
bool has_gl_texture_rg;
bool has_texture_norm16;
struct gl_shader *current_shader;
struct gl_shader *fallback_shader;

View File

@ -1822,6 +1822,7 @@ gl_format_from_internal(GLenum internal_format)
return GL_RED_EXT;
case GL_RG8_EXT:
return GL_RG_EXT;
case GL_RGBA16_EXT:
case GL_RGBA16F:
case GL_RGB10_A2:
return GL_RGBA;
@ -2035,6 +2036,24 @@ gl_renderer_attach_shm(struct weston_surface *es, struct weston_buffer *buffer,
gl_pixel_type = GL_HALF_FLOAT;
es->is_opaque = true;
break;
case WL_SHM_FORMAT_ABGR16161616:
if (!gr->has_texture_norm16)
goto unsupported;
gs->shader_variant = SHADER_VARIANT_RGBA;
pitch = wl_shm_buffer_get_stride(shm_buffer) / 8;
gl_format[0] = GL_RGBA16_EXT;
gl_pixel_type = GL_UNSIGNED_SHORT;
es->is_opaque = false;
break;
case WL_SHM_FORMAT_XBGR16161616:
if (!gr->has_texture_norm16)
goto unsupported;
gs->shader_variant = SHADER_VARIANT_RGBX;
pitch = wl_shm_buffer_get_stride(shm_buffer) / 8;
gl_format[0] = GL_RGBA16_EXT;
gl_pixel_type = GL_UNSIGNED_SHORT;
es->is_opaque = true;
break;
#endif
case WL_SHM_FORMAT_YUV420:
gs->shader_variant = SHADER_VARIANT_Y_U_V;
@ -3766,6 +3785,10 @@ gl_renderer_display_create(struct weston_compositor *ec,
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR16161616F);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XBGR16161616F);
}
if (gr->has_texture_norm16) {
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_ABGR16161616);
wl_display_add_shm_format(ec->wl_display, WL_SHM_FORMAT_XBGR16161616);
}
#endif
if (gr->gl_supports_color_transforms)
@ -3942,6 +3965,9 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
weston_check_egl_extension(extensions, "GL_EXT_texture_type_2_10_10_10_REV"))
gr->has_texture_type_2_10_10_10_rev = true;
if (weston_check_egl_extension(extensions, "GL_EXT_texture_norm16"))
gr->has_texture_norm16 = true;
if (gr->gl_version >= gr_gl_version(3, 0) ||
weston_check_egl_extension(extensions, "GL_EXT_texture_rg"))
gr->has_gl_texture_rg = true;

View File

@ -145,8 +145,8 @@ if get_option('deprecated-wl-shell')
config_h.set('HAVE_DEPRECATED_WL_SHELL', '1')
endif
dep_wayland_server = dependency('wayland-server', version: '>= 1.18.0')
dep_wayland_client = dependency('wayland-client', version: '>= 1.18.0')
dep_wayland_server = dependency('wayland-server', version: '>= 1.20.0')
dep_wayland_client = dependency('wayland-client', version: '>= 1.20.0')
dep_pixman = dependency('pixman-1', version: '>= 0.25.2')
dep_libinput = dependency('libinput', version: '>= 0.8.0')
dep_libevdev = dependency('libevdev')

View File

@ -38,4 +38,12 @@
#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
#endif
#ifndef DRM_FORMAT_XBGR16161616
#define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */
#endif
#ifndef DRM_FORMAT_ABGR16161616
#define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */
#endif
#endif