From 588893c07b1e674e18686e0867341b071b8f6936 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 9 Nov 2024 18:49:15 +0000 Subject: [PATCH] work --- src/allocator/DRMDumb.cpp | 9 ++++++--- src/backend/drm/DRM.cpp | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/allocator/DRMDumb.cpp b/src/allocator/DRMDumb.cpp index bb673e3..4edff96 100644 --- a/src/allocator/DRMDumb.cpp +++ b/src/allocator/DRMDumb.cpp @@ -35,8 +35,9 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params, size = request.size; pixelSize = {(double)request.width, (double)request.height}; - attrs.size = pixelSize; - attrs.fd = request.handle; + attrs.size = pixelSize; + attrs.fd = request.handle; + attrs.stride = stride; drm_mode_map_dumb request2 = { .handle = handle, @@ -115,7 +116,9 @@ Aquamarine::CDRMDumbAllocator::~CDRMDumbAllocator() { } SP Aquamarine::CDRMDumbAllocator::create(int drmfd_, Hyprutils::Memory::CWeakPointer backend_) { - return SP(new CDRMDumbAllocator(drmfd_, backend_)); + auto a = SP(new CDRMDumbAllocator(drmfd_, backend_)); + a->self = a; + return a; } SP Aquamarine::CDRMDumbAllocator::acquire(const SAllocatorBufferParams& params, SP swapchain_) { diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index d4d0e78..1290980 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -256,6 +256,8 @@ std::vector> Aquamarine::CDRMBackend::attempt(SP backe newPrimary = drmBackend; } + drmBackend->dumbAllocator = CDRMDumbAllocator::create(gpu->fd, backend); + backends.emplace_back(drmBackend); // so that session can handle udev change/remove events for this gpu @@ -1652,19 +1654,24 @@ SP Aquamarine::CDRMOutput::getBackend() { } bool Aquamarine::CDRMOutput::setCursor(SP buffer, const Vector2D& hotspot) { - auto bufferType = buffer->type(); - - if ((bufferType == eBufferType::BUFFER_TYPE_SHM && !buffer->shm().success) || (bufferType == eBufferType::BUFFER_TYPE_DMABUF && !buffer->dmabuf().success)) { - backend->backend->log(AQ_LOG_ERROR, "drm: Invalid buffer passed to setCursor"); - return false; - } - if (!connector->crtc) return false; if (!buffer) setCursorVisible(false); else { + auto bufferType = buffer->type(); + + if (!buffer->good()) { + backend->backend->log(AQ_LOG_ERROR, "drm: bad buffer passed to setCursor"); + return false; + } + + if ((bufferType == eBufferType::BUFFER_TYPE_SHM && !buffer->shm().success) || (bufferType == eBufferType::BUFFER_TYPE_DMABUF && !buffer->dmabuf().success)) { + backend->backend->log(AQ_LOG_ERROR, "drm: Invalid buffer passed to setCursor"); + return false; + } + SP fb; if (backend->primary) { @@ -1933,10 +1940,8 @@ uint32_t Aquamarine::CDRMFB::submitBuffer() { uint32_t newID = 0; if (buffer->type() == eBufferType::BUFFER_TYPE_DMABUF) { - auto attrs = buffer->dmabuf(); - - std::array mods = {0, 0, 0, 0}; + std::array mods = {0, 0, 0, 0}; for (size_t i = 0; i < attrs.planes; ++i) { mods[i] = attrs.modifier; }