summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2022-04-01 22:58:40 -0700
committerGravatar bunnei2022-04-01 22:58:40 -0700
commit4036e37bbef38da8bc8ae017a049409219be1e51 (patch)
tree43c414006412a15b8d752f4fc6c6084b745f4ffc /src
parenthle: service: nvflinger: buffer_queue_producer: Cleanup & add GetReleasedBuff... (diff)
downloadyuzu-4036e37bbef38da8bc8ae017a049409219be1e51.tar.gz
yuzu-4036e37bbef38da8bc8ae017a049409219be1e51.tar.xz
yuzu-4036e37bbef38da8bc8ae017a049409219be1e51.zip
hle: service: nvflinger: consumer_base: Cleanup & fixes.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.cpp29
-rw-r--r--src/core/hle/service/nvflinger/consumer_base.h3
2 files changed, 17 insertions, 15 deletions
diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvflinger/consumer_base.cpp
index be65a3f88..c2c80832c 100644
--- a/src/core/hle/service/nvflinger/consumer_base.cpp
+++ b/src/core/hle/service/nvflinger/consumer_base.cpp
@@ -36,38 +36,41 @@ void ConsumerBase::FreeBufferLocked(s32 slot_index) {
36} 36}
37 37
38void ConsumerBase::OnFrameAvailable(const BufferItem& item) { 38void ConsumerBase::OnFrameAvailable(const BufferItem& item) {
39 std::scoped_lock lock(mutex);
40 LOG_DEBUG(Service_NVFlinger, "called"); 39 LOG_DEBUG(Service_NVFlinger, "called");
41} 40}
42 41
43void ConsumerBase::OnFrameReplaced(const BufferItem& item) { 42void ConsumerBase::OnFrameReplaced(const BufferItem& item) {
44 std::scoped_lock lock(mutex);
45 LOG_DEBUG(Service_NVFlinger, "called"); 43 LOG_DEBUG(Service_NVFlinger, "called");
46} 44}
47 45
48void ConsumerBase::OnBuffersReleased() { 46void ConsumerBase::OnBuffersReleased() {
49 std::scoped_lock lock(mutex); 47 std::scoped_lock lock(mutex);
50 LOG_DEBUG(Service_NVFlinger, "called");
51}
52 48
53void ConsumerBase::OnSidebandStreamChanged() {} 49 LOG_DEBUG(Service_NVFlinger, "called");
54 50
55Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when,
56 u64 max_frame_number) {
57 if (is_abandoned) { 51 if (is_abandoned) {
58 LOG_ERROR(Service_NVFlinger, "consumer is abandoned!"); 52 // Nothing to do if we're already abandoned.
59 return Status::NoInit; 53 return;
60 } 54 }
61 55
62 Status err = consumer->AcquireBuffer(item, present_when, max_frame_number); 56 u64 mask = 0;
57 consumer->GetReleasedBuffers(&mask);
58 for (int i = 0; i < BufferQueueDefs::NUM_BUFFER_SLOTS; i++) {
59 if (mask & (1ULL << i)) {
60 FreeBufferLocked(i);
61 }
62 }
63}
64
65void ConsumerBase::OnSidebandStreamChanged() {}
66
67Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when) {
68 Status err = consumer->AcquireBuffer(item, present_when);
63 if (err != Status::NoError) { 69 if (err != Status::NoError) {
64 return err; 70 return err;
65 } 71 }
66 72
67 if (item->graphic_buffer != nullptr) { 73 if (item->graphic_buffer != nullptr) {
68 if (slots[item->slot].graphic_buffer != nullptr) {
69 FreeBufferLocked(item->slot);
70 }
71 slots[item->slot].graphic_buffer = item->graphic_buffer; 74 slots[item->slot].graphic_buffer = item->graphic_buffer;
72 } 75 }
73 76
diff --git a/src/core/hle/service/nvflinger/consumer_base.h b/src/core/hle/service/nvflinger/consumer_base.h
index 9ab949420..736080e3a 100644
--- a/src/core/hle/service/nvflinger/consumer_base.h
+++ b/src/core/hle/service/nvflinger/consumer_base.h
@@ -35,8 +35,7 @@ protected:
35 virtual void OnSidebandStreamChanged() override; 35 virtual void OnSidebandStreamChanged() override;
36 36
37 void FreeBufferLocked(s32 slot_index); 37 void FreeBufferLocked(s32 slot_index);
38 Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when, 38 Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when);
39 u64 max_frame_number = 0);
40 Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer); 39 Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer);
41 bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer) const; 40 bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer) const;
42 Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer, 41 Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer,