mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-01 16:55:59 +01:00
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.
This commit is contained in:
parent
7ea0e9f277
commit
c4635c68d2
1 changed files with 10 additions and 0 deletions
|
@ -152,6 +152,16 @@ struct wlr_drm_format *wlr_drm_format_intersect(
|
||||||
const struct wlr_drm_format *a, const struct wlr_drm_format *b) {
|
const struct wlr_drm_format *a, const struct wlr_drm_format *b) {
|
||||||
assert(a->format == b->format);
|
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_cap = a->len < b->len ? a->len : b->len;
|
||||||
size_t format_size = sizeof(struct wlr_drm_format) +
|
size_t format_size = sizeof(struct wlr_drm_format) +
|
||||||
format_cap * sizeof(a->modifiers[0]);
|
format_cap * sizeof(a->modifiers[0]);
|
||||||
|
|
Loading…
Reference in a new issue