drm: attempt to re-modeset if commit fails

however, keep track of this so we don't attempt to modeset all the time on an invalid state
This commit is contained in:
Vaxry 2024-07-18 00:06:04 +02:00
parent 2dc8ba961c
commit 5b34d0df1f
2 changed files with 23 additions and 1 deletions

View file

@ -287,6 +287,9 @@ namespace Aquamarine {
SDRMPageFlip pendingPageFlip; SDRMPageFlip pendingPageFlip;
bool frameEventScheduled = false; bool frameEventScheduled = false;
// the current state is invalid and won't commit, don't try to modeset.
bool commitTainted = false;
Hyprutils::Memory::CSharedPointer<SOutputMode> fallbackMode; Hyprutils::Memory::CSharedPointer<SOutputMode> fallbackMode;
struct { struct {

View file

@ -1356,6 +1356,10 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
} }
auto OPTIONS = swapchain->currentOptions(); auto OPTIONS = swapchain->currentOptions();
auto bufDma = STATE.buffer->dmabuf();
OPTIONS.size = STATE.buffer->size;
if (OPTIONS.format == DRM_FORMAT_INVALID)
OPTIONS.format = bufDma.format;
OPTIONS.multigpu = false; // this is not a shared swapchain, and additionally, don't make it linear, nvidia would be mad OPTIONS.multigpu = false; // this is not a shared swapchain, and additionally, don't make it linear, nvidia would be mad
OPTIONS.cursor = false; OPTIONS.cursor = false;
OPTIONS.scanout = true; OPTIONS.scanout = true;
@ -1428,6 +1432,18 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
bool ok = connector->commitState(data); bool ok = connector->commitState(data);
if (!ok && !data.modeset && !connector->commitTainted) {
// attempt to re-modeset, however, flip a tainted flag if the modesetting fails
// to avoid doing this over and over.
data.modeset = true;
data.blocking = true;
data.flags = DRM_MODE_PAGE_FLIP_EVENT;
ok = connector->commitState(data);
if (!ok)
connector->commitTainted = true;
}
if (onlyTest || !ok) if (onlyTest || !ok)
return ok; return ok;
@ -1437,6 +1453,9 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
lastCommitNoBuffer = !data.mainFB; lastCommitNoBuffer = !data.mainFB;
needsFrame = false; needsFrame = false;
if (ok)
connector->commitTainted = false;
return ok; return ok;
} }