diff options
author | Vaxry <[email protected]> | 2024-08-06 13:27:49 +0200 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-08-06 13:27:49 +0200 |
commit | 4341ed594374f170b46f59867936baebd8482459 (patch) | |
tree | 01ad1d0ede632c68173b66acc6fb3a64ade252e4 | |
parent | f2533c55cc25381d764978199ba8ada8957597c8 (diff) | |
download | Hyprland-4341ed594374f170b46f59867936baebd8482459.tar.gz Hyprland-4341ed594374f170b46f59867936baebd8482459.zip |
stuff
-rw-r--r-- | src/config/ConfigManager.cpp | 4 | ||||
-rw-r--r-- | src/helpers/Monitor.cpp | 6 | ||||
-rw-r--r-- | src/render/Renderer.cpp | 49 | ||||
-rw-r--r-- | src/render/Renderer.hpp | 5 |
4 files changed, 53 insertions, 11 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 6eec4dbe..710aa49b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -561,8 +561,8 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("group:groupbar:col.locked_active", Hyprlang::CConfigCustomValueType{&configHandleGradientSet, configHandleGradientDestroy, "0x66ff5500"}); m_pConfig->addConfigValue("group:groupbar:col.locked_inactive", Hyprlang::CConfigCustomValueType{&configHandleGradientSet, configHandleGradientDestroy, "0x66775500"}); - m_pConfig->addConfigValue("render:explicit_sync", Hyprlang::INT{1}); - m_pConfig->addConfigValue("render:explicit_sync_kms", Hyprlang::INT{1}); + m_pConfig->addConfigValue("render:explicit_sync", Hyprlang::INT{2}); + m_pConfig->addConfigValue("render:explicit_sync_kms", Hyprlang::INT{2}); // devices m_pConfig->addSpecialCategory("device", {"name"}); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 48d12d88..61ef8ddf 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -795,8 +795,6 @@ void CMonitor::scheduleDone() { } bool CMonitor::attemptDirectScanout() { - static auto PENABLEEXPLICITKMS = CConfigValue<Hyprlang::INT>("render:explicit_sync_kms"); - if (!mirrors.empty() || isMirror() || g_pHyprRenderer->m_bDirectScanoutBlocked) return false; // do not DS if this monitor is being mirrored. Will break the functionality. @@ -830,8 +828,10 @@ bool CMonitor::attemptDirectScanout() { return false; } + auto explicitOptions = g_pHyprRenderer->getExplicitSyncSettings(); + // wait for the explicit fence if present, and if kms explicit is allowed - bool DOEXPLICIT = PSURFACE->syncobj && PSURFACE->syncobj->acquireTimeline && PSURFACE->syncobj->acquireTimeline->timeline && *PENABLEEXPLICITKMS; + bool DOEXPLICIT = PSURFACE->syncobj && PSURFACE->syncobj->acquireTimeline && PSURFACE->syncobj->acquireTimeline->timeline && explicitOptions.explicitKMSEnabled; int explicitWaitFD = -1; if (DOEXPLICIT) { explicitWaitFD = PSURFACE->syncobj->acquireTimeline->timeline->exportAsSyncFileFD(PSURFACE->syncobj->acquirePoint); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 787367a3..ba81af03 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1405,8 +1405,6 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { } bool CHyprRenderer::commitPendingAndDoExplicitSync(CMonitor* pMonitor) { - static auto PENABLEEXPLICIT = CConfigValue<Hyprlang::INT>("render:explicit_sync"); - // apply timelines for explicit sync // save inFD otherwise reset will reset it auto inFD = pMonitor->output->state->state().explicitInFence; @@ -1431,7 +1429,9 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(CMonitor* pMonitor) { } } - if (!*PENABLEEXPLICIT) + auto explicitOptions = getExplicitSyncSettings(); + + if (!explicitOptions.explicitEnabled) return ok; if (inFD >= 0) @@ -2649,8 +2649,6 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode void CHyprRenderer::endRender() { const auto PMONITOR = g_pHyprOpenGL->m_RenderData.pMonitor; static auto PNVIDIAANTIFLICKER = CConfigValue<Hyprlang::INT>("opengl:nvidia_anti_flicker"); - static auto PENABLEEXPLICIT = CConfigValue<Hyprlang::INT>("render:explicit_sync"); - static auto PENABLEEXPLICITKMS = CConfigValue<Hyprlang::INT>("render:explicit_sync_kms"); PMONITOR->commitSeq++; @@ -2674,7 +2672,9 @@ void CHyprRenderer::endRender() { if (m_eRenderMode == RENDER_MODE_NORMAL) { PMONITOR->output->state->setBuffer(m_pCurrentBuffer); - if (PMONITOR->inTimeline && *PENABLEEXPLICIT && *PENABLEEXPLICITKMS) { + auto explicitOptions = getExplicitSyncSettings(); + + if (PMONITOR->inTimeline && explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled) { auto sync = g_pHyprOpenGL->createEGLSync(-1); if (!sync) { Debug::log(ERR, "renderer: couldn't create an EGLSync for out in endRender"); @@ -2714,3 +2714,40 @@ SP<CRenderbuffer> CHyprRenderer::getCurrentRBO() { bool CHyprRenderer::isNvidia() { return m_bNvidia; } + +SExplicitSyncSettings CHyprRenderer::getExplicitSyncSettings() { + static auto PENABLEEXPLICIT = CConfigValue<Hyprlang::INT>("render:explicit_sync"); + static auto PENABLEEXPLICITKMS = CConfigValue<Hyprlang::INT>("render:explicit_sync_kms"); + + SExplicitSyncSettings settings; + settings.explicitEnabled = *PENABLEEXPLICIT; + settings.explicitKMSEnabled = *PENABLEEXPLICITKMS; + + if (*PENABLEEXPLICIT == 2 /* auto */) + settings.explicitEnabled = true; + if (*PENABLEEXPLICITKMS == 2 /* auto */) { + if (!m_bNvidia) + settings.explicitKMSEnabled = true; + else { + if (!std::filesystem::exists("/proc/driver/nvidia/version")) + settings.explicitKMSEnabled = false; + else { + // check nvidia version. Explicit KMS is supported in 560+ + std::ifstream ifs("/proc/driver/nvidia/version"); + if (!ifs.good()) + settings.explicitKMSEnabled = false; + else { + std::string driverInfo((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>())); + if (driverInfo.contains("550.") || driverInfo.contains("555.")) + settings.explicitKMSEnabled = false; + else + settings.explicitKMSEnabled = true; + + ifs.close(); + } + } + } + } + + return settings; +} diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index 844f4700..84501821 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -39,6 +39,10 @@ class CToplevelExportProtocolManager; class CInputManager; struct SSessionLockSurface; +struct SExplicitSyncSettings { + bool explicitEnabled = false, explicitKMSEnabled = false; +}; + class CHyprRenderer { public: CHyprRenderer(); @@ -73,6 +77,7 @@ class CHyprRenderer { bool isNvidia(); void makeEGLCurrent(); void unsetEGL(); + SExplicitSyncSettings getExplicitSyncSettings(); // if RENDER_MODE_NORMAL, provided damage will be written to. // otherwise, it will be the one used. |