From da616406088ffaac67cc35fbca94d27828d2156a Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 10 Nov 2024 22:43:49 +0000 Subject: [PATCH] reer --- include/aquamarine/allocator/DRMDumb.hpp | 6 +++--- src/allocator/DRMDumb.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/aquamarine/allocator/DRMDumb.hpp b/include/aquamarine/allocator/DRMDumb.hpp index 1ca37bc..a5eca2c 100644 --- a/include/aquamarine/allocator/DRMDumb.hpp +++ b/include/aquamarine/allocator/DRMDumb.hpp @@ -29,9 +29,9 @@ namespace Aquamarine { // Hyprutils::Math::Vector2D pixelSize; uint32_t stride = 0, handle = 0; - uint64_t size = 0; - uint8_t* data = nullptr; - int primeFD = -1; + uint64_t bufferLen = 0; + uint8_t* data = nullptr; + int primeFD = -1; // SDMABUFAttrs attrs{.success = false}; diff --git a/src/allocator/DRMDumb.cpp b/src/allocator/DRMDumb.cpp index 9170e4b..e1fb32f 100644 --- a/src/allocator/DRMDumb.cpp +++ b/src/allocator/DRMDumb.cpp @@ -21,7 +21,7 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer swapchain) : allocator(allocator_) { attrs.format = params.format; - if (int ret = drmModeCreateDumbBuffer(allocator->drmFD(), params.size.x, params.size.y, 32, 0, &handle, &stride, &size); ret < 0) { + if (int ret = drmModeCreateDumbBuffer(allocator->drmFD(), params.size.x, params.size.y, 32, 0, &handle, &stride, &bufferLen); ret < 0) { allocator->backend->log(AQ_LOG_ERROR, std::format("failed to create a drm_dumb buffer: {}", strerror(-ret))); return; } @@ -31,6 +31,7 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params, attrs.size = pixelSize; attrs.strides.at(0) = stride; attrs.planes = 1; + size = pixelSize; uint64_t offset = 0; if (int ret = drmModeMapDumbBuffer(allocator->drmFD(), handle, &offset); ret < 0) { @@ -38,14 +39,14 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params, return; } - data = (uint8_t*)mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, allocator->drmFD(), offset); + data = (uint8_t*)mmap(nullptr, bufferLen, PROT_READ | PROT_WRITE, MAP_SHARED, allocator->drmFD(), offset); if (data == MAP_FAILED) { allocator->backend->log(AQ_LOG_ERROR, "failed to mmap a drm_dumb buffer"); return; } // set the entire buffer so we dont get garbage - memset(data, 0xFF, size); + memset(data, 0xFF, bufferLen); if (int ret = drmPrimeHandleToFD(allocator->drmFD(), handle, DRM_CLOEXEC, &primeFD); ret < 0) { allocator->backend->log(AQ_LOG_ERROR, std::format("failed to map a drm_dumb buffer: {}", strerror(-ret))); @@ -68,7 +69,7 @@ Aquamarine::CDRMDumbBuffer::~CDRMDumbBuffer() { return; if (data) - munmap(data, size); + munmap(data, bufferLen); drmModeDestroyDumbBuffer(allocator->drmFD(), handle); } @@ -98,7 +99,7 @@ SDMABUFAttrs Aquamarine::CDRMDumbBuffer::dmabuf() { } std::tuple Aquamarine::CDRMDumbBuffer::beginDataPtr(uint32_t flags) { - return {data, attrs.format, size}; + return {data, attrs.format, bufferLen}; } void Aquamarine::CDRMDumbBuffer::endDataPtr() {