Commit Graph

40 Commits

Author SHA1 Message Date
Kenny Levinsen 73dd934794 render/drm_format_set: Clean up on union failure
If drm_format_set_extend fails, we need to make sure each wlr_drm_format
is cleaned up together with the formats array. Finish the set to take
care of it.
2024-02-22 23:03:50 +01:00
Kirill Primak 20b99ed854 render/drm_format_set: fix possible leak on realloc error 2024-01-17 15:44:37 +00:00
Simon Ser 7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Tobias Predel e449c1dec8 wlr_drm_format_set_copy: Do not allocate heap
Address Sanitizer reported two memory leaks because of
fmt not being freed in wlr_drm_format_set_copy.

This commit fixes the memory leak by removing the
allocation to the heap. The struct is allocated to the
stack anyway.
2023-05-14 17:50:08 +02:00
Alexander Orzechowski 47e175ae7f wlr_drm_format_set_intersect: Clear destination before trying to write to it 2023-05-11 14:43:22 -04:00
Alexander Orzechowski 300bd80772 wlr_drm_format_set: Store formats on array 2023-05-11 18:25:52 +02:00
Alexander Orzechowski 90d08f8f1c wlr_drm_format: Rework wlr_drm_format_intersect
Now it takes a reference to a destination format
2023-05-11 18:24:43 +02:00
Alexander Orzechowski 340700cb70 wlr_drm_format: Change wlr_drm_format_dup to copy 2023-05-11 18:24:43 +02:00
Alexander Orzechowski 099a147439 wlr_drm_format: Change wlr_drm_format_create to init 2023-05-11 18:24:40 +02:00
Alexander Orzechowski e427e019c4 wlr_drm_format: Don't take double pointer in wlr_drm_format_add 2023-05-11 03:51:01 -04:00
Alexander Orzechowski e6879616e7 wlr_drm_format: Make structure constant length
Don't store modifiers as part of the struct.
2023-05-11 03:51:01 -04:00
Alexander Orzechowski b45396c790 wlr_drm_format: Introduce drm_format_finish 2023-05-11 03:51:01 -04:00
Alexander Orzechowski 5adb1be3a7 drm_format_set_intersect: Require initialized dst and remove assert
The usages in linux_dmabuf zero out the dst before passing it so this
change should be fine.
2023-05-04 18:19:33 +00:00
Alexander Orzechowski 1ee75786b4 drm_format_set_union: Require initialized dst and remove assert 2023-05-04 18:19:33 +00:00
Austin Shafer ec37d55a5e Add union function for format sets 2023-05-03 12:06:48 -04:00
Brett Ernst 7d9938c957 drm_format_set: fix realloc size 2023-03-16 18:13:11 -07:00
Simon Zeni 4b3bbb0c4f render/drm_format_set: fill dst in wlr_drm_format_set_copy 2022-12-02 11:47:47 -05:00
Simon Ser c9b378d21a render/drm-format-set: add wlr_drm_format_set_copy() 2022-12-02 14:27:07 +00:00
Simon Ser 7201aae3d6 render/drm-format-set: add wlr_drm_format_set_intersect
This intersects two DRM format sets. This is useful for implementing
DMA-BUF feedback in compositors, see e.g. the Sway PR [1].

[1]: https://github.com/swaywm/sway/pull/6313
2021-12-03 14:42:41 +00:00
Simon Ser 98f2efde98 render/drm_format_set: remove special LINEAR case
This was used to make the intersection of INVALID and LINEAR result
in LINEAR. We can now just require LINEAR to be in both lists.
2021-11-26 16:40:53 +00:00
Simon Ser affe9eda57 Require INVALID for implicit format modifiers
See [1] for the motivation.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-11-26 16:40:53 +00:00
Simon Ser d78cb808b1 render/drm_format_set: add wlr_drm_format_has 2021-11-26 16:40:53 +00:00
Demi Marie Obenour b5d4bc3c62 Improve wlr_drm_format documentation
A wlroots user can easily get confused and think that `cap` refers to
wlroots buffer capabilities, not array capacity.
2021-11-17 16:35:20 +00:00
Simon Ser 323b8498ad Revert "render/drm_format_set: add wlr_drm_format_has"
This reverts commit 833437d592.
2021-10-01 09:26:05 -06:00
Simon Ser 1d7e438d8a Revert "Require INVALID for implicit format modifiers"
This reverts commit ea7357b703.
2021-10-01 09:26:05 -06:00
Simon Ser 42138a073b Revert "render/drm_format_set: remove special LINEAR case"
This reverts commit 6d281d96cb.
2021-10-01 09:26:05 -06:00
Simon Ser 6d281d96cb render/drm_format_set: remove special LINEAR case
This was used to make the intersection of INVALID and LINEAR result
in LINEAR. We can now just require LINEAR to be in both lists.
2021-10-01 09:21:50 -06:00
Simon Ser ea7357b703 Require INVALID for implicit format modifiers
See [1] for the motivation.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-10-01 09:21:50 -06:00
Simon Ser 833437d592 render/drm_format_set: add wlr_drm_format_has 2021-10-01 09:21:50 -06:00
Simon Ser c4635c68d2 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.
2020-12-30 11:17:43 +01:00
Simon Ser d37214cb16 render/drm_format_set: add wlr_drm_format_{create,add} 2020-12-18 09:41:12 +01:00
Simon Ser 8a6930c138
render/drm_format_set: assert len <= cap when duplicating 2020-12-08 23:35:05 +01:00
Simon Ser 29da97c185
render/drm_format_set: allocate using cap when duplicating
In wlr_drm_format_dup, allocate the new wlr_drm_format using cap instead
of len. This makes it so the cap field is up-to-date and the chunk of
memory isn't too small if we append new modifiers (we don't allow this
yet but might in the future).
2020-12-08 16:02:44 +01:00
Simon Ser 82443ea46b render/drm_format_set: introduce wlr_drm_format_intersect
Intersects modifiers from two wlr_drm_format structs. If either format
doesn't support modifiers, the resulting format won't support modifiers.
2020-12-03 10:52:25 +01:00
Simon Ser 7c6212a0f7 render/drm_format_set: introduce wlr_drm_format_dup 2020-11-15 22:48:42 +01:00
Simon Ser 01d4506253 render/drm_format_set: disallow DRM_FORMAT_INVALID
It doesn't make sense to add DRM_FORMAT_INVALID to a format set. Adding
an assertion allows us to safely query the format set with
DRM_FORMAT_INVALID. See [1].

[1]: https://github.com/swaywm/wlroots/pull/2021#discussion_r385839668
2020-04-22 22:14:44 +02:00
Drew DeVault 540e23d102 Revert "render/drm: keep old drm_format if realloc fails"
This reverts commit c1be9b6945.
2019-08-12 19:53:39 +09:00
Antonin Décimo c1be9b6945 render/drm: keep old drm_format if realloc fails 2019-08-12 09:37:21 +09:00
Simon Ser e516ea4c79 backend/drm: check format when scanning out DMA-BUF 2019-06-07 09:06:11 -04:00
Scott Anderson c01b81c99c
render: introduce wlr_drm_format_set
This types adds a container for formats + modifiers.

A list that is of [format [modifier]] was chosen instead of
[format modifer] because that is how GBM accepts them.

Co-Authored-By: emersion <contact@emersion.fr>
2019-04-01 19:15:56 +03:00