aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/service/nvflinger
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-02-21 11:31:53 -0500
committerLioncash <mathew1800@gmail.com>2019-02-21 22:09:46 -0500
commit90528f132678ea7dfa9ac4588ae2b8c7808d4685 (patch)
tree57a37cad480b9ec528914a8fc67b699ec8ad016d /src/core/hle/service/nvflinger
parentfd15730767860659bdb58e8cd33074530a708295 (diff)
service/nvflinger: Store BufferQueue instances as regular data members
The NVFlinger service is already passed into services that need to guarantee its lifetime, so the BufferQueue instances will already live as long as they're needed. Making them std::shared_ptr instances in this case is unnecessary.
Diffstat (limited to 'src/core/hle/service/nvflinger')
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp17
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h7
2 files changed, 17 insertions, 7 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 95bb55bbb..56f31e2ac 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -78,9 +78,8 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) {
const u64 layer_id = next_layer_id++;
const u32 buffer_queue_id = next_buffer_queue_id++;
- auto buffer_queue = std::make_shared<BufferQueue>(buffer_queue_id, layer_id);
- display->CreateLayer(layer_id, buffer_queue);
- buffer_queues.emplace_back(std::move(buffer_queue));
+ buffer_queues.emplace_back(buffer_queue_id, layer_id);
+ display->CreateLayer(layer_id, buffer_queues.back());
return layer_id;
}
@@ -104,9 +103,17 @@ Kernel::SharedPtr<Kernel::ReadableEvent> NVFlinger::FindVsyncEvent(u64 display_i
return display->GetVSyncEvent();
}
-std::shared_ptr<BufferQueue> NVFlinger::FindBufferQueue(u32 id) const {
+BufferQueue& NVFlinger::FindBufferQueue(u32 id) {
const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(),
- [&](const auto& queue) { return queue->GetId() == id; });
+ [id](const auto& queue) { return queue.GetId() == id; });
+
+ ASSERT(itr != buffer_queues.end());
+ return *itr;
+}
+
+const BufferQueue& NVFlinger::FindBufferQueue(u32 id) const {
+ const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(),
+ [id](const auto& queue) { return queue.GetId() == id; });
ASSERT(itr != buffer_queues.end());
return *itr;
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h
index f9458745a..c0a83fffb 100644
--- a/src/core/hle/service/nvflinger/nvflinger.h
+++ b/src/core/hle/service/nvflinger/nvflinger.h
@@ -65,7 +65,10 @@ public:
Kernel::SharedPtr<Kernel::ReadableEvent> FindVsyncEvent(u64 display_id) const;
/// Obtains a buffer queue identified by the ID.
- std::shared_ptr<BufferQueue> FindBufferQueue(u32 id) const;
+ BufferQueue& FindBufferQueue(u32 id);
+
+ /// Obtains a buffer queue identified by the ID.
+ const BufferQueue& FindBufferQueue(u32 id) const;
/// Performs a composition request to the emulated nvidia GPU and triggers the vsync events when
/// finished.
@@ -87,7 +90,7 @@ private:
std::shared_ptr<Nvidia::Module> nvdrv;
std::vector<VI::Display> displays;
- std::vector<std::shared_ptr<BufferQueue>> buffer_queues;
+ std::vector<BufferQueue> buffer_queues;
/// Id to use for the next layer that is created, this counter is shared among all displays.
u64 next_layer_id = 1;