summaryrefslogtreecommitdiff
path: root/src/protocols/MesaDRM.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-07-21 13:09:54 +0200
committerGitHub <noreply@github.com>2024-07-21 13:09:54 +0200
commit016da234d0e852de3ef20eb2e89ac58d2a85f6e7 (patch)
tree496085987176551b0794fffc069877d44943e2f1 /src/protocols/MesaDRM.cpp
parentf642fb97df5c69267a03452533de383ff8023570 (diff)
Core: Move to aquamarine (#6608)
Moves Hyprland from wlroots to aquamarine for the backend. --------- Signed-off-by: Vaxry <vaxry@vaxry.net> Co-authored-by: Mihai Fufezan <mihai@fufexan.net> Co-authored-by: Jan Beich <jbeich@FreeBSD.org> Co-authored-by: vaxerski <vaxerski@users.noreply.github.com> Co-authored-by: UjinT34 <41110182+UjinT34@users.noreply.github.com> Co-authored-by: Tom Englund <tomenglund26@gmail.com> Co-authored-by: Ikalco <73481042+ikalco@users.noreply.github.com> Co-authored-by: diniamo <diniamo53@gmail.com>
Diffstat (limited to 'src/protocols/MesaDRM.cpp')
-rw-r--r--src/protocols/MesaDRM.cpp42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/protocols/MesaDRM.cpp b/src/protocols/MesaDRM.cpp
index 0bcf4a9c..ed412555 100644
--- a/src/protocols/MesaDRM.cpp
+++ b/src/protocols/MesaDRM.cpp
@@ -2,12 +2,11 @@
#include <algorithm>
#include <xf86drm.h>
#include "../Compositor.hpp"
-#include <wlr/render/drm_format_set.h>
#include "types/WLBuffer.hpp"
#define LOGM PROTO::mesaDRM->protoLog
-CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, SDMABUFAttrs attrs_) {
+CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs_) {
LOGM(LOG, "Creating a Mesa dmabuf, with id {}: size {}, fmt {}, planes {}", id, attrs_.size, attrs_.format, attrs_.planes);
for (int i = 0; i < attrs_.planes; ++i) {
LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]);
@@ -60,10 +59,27 @@ CMesaDRMResource::CMesaDRMResource(SP<CWlDrm> resource_) : resource(resource_) {
return;
}
- SDMABUFAttrs attrs;
+ uint64_t mod = DRM_FORMAT_MOD_INVALID;
+
+ auto fmts = g_pHyprOpenGL->getDRMFormats();
+ for (auto& f : fmts) {
+ if (f.drmFormat != fmt)
+ continue;
+
+ for (auto& m : f.modifiers) {
+ if (m == DRM_FORMAT_MOD_LINEAR)
+ continue;
+
+ mod = m;
+ break;
+ }
+ break;
+ }
+
+ Aquamarine::SDMABUFAttrs attrs;
attrs.success = true;
attrs.size = {w, h};
- attrs.modifier = DRM_FORMAT_MOD_INVALID;
+ attrs.modifier = mod;
attrs.planes = 1;
attrs.offsets[0] = off0;
attrs.strides[0] = str0;
@@ -87,7 +103,7 @@ CMesaDRMResource::CMesaDRMResource(SP<CWlDrm> resource_) : resource(resource_) {
auto fmts = g_pHyprOpenGL->getDRMFormats();
for (auto& fmt : fmts) {
- resource->sendFormat(fmt.format);
+ resource->sendFormat(fmt.drmFormat);
}
}
@@ -97,10 +113,10 @@ bool CMesaDRMResource::good() {
CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
drmDevice* dev = nullptr;
- int drmFD = wlr_renderer_get_drm_fd(g_pCompositor->m_sWLRRenderer);
+ int drmFD = g_pCompositor->m_iDRMFD;
if (drmGetDevice2(drmFD, 0, &dev) != 0) {
- LOGM(ERR, "Failed to get device");
- PROTO::mesaDRM.reset();
+ protoLog(ERR, "Failed to get device, disabling MesaDRM");
+ removeGlobal();
return;
}
@@ -108,7 +124,15 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
nodeName = dev->nodes[DRM_NODE_RENDER];
} else {
ASSERT(dev->available_nodes & (1 << DRM_NODE_PRIMARY));
- LOGM(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]);
+
+ if (!dev->nodes[DRM_NODE_PRIMARY]) {
+ protoLog(ERR, "No DRM render node available, both render and primary are null, disabling MesaDRM");
+ drmFreeDevice(&dev);
+ removeGlobal();
+ return;
+ }
+
+ protoLog(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]);
nodeName = dev->nodes[DRM_NODE_PRIMARY];
}
drmFreeDevice(&dev);