Skip to content

Commit

Permalink
nwindowReleaseBuffers: cancel dequeued buffer instead of failing
Browse files Browse the repository at this point in the history
  • Loading branch information
fincs committed Aug 19, 2024
1 parent 3c851a3 commit 7b4e02b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions nx/source/display/native_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ static Result _nwindowConnect(NWindow* nw)
return rc;
}

static Result _nwindowCancelBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence)
{
static const NvMultiFence s_emptyFence = {0};
if (!fence)
fence = &s_emptyFence;

Result rc = bqCancelBuffer(&nw->bq, slot, fence);
if (R_SUCCEEDED(rc))
nw->cur_slot = -1;

return rc;
}

static Result _nwindowDisconnect(NWindow* nw)
{
Result rc = bqDisconnect(&nw->bq, NATIVE_WINDOW_API_CPU);
Expand Down Expand Up @@ -267,13 +280,7 @@ Result nwindowCancelBuffer(NWindow* nw, s32 slot, const NvMultiFence* fence)
return MAKERESULT(Module_Libnx, LibnxError_BadGfxQueueBuffer);
}

static const NvMultiFence s_emptyFence = {0};
if (!fence)
fence = &s_emptyFence;

Result rc = bqCancelBuffer(&nw->bq, slot, fence);
if (R_SUCCEEDED(rc))
nw->cur_slot = -1;
Result rc = _nwindowCancelBuffer(nw, slot, fence);

mutexUnlock(&nw->mutex);
return rc;
Expand Down Expand Up @@ -323,8 +330,9 @@ Result nwindowReleaseBuffers(NWindow* nw)
mutexLock(&nw->mutex);

if (nw->cur_slot >= 0)
rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
else if (nw->is_connected && nw->slots_configured)
rc = _nwindowCancelBuffer(nw, nw->cur_slot, NULL);

if (R_SUCCEEDED(rc) && nw->is_connected && nw->slots_configured)
rc = _nwindowDisconnect(nw);

mutexUnlock(&nw->mutex);
Expand Down

0 comments on commit 7b4e02b

Please sign in to comment.