mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-04 14:11:59 -07:00
syncobj: restore SHM buffer reset (#9675)
reset shm buffers early to mitigate stuttering animations, also reuse the monitors eglSync and store the eglsync per monitor. this however reintroduces flickering in dbeaver nonsyncobj application.
This commit is contained in:
@@ -57,6 +57,7 @@ struct SMonitorRule {
|
|||||||
|
|
||||||
class CMonitor;
|
class CMonitor;
|
||||||
class CSyncTimeline;
|
class CSyncTimeline;
|
||||||
|
class CEGLSync;
|
||||||
|
|
||||||
class CMonitorState {
|
class CMonitorState {
|
||||||
public:
|
public:
|
||||||
@@ -141,6 +142,7 @@ class CMonitor {
|
|||||||
SP<CSyncTimeline> inTimeline;
|
SP<CSyncTimeline> inTimeline;
|
||||||
SP<CSyncTimeline> outTimeline;
|
SP<CSyncTimeline> outTimeline;
|
||||||
Hyprutils::OS::CFileDescriptor inFence;
|
Hyprutils::OS::CFileDescriptor inFence;
|
||||||
|
SP<CEGLSync> eglSync;
|
||||||
uint64_t commitSeq = 0;
|
uint64_t commitSeq = 0;
|
||||||
|
|
||||||
PHLMONITORREF self;
|
PHLMONITORREF self;
|
||||||
|
@@ -471,12 +471,10 @@ void CWLSurfaceResource::commitPendingState(SSurfaceState& state) {
|
|||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// release the buffer if it's synchronous as update() has done everything thats needed
|
// release the buffer if it's synchronous (SHM) as update() has done everything thats needed
|
||||||
// so we can let the app know we're done.
|
// so we can let the app know we're done.
|
||||||
// if (!syncobj && current.buffer && current.buffer->buffer && current.buffer->buffer->isSynchronous()) {
|
if (current.buffer && current.buffer->buffer && current.buffer->buffer->isSynchronous())
|
||||||
// dropCurrentBuffer(); // lets not drop it at all, it will get dropped on next commit if a new buffer arrives.
|
dropCurrentBuffer();
|
||||||
// solves flickering on nonsyncobj apps on explicit sync.
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWLSurfaceResource::updateCursorShm(CRegion damage) {
|
void CWLSurfaceResource::updateCursorShm(CRegion damage) {
|
||||||
|
@@ -1526,21 +1526,19 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
|
|||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
Debug::log(TRACE, "Explicit: {} presented", explicitPresented.size());
|
Debug::log(TRACE, "Explicit: {} presented", explicitPresented.size());
|
||||||
auto sync = g_pHyprOpenGL->createEGLSync(pMonitor->inFence.get());
|
|
||||||
|
|
||||||
if (!sync)
|
if (!pMonitor->eglSync)
|
||||||
Debug::log(TRACE, "Explicit: can't add sync, EGLSync failed");
|
Debug::log(TRACE, "Explicit: can't add sync, monitor has no EGLSync");
|
||||||
else {
|
else {
|
||||||
for (auto const& e : explicitPresented) {
|
for (auto const& e : explicitPresented) {
|
||||||
if (!e->current.buffer || !e->current.buffer->buffer || !e->current.buffer->buffer->syncReleaser)
|
if (!e->current.buffer || !e->current.buffer->buffer || !e->current.buffer->buffer->syncReleaser)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
e->current.buffer->buffer->syncReleaser->addReleaseSync(sync);
|
e->current.buffer->buffer->syncReleaser->addReleaseSync(pMonitor->eglSync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
explicitPresented.clear();
|
explicitPresented.clear();
|
||||||
pMonitor->output->state->resetExplicitFences();
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@@ -2257,13 +2255,13 @@ void CHyprRenderer::endRender() {
|
|||||||
auto explicitOptions = getExplicitSyncSettings(PMONITOR->output);
|
auto explicitOptions = getExplicitSyncSettings(PMONITOR->output);
|
||||||
|
|
||||||
if (PMONITOR->inTimeline && explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled) {
|
if (PMONITOR->inTimeline && explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled) {
|
||||||
auto sync = g_pHyprOpenGL->createEGLSync();
|
PMONITOR->eglSync = g_pHyprOpenGL->createEGLSync();
|
||||||
if (!sync) {
|
if (!PMONITOR->eglSync) {
|
||||||
Debug::log(ERR, "renderer: couldn't create an EGLSync for out in endRender");
|
Debug::log(ERR, "renderer: couldn't create an EGLSync for out in endRender");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = PMONITOR->inTimeline->importFromSyncFileFD(PMONITOR->commitSeq, sync->fd());
|
bool ok = PMONITOR->inTimeline->importFromSyncFileFD(PMONITOR->commitSeq, PMONITOR->eglSync->fd());
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
Debug::log(ERR, "renderer: couldn't import from sync file fd in endRender");
|
Debug::log(ERR, "renderer: couldn't import from sync file fd in endRender");
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user