From 05f4efca81461440fc94ec6fc225ac3bdac80dd8 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sat, 17 Aug 2024 18:47:57 +0200 Subject: [PATCH] buffer: align size to stride (#50) calculate the size to the stride we get from gb_bo_map to better align it. --- src/allocator/GBM.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/allocator/GBM.cpp b/src/allocator/GBM.cpp index 773fc00..8cb2c2a 100644 --- a/src/allocator/GBM.cpp +++ b/src/allocator/GBM.cpp @@ -224,13 +224,13 @@ SDMABUFAttrs Aquamarine::CGBMBuffer::dmabuf() { } std::tuple Aquamarine::CGBMBuffer::beginDataPtr(uint32_t flags) { - uint32_t dst_stride = 0; + uint32_t stride = 0; if (boBuffer) allocator->backend->log(AQ_LOG_ERROR, "beginDataPtr is called a second time without calling endDataPtr first. Returning old mapping"); else - boBuffer = gbm_bo_map(bo, 0, 0, attrs.size.x, attrs.size.y, flags, &dst_stride, &gboMapping); - // FIXME: assumes a 32-bit pixel format - return {(uint8_t*)boBuffer, attrs.format, attrs.size.x * attrs.size.y * 4}; + boBuffer = gbm_bo_map(bo, 0, 0, attrs.size.x, attrs.size.y, flags, &stride, &gboMapping); + + return {(uint8_t*)boBuffer, attrs.format, stride * attrs.size.y}; } void Aquamarine::CGBMBuffer::endDataPtr() {