aboutsummaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-12-04 17:09:00 +0100
committerIlia Bozhinov <ammen99@gmail.com>2020-12-30 11:17:43 +0100
commitc4635c68d25b92564a4568f435526108448fa0ca (patch)
tree15a6538f8a7b3d4cc1482954f0c773dc09c0fa50 /render
parent7ea0e9f27790a9890e97b3068a681f958197c0e5 (diff)
render/drm_format_set: add special case for LINEAR-only formats
Our wlr_format_set structs don't hold GBM usage flags. Instead, users who want to get a LINEAR buffer can use the DRM_FORMAT_MOD_LINEAR modifier even if the kernel driver doesn't support modifiers. Add a special case to wlr_drm_format_intersect to properly handle this situation.
Diffstat (limited to 'render')
-rw-r--r--render/drm_format_set.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/render/drm_format_set.c b/render/drm_format_set.c
index 634d9070..bd8f0cb7 100644
--- a/render/drm_format_set.c
+++ b/render/drm_format_set.c
@@ -152,6 +152,16 @@ 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 doesn't
+ // support any modifier, force LINEAR. This will force the allocator to
+ // create a buffer with a LINEAR layout instead of an implicit modifier.
+ if (a->len == 0 && b->len == 1 && b->modifiers[0] == DRM_FORMAT_MOD_LINEAR) {
+ return wlr_drm_format_dup(b);
+ }
+ if (b->len == 0 && a->len == 1 && a->modifiers[0] == DRM_FORMAT_MOD_LINEAR) {
+ return wlr_drm_format_dup(a);
+ }
+
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]);