Commit Graph

15 Commits

Author SHA1 Message Date
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Simon Ser c74f89d4f8 Avoid using memcpy() to copy structs
We can just use a regular assignment instead. This is more
type-safe since there is no need to provide the struct size.

The remaining memcpy() calls perform array copies or copies from
void pointers (which may be unaligned).
2023-08-03 14:40:28 +00:00
Simon Ser fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Simon Ser 96f3f3c92e render/pixel-format: add support for block-based formats
Some formats like sub-sampled YCbCr use a block of bytes to
store the color values for more than one pixel. Update our format
table to be able to handle such formats.
2023-05-21 20:28:45 +00:00
Simon Ser fdb24d19ca allocator/drm_dumb: use libdrm dumb buffer helpers
References: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/272
2022-11-17 08:05:55 +00:00
Simon Ser 58d4cfaca3 render/allocator/drm_dumb: drop finish_buffer()
Simplify things a bit.
2022-10-01 19:45:29 +00:00
Simon Ser c659792d7b render/allocator/drm_dumb: fix error handling
In the CREATE_DUMB error code-path, we'd only free() the buffer,
however it's already inserted in the alloc->buffers list at this
point.

Instead, make sure finish_buffer() is safe to call (by populating
drm_fd) and call that function.
2022-10-01 19:45:29 +00:00
Simon Ser 3e7ea8715b render/allocator/drm_dumb: get format info before allocating
Simplifies error handling a bit.
2022-10-01 19:45:29 +00:00
Simon Ser d81f68d2b4 render/allocator/drm_dumb: check modifier list
Check that the modifier list passed as input contains either
INVALID or LINEAR. We don't support others.
2022-10-01 19:45:29 +00:00
Simon Ser 5ef8a18a29 render/allocator/drm_dumb: advertise LINEAR instead of INVALID modifier
INVALID means that the modifier is implicit. However dumb buffers
are guaranteed to be LINEAR, so let's just advertise this. Fixes
cursors with the DRM backend: cursor planes usually only support
LINEAR.
2022-10-01 19:45:29 +00:00
Simon Ser 39b68ea47a buffer: extract interface to separate header
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3389
2022-03-03 15:39:05 +01:00
Simon Zeni 02a1ae169e render/allocator: make wlr_allocator part of the public API 2021-11-09 15:26:36 +00:00
Simon Ser 4e7a8707cc buffer: add data_ptr access flags
This allows callers to specify the operations they'll perform on
the returned data pointer. The motivations for this are:

- The upcoming Linux MAP_NOSIGBUS flag may only be usable on
  read-only mappings.
- gbm_bo_map with GBM_BO_TRANSFER_READ hurts performance.
2021-09-10 13:16:10 -04:00
Simon Ser d9d8fc1ab9 render/allocator: re-open GBM FD
Using the same DRM file description for the DRM backend and for the
GBM allocator will result in GEM handle ref'counting issues [1].
Re-open the DRM FD to fix these issues.

[1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/110
2021-09-01 15:17:05 -04:00
Simon Ser 3ce2ea9e16 Move allocator stuff into new directory
Add render/allocator/ and include/render/allocator/ to hold
everything allocator-related.
2021-08-25 09:57:20 -04:00
Renamed from render/drm_dumb_allocator.c (Browse further)