maybe dont kill the kernel

This commit is contained in:
Vaxry 2024-11-09 19:00:02 +00:00
parent e844282d1d
commit cac883a39c
5 changed files with 24 additions and 10 deletions

View file

@ -19,7 +19,7 @@ namespace Aquamarine {
virtual SSHMAttrs shm();
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
virtual void endDataPtr();
virtual uint32_t drmHandle();
virtual uint32_t drmID();
private:
CDRMDumbBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator_,
@ -28,7 +28,7 @@ namespace Aquamarine {
Hyprutils::Memory::CWeakPointer<CDRMDumbAllocator> allocator;
//
uint32_t drmID = 0;
uint32_t idrmID = 0;
Hyprutils::Math::Vector2D pixelSize;
uint32_t stride = 0, handle = 0;
uint64_t size = 0;

View file

@ -60,7 +60,7 @@ namespace Aquamarine {
virtual void lock();
virtual void unlock();
virtual bool locked();
virtual uint32_t drmHandle();
virtual uint32_t drmID();
Hyprutils::Math::Vector2D size;
bool opaque = false;

View file

@ -39,6 +39,16 @@ Aquamarine::CDRMDumbBuffer::CDRMDumbBuffer(const SAllocatorBufferParams& params,
attrs.fd = request.handle;
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 = {
.handle = handle,
};
@ -69,6 +79,9 @@ Aquamarine::CDRMDumbBuffer::~CDRMDumbBuffer() {
if (data)
munmap(data, size);
if (idrmID)
drmModeRmFB(allocator->drmFD(), idrmID);
drm_mode_destroy_dumb request = {
.handle = handle,
};
@ -107,7 +120,7 @@ void Aquamarine::CDRMDumbBuffer::endDataPtr() {
; // nothing to do
}
uint32_t Aquamarine::CDRMDumbBuffer::drmHandle() {
uint32_t Aquamarine::CDRMDumbBuffer::drmID() {
return handle;
}

View file

@ -1826,7 +1826,7 @@ Aquamarine::CDRMFB::CDRMFB(SP<IBuffer> buffer_, Hyprutils::Memory::CWeakPointer<
void Aquamarine::CDRMFB::import() {
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");
return;
}
@ -1838,7 +1838,7 @@ void Aquamarine::CDRMFB::import() {
// TODO: check format
if (!buffer->drmHandle()) {
if (!buffer->drmID()) {
for (int i = 0; i < attrs.planes; ++i) {
int ret = drmPrimeFDToHandle(backend->gpu->fd, attrs.fds.at(i), &boHandles[i]);
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))));
}
} else
boHandles = {buffer->drmHandle(), 0, 0, 0};
id = submitBuffer();
} else
id = buffer->drmID();
if (!id) {
backend->backend->log(AQ_LOG_ERROR, "drm: Failed to submit a buffer to KMS");
buffer->attachments.add(makeShared<CDRMBufferUnimportable>());

View file

@ -40,6 +40,6 @@ bool Aquamarine::IBuffer::locked() {
return locks;
}
uint32_t Aquamarine::IBuffer::drmHandle() {
uint32_t Aquamarine::IBuffer::drmID() {
return 0;
}