mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 08:26:00 +01:00
maybe dont kill the kernel
This commit is contained in:
parent
e844282d1d
commit
cac883a39c
5 changed files with 24 additions and 10 deletions
|
@ -19,7 +19,7 @@ namespace Aquamarine {
|
||||||
virtual SSHMAttrs shm();
|
virtual SSHMAttrs shm();
|
||||||
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
|
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
|
||||||
virtual void endDataPtr();
|
virtual void endDataPtr();
|
||||||
virtual uint32_t drmHandle();
|
virtual uint32_t drmID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CDRMDumbBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator_,
|
CDRMDumbBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator_,
|
||||||
|
@ -28,7 +28,7 @@ namespace Aquamarine {
|
||||||
Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator;
|
Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator;
|
||||||
|
|
||||||
//
|
//
|
||||||
uint32_t drmID = 0;
|
uint32_t idrmID = 0;
|
||||||
Hyprutils::Math::Vector2D pixelSize;
|
Hyprutils::Math::Vector2D pixelSize;
|
||||||
uint32_t stride = 0, handle = 0;
|
uint32_t stride = 0, handle = 0;
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace Aquamarine {
|
||||||
virtual void lock();
|
virtual void lock();
|
||||||
virtual void unlock();
|
virtual void unlock();
|
||||||
virtual bool locked();
|
virtual bool locked();
|
||||||
virtual uint32_t drmHandle();
|
virtual uint32_t drmID();
|
||||||
|
|
||||||
Hyprutils::Math::Vector2D size;
|
Hyprutils::Math::Vector2D size;
|
||||||
bool opaque = false;
|
bool opaque = false;
|
||||||
|
|
|
@ -39,6 +39,16 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params,
|
||||||
attrs.fd = request.handle;
|
attrs.fd = request.handle;
|
||||||
attrs.stride = stride;
|
attrs.stride = stride;
|
||||||
|
|
||||||
|
uint32_t handles[4] = {handle, 0, 0, 0};
|
||||||
|
uint32_t strides[4] = {stride, 0, 0, 0};
|
||||||
|
uint32_t offsets[4] = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
// these buffers are tied to drm... we need to import them here. CDRMFB will not be clean anymore... weeee...
|
||||||
|
if (int ret = drmModeAddFB2(allocator->drmFD(), params.size.x, params.size.y, params.format, handles, strides, offsets, &idrmID, 0); ret < 0) {
|
||||||
|
allocator->backend->log(AQ_LOG_ERROR, std::format("failed to drmModeAddFB2 a drm_dumb buffer: {}", strerror(-ret)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
drm_mode_map_dumb request2 = {
|
drm_mode_map_dumb request2 = {
|
||||||
.handle = handle,
|
.handle = handle,
|
||||||
};
|
};
|
||||||
|
@ -69,6 +79,9 @@ Aquamarine::CDRMDumbBuffer::~CDRMDumbBuffer() {
|
||||||
if (data)
|
if (data)
|
||||||
munmap(data, size);
|
munmap(data, size);
|
||||||
|
|
||||||
|
if (idrmID)
|
||||||
|
drmModeRmFB(allocator->drmFD(), idrmID);
|
||||||
|
|
||||||
drm_mode_destroy_dumb request = {
|
drm_mode_destroy_dumb request = {
|
||||||
.handle = handle,
|
.handle = handle,
|
||||||
};
|
};
|
||||||
|
@ -107,7 +120,7 @@ void Aquamarine::CDRMDumbBuffer::endDataPtr() {
|
||||||
; // nothing to do
|
; // nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Aquamarine::CDRMDumbBuffer::drmHandle() {
|
uint32_t Aquamarine::CDRMDumbBuffer::drmID() {
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1826,7 +1826,7 @@ Aquamarine::CDRMFB::CDRMFB(SP<IBuffer> buffer_, Hyprutils::Memory::CWeakPointer<
|
||||||
|
|
||||||
void Aquamarine::CDRMFB::import() {
|
void Aquamarine::CDRMFB::import() {
|
||||||
auto attrs = buffer->dmabuf();
|
auto attrs = buffer->dmabuf();
|
||||||
if (!attrs.success && !buffer->drmHandle()) {
|
if (!attrs.success && !buffer->drmID()) {
|
||||||
backend->backend->log(AQ_LOG_ERROR, "drm: Buffer submitted has no dmabuf or a drm handle");
|
backend->backend->log(AQ_LOG_ERROR, "drm: Buffer submitted has no dmabuf or a drm handle");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1838,7 +1838,7 @@ void Aquamarine::CDRMFB::import() {
|
||||||
|
|
||||||
// TODO: check format
|
// TODO: check format
|
||||||
|
|
||||||
if (!buffer->drmHandle()) {
|
if (!buffer->drmID()) {
|
||||||
for (int i = 0; i < attrs.planes; ++i) {
|
for (int i = 0; i < attrs.planes; ++i) {
|
||||||
int ret = drmPrimeFDToHandle(backend->gpu->fd, attrs.fds.at(i), &boHandles[i]);
|
int ret = drmPrimeFDToHandle(backend->gpu->fd, attrs.fds.at(i), &boHandles[i]);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -1849,10 +1849,11 @@ void Aquamarine::CDRMFB::import() {
|
||||||
|
|
||||||
TRACE(backend->backend->log(AQ_LOG_TRACE, std::format("drm: CDRMFB: plane {} has fd {}, got handle {}", i, attrs.fds.at(i), boHandles.at(i))));
|
TRACE(backend->backend->log(AQ_LOG_TRACE, std::format("drm: CDRMFB: plane {} has fd {}, got handle {}", i, attrs.fds.at(i), boHandles.at(i))));
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
boHandles = {buffer->drmHandle(), 0, 0, 0};
|
|
||||||
|
|
||||||
id = submitBuffer();
|
id = submitBuffer();
|
||||||
|
} else
|
||||||
|
id = buffer->drmID();
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
backend->backend->log(AQ_LOG_ERROR, "drm: Failed to submit a buffer to KMS");
|
backend->backend->log(AQ_LOG_ERROR, "drm: Failed to submit a buffer to KMS");
|
||||||
buffer->attachments.add(makeShared<CDRMBufferUnimportable>());
|
buffer->attachments.add(makeShared<CDRMBufferUnimportable>());
|
||||||
|
|
|
@ -40,6 +40,6 @@ bool Aquamarine::IBuffer::locked() {
|
||||||
return locks;
|
return locks;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Aquamarine::IBuffer::drmHandle() {
|
uint32_t Aquamarine::IBuffer::drmID() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue