Skip to content

Commit

Permalink
renderer: move to CFileDescriptor
Browse files Browse the repository at this point in the history
use CFileDescriptors instead of manual fd handling
  • Loading branch information
gulafaran committed Nov 21, 2024
1 parent 4b00d69 commit bf78c89
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,10 +1510,10 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor) {
bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
// apply timelines for explicit sync
// save inFD otherwise reset will reset it
auto inFD = pMonitor->output->state->state().explicitInFence;
CFileDescriptor inFD(pMonitor->output->state->state().explicitInFence);
pMonitor->output->state->resetExplicitFences();
if (inFD >= 0)
pMonitor->output->state->setExplicitInFence(inFD);
if (inFD.isValid())
pMonitor->output->state->setExplicitInFence(inFD.get());
auto explicitOptions = getExplicitSyncSettings();
if (explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled)
pMonitor->output->state->enableExplicitOutFenceForNextCommit();
Expand All @@ -1525,7 +1525,7 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {

bool ok = pMonitor->state.commit();
if (!ok) {
if (inFD >= 0) {
if (inFD.isValid()) {
Debug::log(TRACE, "Monitor state commit failed, retrying without a fence");
pMonitor->output->state->resetExplicitFences();
ok = pMonitor->state.commit();
Expand All @@ -1543,12 +1543,9 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
if (!explicitOptions.explicitEnabled)
return ok;

if (inFD >= 0)
close(inFD);

if (pMonitor->output->state->state().explicitOutFence >= 0) {
Debug::log(TRACE, "Aquamarine returned an explicit out fence at {}", pMonitor->output->state->state().explicitOutFence);
close(pMonitor->output->state->state().explicitOutFence);
CFileDescriptor outFD(pMonitor->output->state->state().explicitOutFence);
if (outFD.isValid()) {
Debug::log(TRACE, "Aquamarine returned an explicit out fence at {}", outFD.get());
} else
Debug::log(TRACE, "Aquamarine did not return an explicit out fence");

Expand Down

0 comments on commit bf78c89

Please sign in to comment.