Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DS and VRR automation #9334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,9 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
},
SConfigOptionDescription{
.value = "misc:vrr",
.description = " controls the VRR (Adaptive Sync) of your monitors. 0 - off, 1 - on, 2 - fullscreen only [0/1/2]",
.description = " controls the VRR (Adaptive Sync) of your monitors. 0 - off, 1 - on, 2 - fullscreen only, 3 - fullscreen with game or video content type [0/1/2/3]",
.type = CONFIG_OPTION_INT,
.data = SConfigOptionDescription::SRangeData{0, 0, 2},
.data = SConfigOptionDescription::SRangeData{.value = 0, .min = 0, .max = 3},
},
SConfigOptionDescription{
.value = "misc:mouse_move_enables_dpms",
Expand Down
32 changes: 15 additions & 17 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <memory>
using namespace Hyprutils::String;
using namespace Hyprutils::Animation;
using enum NContentType::eContentType;

//NOLINTNEXTLINE
extern "C" char** environ;
Expand Down Expand Up @@ -1618,37 +1619,34 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
}
m->vrrActive = true;
return;
} else if (USEVRR == 2) {
} else if (USEVRR == 2 || USEVRR == 3) {
const auto PWORKSPACE = m->activeWorkspace;

if (!PWORKSPACE)
return; // ???

const auto WORKSPACEFULL = PWORKSPACE->m_bHasFullscreenWindow && (PWORKSPACE->m_efFullscreenMode & FSMODE_FULLSCREEN);
bool wantVRR = PWORKSPACE->m_bHasFullscreenWindow && (PWORKSPACE->m_efFullscreenMode & FSMODE_FULLSCREEN);
if (wantVRR && USEVRR == 3) {
const auto contentType = PWORKSPACE->getFullscreenWindow()->getContentType();
wantVRR = contentType == CONTENT_TYPE_GAME || contentType == CONTENT_TYPE_VIDEO;
}

if (WORKSPACEFULL) {
if (wantVRR) {
/* fullscreen */
m->vrrActive = true;

m->output->state->resetExplicitFences();
m->output->state->setAdaptiveSync(true);
if (!m->output->state->state().adaptiveSync) {
m->output->state->setAdaptiveSync(true);

if (!m->state.test()) {
Debug::log(LOG, "Pending output {} does not accept VRR.", m->output->name);
m->output->state->setAdaptiveSync(false);
if (!m->state.test()) {
Debug::log(LOG, "Pending output {} does not accept VRR.", m->output->name);
m->output->state->setAdaptiveSync(false);
}
}

if (!m->state.commit())
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name);

} else if (!WORKSPACEFULL) {
} else {
m->vrrActive = false;

m->output->state->resetExplicitFences();
m->output->state->setAdaptiveSync(false);

if (!m->state.commit())
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name);
}
}
};
Expand Down
9 changes: 4 additions & 5 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
#include "pass/RendererHintsPassElement.hpp"
#include "pass/SurfacePassElement.hpp"
#include "debug/Log.hpp"
#include "protocols/ColorManagement.hpp"
#if AQUAMARINE_VERSION_NUMBER > 702 // >0.7.2
#include "protocols/types/ContentType.hpp"
#endif
#include "../protocols/ColorManagement.hpp"
#include "../protocols/types/ContentType.hpp"

#include <hyprutils/utils/ScopeGuard.hpp>
using namespace Hyprutils::Utils;
Expand Down Expand Up @@ -1197,7 +1195,8 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor) {
pMonitor->tearingState.activelyTearing = shouldTear;

if ((*PDIRECTSCANOUT == 1 ||
(*PDIRECTSCANOUT == 2 && pMonitor->activeWorkspace->getFullscreenWindow() && pMonitor->activeWorkspace->getFullscreenWindow()->getContentType() == CONTENT_TYPE_GAME)) &&
(*PDIRECTSCANOUT == 2 && pMonitor->activeWorkspace && pMonitor->activeWorkspace->m_bHasFullscreenWindow &&
pMonitor->activeWorkspace->m_efFullscreenMode == FSMODE_FULLSCREEN && pMonitor->activeWorkspace->getFullscreenWindow()->getContentType() == CONTENT_TYPE_GAME)) &&
!shouldTear) {
if (pMonitor->attemptDirectScanout()) {
return;
Expand Down
Loading