aboutsummaryrefslogtreecommitdiff
path: root/render/allocator
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-05-08 22:17:26 +0200
committerSimon Ser <contact@emersion.fr>2023-05-21 20:28:45 +0000
commit96f3f3c92e8db16f9acc551b2673db70108988f2 (patch)
treeb5f5fdcfe6164fb38d61c4e02b3a1b71c40f9e2a /render/allocator
parent78a1ac540ec1bd1e336f066f6691451643e7b99d (diff)
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.
Diffstat (limited to 'render/allocator')
-rw-r--r--render/allocator/drm_dumb.c6
-rw-r--r--render/allocator/shm.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c
index 08ee0f0e..684ba2e3 100644
--- a/render/allocator/drm_dumb.c
+++ b/render/allocator/drm_dumb.c
@@ -44,6 +44,9 @@ static struct wlr_drm_dumb_buffer *create_buffer(
wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported",
format->format);
return NULL;
+ } else if (pixel_format_info_pixels_per_block(info) != 1) {
+ wlr_log(WLR_ERROR, "Block formats are not supported");
+ return NULL;
}
struct wlr_drm_dumb_buffer *buffer = calloc(1, sizeof(*buffer));
@@ -55,7 +58,8 @@ static struct wlr_drm_dumb_buffer *create_buffer(
buffer->drm_fd = alloc->drm_fd;
- if (drmModeCreateDumbBuffer(alloc->drm_fd, width, height, info->bpp, 0,
+ uint32_t bpp = 8 * info->bytes_per_block;
+ if (drmModeCreateDumbBuffer(alloc->drm_fd, width, height, bpp, 0,
&buffer->handle, &buffer->stride, &buffer->size) != 0) {
wlr_log_errno(WLR_ERROR, "Failed to create DRM dumb buffer");
goto create_destroy;
diff --git a/render/allocator/shm.c b/render/allocator/shm.c
index 9e49a144..55a8fab2 100644
--- a/render/allocator/shm.c
+++ b/render/allocator/shm.c
@@ -71,8 +71,7 @@ static struct wlr_buffer *allocator_create_buffer(
wlr_buffer_init(&buffer->base, &buffer_impl, width, height);
// TODO: consider using a single file for multiple buffers
- int bytes_per_pixel = info->bpp / 8;
- int stride = width * bytes_per_pixel; // TODO: align?
+ int stride = pixel_format_info_min_stride(info, width); // TODO: align?
buffer->size = stride * height;
buffer->shm.fd = allocate_shm_file(buffer->size);
if (buffer->shm.fd < 0) {