Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include <sys/resource.h>
#include <malloc.h>
#include <unistd.h>
#include <xf86drm.h>

using namespace Hyprutils::String;
using namespace Aquamarine;
Expand Down Expand Up @@ -167,6 +168,10 @@ void CCompositor::restoreNofile() {
Debug::log(ERR, "Failed restoring NOFILE limits");
}

bool CCompositor::supportsDrmSyncobjTimeline() const {
return m_bDrmSyncobjTimelineSupported;
}

void CCompositor::setMallocThreshold() {
#ifdef M_TRIM_THRESHOLD
// The default is 128 pages,
Expand Down Expand Up @@ -354,6 +359,16 @@ void CCompositor::initServer(std::string socketName, int socketFd) {
m_drmFD = m_aqBackend->drmFD();
Debug::log(LOG, "Running on DRMFD: {}", m_drmFD);

if (m_drmFD >= 0) {
uint64_t cap = 0;
int ret = drmGetCap(m_drmFD, DRM_CAP_SYNCOBJ_TIMELINE, &cap);
m_bDrmSyncobjTimelineSupported = (ret == 0 && cap != 0);
Debug::log(LOG, "DRM syncobj timeline support: {}", m_bDrmSyncobjTimelineSupported ? "yes" : "no");
} else {
m_bDrmSyncobjTimelineSupported = false;
Debug::log(LOG, "DRM syncobj timeline support: no (no DRM FD)");
}

if (!socketName.empty() && socketFd != -1) {
fcntl(socketFd, F_SETFD, FD_CLOEXEC);
const auto RETVAL = wl_display_add_socket_fd(m_wlDisplay, socketFd);
Expand Down
3 changes: 3 additions & 0 deletions src/Compositor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class CCompositor {
NColorManagement::SImageDescription getPreferredImageDescription();
bool shouldChangePreferredImageDescription();

bool supportsDrmSyncobjTimeline() const;
std::string m_explicitConfigPath;

private:
Expand All @@ -165,6 +166,8 @@ class CCompositor {
void removeLockFile();
void setMallocThreshold();

bool m_bDrmSyncobjTimelineSupported = false;

uint64_t m_hyprlandPID = 0;
wl_event_source* m_critSigSource = nullptr;
rlimit m_originalNofile = {};
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/sync/SyncTimeline.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#include "SyncTimeline.hpp"
#include "../../defines.hpp"
#include "../../managers/eventLoop/EventLoopManager.hpp"
#include "../../Compositor.hpp"

#include <xf86drm.h>
#include <sys/eventfd.h>
using namespace Hyprutils::OS;

SP<CSyncTimeline> CSyncTimeline::create(int drmFD_) {
if (!g_pCompositor->supportsDrmSyncobjTimeline())
return nullptr;

auto timeline = SP<CSyncTimeline>(new CSyncTimeline);
timeline->m_drmFD = drmFD_;
timeline->m_self = timeline;
Expand All @@ -20,6 +24,9 @@ SP<CSyncTimeline> CSyncTimeline::create(int drmFD_) {
}

SP<CSyncTimeline> CSyncTimeline::create(int drmFD_, CFileDescriptor&& drmSyncobjFD) {
if (!g_pCompositor->supportsDrmSyncobjTimeline())
return nullptr;

auto timeline = SP<CSyncTimeline>(new CSyncTimeline);
timeline->m_drmFD = drmFD_;
timeline->m_syncobjFD = std::move(drmSyncobjFD);
Expand Down
10 changes: 8 additions & 2 deletions src/managers/ProtocolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "content-type-v1.hpp"

#include <aquamarine/buffer/Buffer.hpp>
#include <xf86drm.h>
#include <aquamarine/backend/Backend.hpp>
#include <hyprutils/memory/UniquePtr.hpp>

Expand Down Expand Up @@ -210,8 +211,13 @@ CProtocolManager::CProtocolManager() {
else
lease.reset();

if (g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext && !PROTO::sync)
PROTO::sync = makeUnique<CDRMSyncobjProtocol>(&wp_linux_drm_syncobj_manager_v1_interface, 1, "DRMSyncobj");
if (g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext && !PROTO::sync) {
if (g_pCompositor->supportsDrmSyncobjTimeline()) {
PROTO::sync = makeUnique<CDRMSyncobjProtocol>(&wp_linux_drm_syncobj_manager_v1_interface, 1, "DRMSyncobj");
Debug::log(LOG, "DRM Syncobj Timeline support detected, enabling explicit sync protocol");
} else
Debug::log(WARN, "DRM Syncobj Timeline not supported, skipping explicit sync protocol");
}
}

if (!g_pHyprOpenGL->getDRMFormats().empty()) {
Expand Down
Loading