render/pixel_format: add pixel_format_get_opaque_substitute()

We'll soon move opaque substitutes outside of the format table.
Prepare the work by introducing a separate function to get this
piece of information.
This commit is contained in:
Simon Ser 2026-02-19 15:43:51 +01:00
parent f295d0322a
commit 2d95d8d292
4 changed files with 20 additions and 10 deletions

View file

@ -163,11 +163,10 @@ static struct wlr_drm_fb *drm_fb_create(struct wlr_drm_backend *drm,
attribs.modifier)) {
// The format isn't supported by the plane. Try stripping the alpha
// channel, if any.
const struct wlr_pixel_format_info *info =
drm_get_pixel_format_info(attribs.format);
if (info != NULL && info->opaque_substitute != DRM_FORMAT_INVALID &&
wlr_drm_format_set_has(formats, info->opaque_substitute, attribs.modifier)) {
attribs.format = info->opaque_substitute;
uint32_t opaque_substitute = pixel_format_get_opaque_substitute(attribs.format);
if (opaque_substitute != DRM_FORMAT_INVALID &&
wlr_drm_format_set_has(formats, opaque_substitute, attribs.modifier)) {
attribs.format = opaque_substitute;
} else {
wlr_log(WLR_DEBUG, "Buffer format 0x%"PRIX32" with modifier "
"0x%"PRIX64" cannot be scanned out",