This commit is contained in:
Vaxry 2024-11-09 18:49:15 +00:00
parent abd58530c3
commit 588893c07b
2 changed files with 21 additions and 13 deletions

View file

@ -35,8 +35,9 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params,
size = request.size; size = request.size;
pixelSize = {(double)request.width, (double)request.height}; pixelSize = {(double)request.width, (double)request.height};
attrs.size = pixelSize; attrs.size = pixelSize;
attrs.fd = request.handle; attrs.fd = request.handle;
attrs.stride = stride;
drm_mode_map_dumb request2 = { drm_mode_map_dumb request2 = {
.handle = handle, .handle = handle,
@ -115,7 +116,9 @@ Aquamarine::CDRMDumbAllocator::~CDRMDumbAllocator() {
} }
SP<CDRMDumbAllocator> Aquamarine::CDRMDumbAllocator::create(int drmfd_, Hyprutils::Memory::CWeakPointer<CBackend> backend_) { SP<CDRMDumbAllocator> Aquamarine::CDRMDumbAllocator::create(int drmfd_, Hyprutils::Memory::CWeakPointer<CBackend> backend_) {
return SP<CDRMDumbAllocator>(new CDRMDumbAllocator(drmfd_, backend_)); auto a = SP<CDRMDumbAllocator>(new CDRMDumbAllocator(drmfd_, backend_));
a->self = a;
return a;
} }
SP<IBuffer> Aquamarine::CDRMDumbAllocator::acquire(const SAllocatorBufferParams& params, SP<CSwapchain> swapchain_) { SP<IBuffer> Aquamarine::CDRMDumbAllocator::acquire(const SAllocatorBufferParams& params, SP<CSwapchain> swapchain_) {

View file

@ -256,6 +256,8 @@ std::vector<SP<CDRMBackend>> Aquamarine::CDRMBackend::attempt(SP<CBackend> backe
newPrimary = drmBackend; newPrimary = drmBackend;
} }
drmBackend->dumbAllocator = CDRMDumbAllocator::create(gpu->fd, backend);
backends.emplace_back(drmBackend); backends.emplace_back(drmBackend);
// so that session can handle udev change/remove events for this gpu // so that session can handle udev change/remove events for this gpu
@ -1652,19 +1654,24 @@ SP<IBackendImplementation> Aquamarine::CDRMOutput::getBackend() {
} }
bool Aquamarine::CDRMOutput::setCursor(SP<IBuffer> buffer, const Vector2D& hotspot) { bool Aquamarine::CDRMOutput::setCursor(SP<IBuffer> 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) if (!connector->crtc)
return false; return false;
if (!buffer) if (!buffer)
setCursorVisible(false); setCursorVisible(false);
else { 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<CDRMFB> fb; SP<CDRMFB> fb;
if (backend->primary) { if (backend->primary) {
@ -1933,10 +1940,8 @@ uint32_t Aquamarine::CDRMFB::submitBuffer() {
uint32_t newID = 0; uint32_t newID = 0;
if (buffer->type() == eBufferType::BUFFER_TYPE_DMABUF) { if (buffer->type() == eBufferType::BUFFER_TYPE_DMABUF) {
auto attrs = buffer->dmabuf(); auto attrs = buffer->dmabuf();
std::array<uint64_t, 4> mods = {0, 0, 0, 0};
std::array<uint64_t, 4> mods = {0, 0, 0, 0};
for (size_t i = 0; i < attrs.planes; ++i) { for (size_t i = 0; i < attrs.planes; ++i) {
mods[i] = attrs.modifier; mods[i] = attrs.modifier;
} }