diff options
| author | 2023-12-07 17:45:42 -0500 | |
|---|---|---|
| committer | 2023-12-16 13:40:04 -0500 | |
| commit | fcc85abe27eaeb8194302dbb392b490217b13d85 (patch) | |
| tree | b9510aca7cf7b2bf47512b324d21138c6099b399 /src | |
| parent | Merge pull request #12354 from liamwhite/mackage-panager (diff) | |
| download | yuzu-fcc85abe27eaeb8194302dbb392b490217b13d85.tar.gz yuzu-fcc85abe27eaeb8194302dbb392b490217b13d85.tar.xz yuzu-fcc85abe27eaeb8194302dbb392b490217b13d85.zip | |
nvnflinger: mark buffer as acquired when acquired
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp | 35 | ||||
| -rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_core.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvnflinger/buffer_slot.h | 1 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp index d91886bed..bbe8e06d4 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp | |||
| @@ -90,6 +90,18 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, | |||
| 90 | 90 | ||
| 91 | LOG_DEBUG(Service_Nvnflinger, "acquiring slot={}", slot); | 91 | LOG_DEBUG(Service_Nvnflinger, "acquiring slot={}", slot); |
| 92 | 92 | ||
| 93 | // If the front buffer is still being tracked, update its slot state | ||
| 94 | if (core->StillTracking(*front)) { | ||
| 95 | slots[slot].acquire_called = true; | ||
| 96 | slots[slot].needs_cleanup_on_release = false; | ||
| 97 | slots[slot].buffer_state = BufferState::Acquired; | ||
| 98 | |||
| 99 | // TODO: for now, avoid resetting the fence, so that when we next return this | ||
| 100 | // slot to the producer, it will wait for the fence to pass. We should fix this | ||
| 101 | // by properly waiting for the fence in the BufferItemConsumer. | ||
| 102 | // slots[slot].fence = Fence::NoFence(); | ||
| 103 | } | ||
| 104 | |||
| 93 | // If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to | 105 | // If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to |
| 94 | // avoid unnecessarily remapping this buffer on the consumer side. | 106 | // avoid unnecessarily remapping this buffer on the consumer side. |
| 95 | if (out_buffer->acquire_called) { | 107 | if (out_buffer->acquire_called) { |
| @@ -132,11 +144,28 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc | |||
| 132 | ++current; | 144 | ++current; |
| 133 | } | 145 | } |
| 134 | 146 | ||
| 135 | slots[slot].buffer_state = BufferState::Free; | 147 | if (slots[slot].buffer_state == BufferState::Acquired) { |
| 148 | // TODO: for now, avoid resetting the fence, so that when we next return this | ||
| 149 | // slot to the producer, it can wait for its own fence to pass. We should fix this | ||
| 150 | // by properly waiting for the fence in the BufferItemConsumer. | ||
| 151 | // slots[slot].fence = release_fence; | ||
| 152 | slots[slot].buffer_state = BufferState::Free; | ||
| 136 | 153 | ||
| 137 | listener = core->connected_producer_listener; | 154 | listener = core->connected_producer_listener; |
| 138 | 155 | ||
| 139 | LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); | 156 | LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); |
| 157 | } else if (slots[slot].needs_cleanup_on_release) { | ||
| 158 | LOG_DEBUG(Service_Nvnflinger, "releasing a stale buffer slot {} (state = {})", slot, | ||
| 159 | slots[slot].buffer_state); | ||
| 160 | slots[slot].needs_cleanup_on_release = false; | ||
| 161 | return Status::StaleBufferSlot; | ||
| 162 | } else { | ||
| 163 | LOG_ERROR(Service_Nvnflinger, | ||
| 164 | "attempted to release buffer slot {} but its state was {}", slot, | ||
| 165 | slots[slot].buffer_state); | ||
| 166 | |||
| 167 | return Status::BadValue; | ||
| 168 | } | ||
| 140 | 169 | ||
| 141 | core->SignalDequeueCondition(); | 170 | core->SignalDequeueCondition(); |
| 142 | } | 171 | } |
diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp index 4ed5e5978..5d8c861fa 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp | |||
| @@ -74,6 +74,10 @@ void BufferQueueCore::FreeBufferLocked(s32 slot) { | |||
| 74 | 74 | ||
| 75 | slots[slot].graphic_buffer.reset(); | 75 | slots[slot].graphic_buffer.reset(); |
| 76 | 76 | ||
| 77 | if (slots[slot].buffer_state == BufferState::Acquired) { | ||
| 78 | slots[slot].needs_cleanup_on_release = true; | ||
| 79 | } | ||
| 80 | |||
| 77 | slots[slot].buffer_state = BufferState::Free; | 81 | slots[slot].buffer_state = BufferState::Free; |
| 78 | slots[slot].frame_number = UINT32_MAX; | 82 | slots[slot].frame_number = UINT32_MAX; |
| 79 | slots[slot].acquire_called = false; | 83 | slots[slot].acquire_called = false; |
diff --git a/src/core/hle/service/nvnflinger/buffer_slot.h b/src/core/hle/service/nvnflinger/buffer_slot.h index d25bca049..37daca78b 100644 --- a/src/core/hle/service/nvnflinger/buffer_slot.h +++ b/src/core/hle/service/nvnflinger/buffer_slot.h | |||
| @@ -31,6 +31,7 @@ struct BufferSlot final { | |||
| 31 | u64 frame_number{}; | 31 | u64 frame_number{}; |
| 32 | Fence fence; | 32 | Fence fence; |
| 33 | bool acquire_called{}; | 33 | bool acquire_called{}; |
| 34 | bool needs_cleanup_on_release{}; | ||
| 34 | bool attached_by_consumer{}; | 35 | bool attached_by_consumer{}; |
| 35 | bool is_preallocated{}; | 36 | bool is_preallocated{}; |
| 36 | }; | 37 | }; |