From 260a495a234088934f8167e4fe4d9d393e0d9c5e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 28 Nov 2022 19:06:31 -0500 Subject: consumer_base: Remove redundant virtual override already serves this purpose --- src/core/hle/service/nvflinger/consumer_base.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/nvflinger/consumer_base.h b/src/core/hle/service/nvflinger/consumer_base.h index 90ba07f45..7be477c43 100644 --- a/src/core/hle/service/nvflinger/consumer_base.h +++ b/src/core/hle/service/nvflinger/consumer_base.h @@ -27,12 +27,12 @@ public: protected: explicit ConsumerBase(std::unique_ptr consumer_); - virtual ~ConsumerBase(); + ~ConsumerBase() override; - virtual void OnFrameAvailable(const BufferItem& item) override; - virtual void OnFrameReplaced(const BufferItem& item) override; - virtual void OnBuffersReleased() override; - virtual void OnSidebandStreamChanged() override; + void OnFrameAvailable(const BufferItem& item) override; + void OnFrameReplaced(const BufferItem& item) override; + void OnBuffersReleased() override; + void OnSidebandStreamChanged() override; void FreeBufferLocked(s32 slot_index); Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when); -- cgit v1.2.3 From c0c4f6dfa6f45d3ab0b4f7b7d243fa9fc3fe973a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 28 Nov 2022 19:09:41 -0500 Subject: consumer_base: Pass shared_ptr by const reference Avoids churning atomic reference count increments and decrements. --- src/core/hle/service/nvflinger/consumer_base.cpp | 6 +++--- src/core/hle/service/nvflinger/consumer_base.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/nvflinger/consumer_base.cpp b/src/core/hle/service/nvflinger/consumer_base.cpp index 5b9995854..982531e2d 100644 --- a/src/core/hle/service/nvflinger/consumer_base.cpp +++ b/src/core/hle/service/nvflinger/consumer_base.cpp @@ -83,7 +83,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco } Status ConsumerBase::AddReleaseFenceLocked(s32 slot, - const std::shared_ptr graphic_buffer, + const std::shared_ptr& graphic_buffer, const Fence& fence) { LOG_DEBUG(Service_NVFlinger, "slot={}", slot); @@ -100,7 +100,7 @@ Status ConsumerBase::AddReleaseFenceLocked(s32 slot, } Status ConsumerBase::ReleaseBufferLocked(s32 slot, - const std::shared_ptr graphic_buffer) { + const std::shared_ptr& graphic_buffer) { // If consumer no longer tracks this graphic_buffer (we received a new // buffer on the same slot), the buffer producer is definitely no longer // tracking it. @@ -121,7 +121,7 @@ Status ConsumerBase::ReleaseBufferLocked(s32 slot, } bool ConsumerBase::StillTracking(s32 slot, - const std::shared_ptr graphic_buffer) const { + const std::shared_ptr& graphic_buffer) const { if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) { return false; } diff --git a/src/core/hle/service/nvflinger/consumer_base.h b/src/core/hle/service/nvflinger/consumer_base.h index 7be477c43..9a8a5f6bb 100644 --- a/src/core/hle/service/nvflinger/consumer_base.h +++ b/src/core/hle/service/nvflinger/consumer_base.h @@ -36,9 +36,9 @@ protected: void FreeBufferLocked(s32 slot_index); Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when); - Status ReleaseBufferLocked(s32 slot, const std::shared_ptr graphic_buffer); - bool StillTracking(s32 slot, const std::shared_ptr graphic_buffer) const; - Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr graphic_buffer, + Status ReleaseBufferLocked(s32 slot, const std::shared_ptr& graphic_buffer); + bool StillTracking(s32 slot, const std::shared_ptr& graphic_buffer) const; + Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr& graphic_buffer, const Fence& fence); struct Slot final { -- cgit v1.2.3 From 3020f72b0ced962115dec59def983eb70f7c004f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 28 Nov 2022 19:12:23 -0500 Subject: buffer_queue_consumer: std::move std::shared_ptr in Connect() Avoids an unnecessary reference count increment and decrement --- src/core/hle/service/nvflinger/buffer_queue_consumer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp index 1ce67c771..0767e548d 100644 --- a/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue_consumer.cpp @@ -169,7 +169,7 @@ Status BufferQueueConsumer::Connect(std::shared_ptr consumer_ return Status::NoInit; } - core->consumer_listener = consumer_listener; + core->consumer_listener = std::move(consumer_listener); core->consumer_controlled_by_app = controlled_by_app; return Status::NoError; -- cgit v1.2.3 From ae74f46e787e426610b9d9523db9e9981fede18c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 28 Nov 2022 19:15:24 -0500 Subject: buffer_item_consumer: Pass fence by const-ref in ReleaseBuffer() This isn't directly modified. Also allows rvalues to be used with it. --- src/core/hle/service/nvflinger/buffer_item_consumer.cpp | 2 +- src/core/hle/service/nvflinger/buffer_item_consumer.h | 2 +- src/core/hle/service/nvflinger/nvflinger.cpp | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp index 6d2c92a2c..152bb5bdf 100644 --- a/src/core/hle/service/nvflinger/buffer_item_consumer.cpp +++ b/src/core/hle/service/nvflinger/buffer_item_consumer.cpp @@ -39,7 +39,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco return Status::NoError; } -Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) { +Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, const Fence& release_fence) { std::scoped_lock lock{mutex}; if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence); diff --git a/src/core/hle/service/nvflinger/buffer_item_consumer.h b/src/core/hle/service/nvflinger/buffer_item_consumer.h index 69046233d..a5c655d9e 100644 --- a/src/core/hle/service/nvflinger/buffer_item_consumer.h +++ b/src/core/hle/service/nvflinger/buffer_item_consumer.h @@ -22,7 +22,7 @@ public: explicit BufferItemConsumer(std::unique_ptr consumer); Status AcquireBuffer(BufferItem* item, std::chrono::nanoseconds present_when, bool wait_for_fence = true); - Status ReleaseBuffer(const BufferItem& item, Fence& release_fence); + Status ReleaseBuffer(const BufferItem& item, const Fence& release_fence); }; } // namespace Service::android diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index c3af12c90..d1cbadde4 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -307,8 +307,7 @@ void NVFlinger::Compose() { swap_interval = buffer.swap_interval; - auto fence = android::Fence::NoFence(); - layer.GetConsumer().ReleaseBuffer(buffer, fence); + layer.GetConsumer().ReleaseBuffer(buffer, android::Fence::NoFence()); } } -- cgit v1.2.3