summaryrefslogtreecommitdiff
path: root/src/core/hle/service/nvnflinger
diff options
context:
space:
mode:
authorGravatar Liam2023-10-20 10:17:16 -0400
committerGravatar Liam2023-10-20 10:17:32 -0400
commit689f346e9728bde1944808dc0b1984349e9895cf (patch)
treebede50029732fb14417da2c6456555375b2653f3 /src/core/hle/service/nvnflinger
parentMerge pull request #11822 from german77/no-name (diff)
downloadyuzu-689f346e9728bde1944808dc0b1984349e9895cf.tar.gz
yuzu-689f346e9728bde1944808dc0b1984349e9895cf.tar.xz
yuzu-689f346e9728bde1944808dc0b1984349e9895cf.zip
nvnflinger: fix reporting and freeing of preallocated buffers
Co-authored-by: Kelebek1 <eeeedddccc@hotmail.co.uk>
Diffstat (limited to 'src/core/hle/service/nvnflinger')
-rw-r--r--src/core/hle/service/nvnflinger/buffer_queue_core.cpp6
-rw-r--r--src/core/hle/service/nvnflinger/buffer_queue_producer.cpp5
2 files changed, 6 insertions, 5 deletions
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp
index 2dbe29616..ed66f6f5b 100644
--- a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp
+++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp
@@ -41,7 +41,7 @@ bool BufferQueueCore::WaitForDequeueCondition(std::unique_lock<std::mutex>& lk)
41s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const { 41s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
42 // If DequeueBuffer is allowed to error out, we don't have to add an extra buffer. 42 // If DequeueBuffer is allowed to error out, we don't have to add an extra buffer.
43 if (!use_async_buffer) { 43 if (!use_async_buffer) {
44 return max_acquired_buffer_count; 44 return 0;
45 } 45 }
46 46
47 if (dequeue_buffer_cannot_block || async) { 47 if (dequeue_buffer_cannot_block || async) {
@@ -52,7 +52,7 @@ s32 BufferQueueCore::GetMinUndequeuedBufferCountLocked(bool async) const {
52} 52}
53 53
54s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const { 54s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const {
55 return GetMinUndequeuedBufferCountLocked(async) + 1; 55 return GetMinUndequeuedBufferCountLocked(async);
56} 56}
57 57
58s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const { 58s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
@@ -61,7 +61,7 @@ s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
61 61
62 if (override_max_buffer_count != 0) { 62 if (override_max_buffer_count != 0) {
63 ASSERT(override_max_buffer_count >= min_buffer_count); 63 ASSERT(override_max_buffer_count >= min_buffer_count);
64 max_buffer_count = override_max_buffer_count; 64 return override_max_buffer_count;
65 } 65 }
66 66
67 // Any buffers that are dequeued by the producer or sitting in the queue waiting to be consumed 67 // Any buffers that are dequeued by the producer or sitting in the queue waiting to be consumed
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
index dc6917d5d..6e7a49658 100644
--- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
+++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp
@@ -134,7 +134,7 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St
134 const s32 max_buffer_count = core->GetMaxBufferCountLocked(async); 134 const s32 max_buffer_count = core->GetMaxBufferCountLocked(async);
135 if (async && core->override_max_buffer_count) { 135 if (async && core->override_max_buffer_count) {
136 if (core->override_max_buffer_count < max_buffer_count) { 136 if (core->override_max_buffer_count < max_buffer_count) {
137 LOG_ERROR(Service_Nvnflinger, "async mode is invalid with buffer count override"); 137 *found = BufferQueueCore::INVALID_BUFFER_SLOT;
138 return Status::BadValue; 138 return Status::BadValue;
139 } 139 }
140 } 140 }
@@ -142,7 +142,8 @@ Status BufferQueueProducer::WaitForFreeSlotThenRelock(bool async, s32* found, St
142 // Free up any buffers that are in slots beyond the max buffer count 142 // Free up any buffers that are in slots beyond the max buffer count
143 for (s32 s = max_buffer_count; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) { 143 for (s32 s = max_buffer_count; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
144 ASSERT(slots[s].buffer_state == BufferState::Free); 144 ASSERT(slots[s].buffer_state == BufferState::Free);
145 if (slots[s].graphic_buffer != nullptr) { 145 if (slots[s].graphic_buffer != nullptr && slots[s].buffer_state == BufferState::Free &&
146 !slots[s].is_preallocated) {
146 core->FreeBufferLocked(s); 147 core->FreeBufferLocked(s);
147 *return_flags |= Status::ReleaseAllBuffers; 148 *return_flags |= Status::ReleaseAllBuffers;
148 } 149 }