aboutsummaryrefslogtreecommitdiff
path: root/render/drm_format_set.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-10-01 17:22:04 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-10-01 09:26:05 -0600
commit42138a073bcfa3f18d5467cf6f2ded19c3667e96 (patch)
tree4511a376b188516f7e0ba3c7534ec22a4cd2979d /render/drm_format_set.c
parent6d281d96cb93b8de972039d5cb00bfce49d9a58c (diff)
Revert "render/drm_format_set: remove special LINEAR case"
This reverts commit 6d281d96cb93b8de972039d5cb00bfce49d9a58c.
Diffstat (limited to 'render/drm_format_set.c')
-rw-r--r--render/drm_format_set.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/render/drm_format_set.c b/render/drm_format_set.c
index 36cdcd5d..8dc48675 100644
--- a/render/drm_format_set.c
+++ b/render/drm_format_set.c
@@ -144,6 +144,18 @@ struct wlr_drm_format *wlr_drm_format_intersect(
const struct wlr_drm_format *a, const struct wlr_drm_format *b) {
assert(a->format == b->format);
+ // Special case: if a format only supports LINEAR and the other supports
+ // implicit modifiers, force LINEAR. This will force the allocator to
+ // create a buffer with a linear layout instead of an implicit modifier.
+ if (a->len == 1 && a->modifiers[0] == DRM_FORMAT_MOD_LINEAR &&
+ wlr_drm_format_has(b, DRM_FORMAT_MOD_INVALID)) {
+ return wlr_drm_format_dup(a);
+ }
+ if (b->len == 1 && b->modifiers[0] == DRM_FORMAT_MOD_LINEAR &&
+ wlr_drm_format_has(a, DRM_FORMAT_MOD_INVALID)) {
+ return wlr_drm_format_dup(b);
+ }
+
size_t format_cap = a->len < b->len ? a->len : b->len;
size_t format_size = sizeof(struct wlr_drm_format) +
format_cap * sizeof(a->modifiers[0]);