Skip to content

Commit

Permalink
drm: attempt to re-modeset if commit fails
Browse files Browse the repository at this point in the history
however, keep track of this so we don't attempt to modeset all the time on an invalid state
  • Loading branch information
vaxerski committed Jul 17, 2024
1 parent 2dc8ba9 commit 5b34d0d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/aquamarine/backend/DRM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ namespace Aquamarine {
SDRMPageFlip pendingPageFlip;
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;

struct {
Expand Down
21 changes: 20 additions & 1 deletion src/backend/drm/DRM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,11 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
mgpu.swapchain = CSwapchain::create(backend->mgpu.allocator, backend.lock());
}

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.cursor = false;
OPTIONS.scanout = true;
Expand Down Expand Up @@ -1428,6 +1432,18 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {

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)
return ok;

Expand All @@ -1437,6 +1453,9 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
lastCommitNoBuffer = !data.mainFB;
needsFrame = false;

if (ok)
connector->commitTainted = false;

return ok;
}

Expand Down

0 comments on commit 5b34d0d

Please sign in to comment.