mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-26 19:32:40 -06:00
nvnflinger: fix reporting and freeing of preallocated buffers
Co-authored-by: Kelebek1 <eeeedddccc@hotmail.co.uk>
This commit is contained in:
parent
85a89ca3e3
commit
689f346e97
2 changed files with 6 additions and 5 deletions
|
@ -41,7 +41,7 @@ bool BufferQueueCore::WaitForDequeueCondition(std::unique_lock<std::mutex>& lk)
|
||||||
s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
|
s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
|
||||||
// If DequeueBuffer is allowed to error out, we don't have to add an extra buffer.
|
// If DequeueBuffer is allowed to error out, we don't have to add an extra buffer.
|
||||||
if (!use_async_buffer) {
|
if (!use_async_buffer) {
|
||||||
return max_acquired_buffer_count;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dequeue_buffer_cannot_block || async) {
|
if (dequeue_buffer_cannot_block || async) {
|
||||||
|
@ -52,7 +52,7 @@ s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const {
|
s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const {
|
||||||
return GetMinUndequeuedBufferCountLocked(async) + 1;
|
return GetMinUndequeuedBufferCountLocked(async);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
||||||
|
@ -61,7 +61,7 @@ s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
||||||
|
|
||||||
if (override_max_buffer_count != 0) {
|
if (override_max_buffer_count != 0) {
|
||||||
ASSERT(override_max_buffer_count >= min_buffer_count);
|
ASSERT(override_max_buffer_count >= min_buffer_count);
|
||||||
max_buffer_count = override_max_buffer_count;
|
return override_max_buffer_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any buffers that are dequeued by the producer or sitting in the queue waiting to be consumed
|
// Any buffers that are dequeued by the producer or sitting in the queue waiting to be consumed
|
||||||
|
|
|
@ -134,7 +134,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St
|
||||||
const s32 max_buffer_count = core->GetMaxBufferCountLocked(async);
|
const s32 max_buffer_count = core->GetMaxBufferCountLocked(async);
|
||||||
if (async && core->override_max_buffer_count) {
|
if (async && core->override_max_buffer_count) {
|
||||||
if (core->override_max_buffer_count < max_buffer_count) {
|
if (core->override_max_buffer_count < max_buffer_count) {
|
||||||
LOG_ERROR(Service_Nvnflinger, "async mode is invalid with buffer count override");
|
*found = BufferQueueCore::INVALID_BUFFER_SLOT;
|
||||||
return Status::BadValue;
|
return Status::BadValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,8 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St
|
||||||
// Free up any buffers that are in slots beyond the max buffer count
|
// Free up any buffers that are in slots beyond the max buffer count
|
||||||
for (s32 s = max_buffer_count; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
|
for (s32 s = max_buffer_count; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
|
||||||
ASSERT(slots[s].buffer_state == BufferState::Free);
|
ASSERT(slots[s].buffer_state == BufferState::Free);
|
||||||
if (slots[s].graphic_buffer != nullptr) {
|
if (slots[s].graphic_buffer != nullptr && slots[s].buffer_state == BufferState::Free &&
|
||||||
|
!slots[s].is_preallocated) {
|
||||||
core->FreeBufferLocked(s);
|
core->FreeBufferLocked(s);
|
||||||
*return_flags |= Status::ReleaseAllBuffers;
|
*return_flags |= Status::ReleaseAllBuffers;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue