mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-03 21:51:55 -07:00
syncobj: use eventfd instead of stalling fd checks (#9437)
* syncobj: cleanup and use uniqueptrs cleanup a bit missing removals if resource not good, erasing from containers etc. make use of unique ptrs instead. and add default destructors. * syncobj: rework syncobj entirerly remove early buffer release that was breaking explicit sync, the buffer needs to exist until the surface commit event has been emitted and draw calls added egl sync points, move to eventfd signaling instead of stalling sync point checks, and recommit pending commits if waiting on a signal. add a CDRMSyncPointState helper class. move a few weak pointers to shared pointers so they dont destruct before we need to use them. * syncobj: queue pending states for eventfd eventfd requires us to queue pending stats until ready and then apply to current, and also when no ready state exist commit the client commit on the current existing buffer, if there is one. * syncobj: clear current buffer damage clear current buffer damage on current buffer commits. * syncobj: cleanup code and fix hyprlock remove unused code, and ensure we dont commit a empty texture causing locksession protocol and gtk4-layer-shell misbehaving. * syncobj: ensure buffers are cleaned up ensure the containers having the various buffers actually gets cleaned up from their containers, incase the CSignal isnt signaled because of expired smart pointers or just wrong order destruction because mishaps. also move the acquire/point setting to buffer attaching. instead of on precommit. * syncobj: remove unused code, optimize remove unused code and merge sync fds if fence is valid, remove manual directscanout buffer dropping that signals release point on pageflip, it can cause us to signal the release point while still keeping the current buffer and rendering it yet again causing wrong things. * syncobj: delay buffer release on non syncobj delay buffer releases on non syncobj surfaces until next commit, and check on async buffers if syncobj and drop and signal the release point on backend buffer release. * syncobj: ensure we follow protocol ensure we follow protocol by replacing acquire/release points if they arrive late and replace already existing ones. also remove unneded brackets, and dont try to manual lock/release buffers when it comes to explicit protocol. it doesnt care about buffer releases only about acquire and release points and signaling them. * syncobj: lets not complicate things set points in precommit, before checking protocol errors and we catch any pending acquire/release points arriving late. * syncobj: move SSurfaceState to types remove destructor resource destroying, let resources destroys them on their events, and move SSurfaceStates to types/SurfaceState.hpp * syncobj: actually store the merged fd have to actually store the mergedfd to use it. * syncobj: cleanup a bit around fences ensure the current asynchronous buffer is actually released on pageflip not the previous. cleanup a bit FD handling in commitPendingAndDoExplicitSync, and reuse the in fence when syncing surfaces. * syncobjs: ensure fence FD doesnt leak calling resetexplicitfence without properly ensuring the FD is closed before will leak it, store it per monitor and let it close itself with the CFileDescriptor class. * syncobj: ensure buffers are actually released buffers were never being sent released properly. * types: Defer buffer sync releaser until unlock * syncobj: store directscanout fence in monitor ensure the infence fd survives the scope of attemptdirectscanout so it doesnt close before it should have. * syncobj: check if if acquire is expired we might hit a race to finish on exit where the timeline just has destructed but the buffer waiter is still pending. and such we removeAllWaiters null dereferences. * syncobj: code style changes remove quack comment, change to m_foo and use a std::vector and weakpointer in the waiter for removal instead of a std::list. * syncobj: remove unused async buffer drop remove unused async buffer drop, only related to directscanout and is handled elsewhere. --------- Co-authored-by: Lee Bousfield <ljbousfield@gmail.com>
This commit is contained in:
@@ -1450,13 +1450,6 @@ static hdr_output_metadata createHDRMetadata(SImageDescription settings, A
|
||||
bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
||||
pMonitor->commitSeq++;
|
||||
|
||||
// apply timelines for explicit sync
|
||||
// save inFD otherwise reset will reset it
|
||||
CFileDescriptor inFD{pMonitor->output->state->state().explicitInFence};
|
||||
pMonitor->output->state->resetExplicitFences();
|
||||
if (inFD.isValid())
|
||||
pMonitor->output->state->setExplicitInFence(inFD.get());
|
||||
|
||||
static auto PPASS = CConfigValue<Hyprlang::INT>("render:cm_fs_passthrough");
|
||||
const bool PHDR = pMonitor->imageDescription.transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ;
|
||||
|
||||
@@ -1517,7 +1510,7 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
||||
|
||||
bool ok = pMonitor->state.commit();
|
||||
if (!ok) {
|
||||
if (inFD.isValid()) {
|
||||
if (pMonitor->inFence.isValid()) {
|
||||
Debug::log(TRACE, "Monitor state commit failed, retrying without a fence");
|
||||
pMonitor->output->state->resetExplicitFences();
|
||||
ok = pMonitor->state.commit();
|
||||
@@ -1537,21 +1530,20 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
||||
return ok;
|
||||
|
||||
Debug::log(TRACE, "Explicit: {} presented", explicitPresented.size());
|
||||
auto sync = g_pHyprOpenGL->createEGLSync({});
|
||||
auto sync = g_pHyprOpenGL->createEGLSync(pMonitor->inFence.get());
|
||||
|
||||
if (!sync)
|
||||
Debug::log(TRACE, "Explicit: can't add sync, EGLSync failed");
|
||||
else {
|
||||
for (auto const& e : explicitPresented) {
|
||||
if (!e->current.buffer || !e->current.buffer->releaser)
|
||||
if (!e->current.buffer || !e->current.buffer->buffer || !e->current.buffer->buffer->syncReleaser)
|
||||
continue;
|
||||
|
||||
e->current.buffer->releaser->addReleaseSync(sync);
|
||||
e->current.buffer->buffer->syncReleaser->addReleaseSync(sync);
|
||||
}
|
||||
}
|
||||
|
||||
explicitPresented.clear();
|
||||
|
||||
pMonitor->output->state->resetExplicitFences();
|
||||
|
||||
return ok;
|
||||
@@ -2269,7 +2261,7 @@ void CHyprRenderer::endRender() {
|
||||
auto explicitOptions = getExplicitSyncSettings(PMONITOR->output);
|
||||
|
||||
if (PMONITOR->inTimeline && explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled) {
|
||||
auto sync = g_pHyprOpenGL->createEGLSync({});
|
||||
auto sync = g_pHyprOpenGL->createEGLSync();
|
||||
if (!sync) {
|
||||
Debug::log(ERR, "renderer: couldn't create an EGLSync for out in endRender");
|
||||
return;
|
||||
@@ -2281,13 +2273,13 @@ void CHyprRenderer::endRender() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto fd = PMONITOR->inTimeline->exportAsSyncFileFD(PMONITOR->commitSeq);
|
||||
if (!fd.isValid()) {
|
||||
PMONITOR->inFence = CFileDescriptor{PMONITOR->inTimeline->exportAsSyncFileFD(PMONITOR->commitSeq)};
|
||||
if (!PMONITOR->inFence.isValid()) {
|
||||
Debug::log(ERR, "renderer: couldn't export from sync timeline in endRender");
|
||||
return;
|
||||
}
|
||||
|
||||
PMONITOR->output->state->setExplicitInFence(fd.take());
|
||||
PMONITOR->output->state->setExplicitInFence(PMONITOR->inFence.get());
|
||||
} else {
|
||||
if (isNvidia() && *PNVIDIAANTIFLICKER)
|
||||
glFinish();
|
||||
|
Reference in New Issue
Block a user