diff options
author | bunnei <bunneidev@gmail.com> | 2020-12-11 00:32:52 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2020-12-29 01:33:47 +0100 |
commit | 19a8f03ad59abacb3fae60f7ba6d5d358e779c29 (patch) | |
tree | a5cbf27860e556f1034cc3797105f705c08e26a1 /src/core/hle/service/nvflinger | |
parent | hle: service: vi: Remove usage of SleepClientThread. (diff) | |
download | yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.tar yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.tar.gz yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.tar.bz2 yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.tar.lz yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.tar.xz yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.tar.zst yuzu-19a8f03ad59abacb3fae60f7ba6d5d358e779c29.zip |
Diffstat (limited to 'src/core/hle/service/nvflinger')
-rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 23 | ||||
-rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.h | 7 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 44aa2bdae..a7a679df1 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -104,6 +104,8 @@ void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { } std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { + const auto guard = Lock(); + LOG_DEBUG(Service, "Opening \"{}\" display", name); // TODO(Subv): Currently we only support the Default display. @@ -121,6 +123,7 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) { } std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { + const auto guard = Lock(); auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -135,12 +138,15 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) { } void NVFlinger::CloseLayer(u64 layer_id) { + const auto guard = Lock(); + for (auto& display : displays) { display.CloseLayer(layer_id); } } std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { + const auto guard = Lock(); const auto* const layer = FindLayer(display_id, layer_id); if (layer == nullptr) { @@ -151,6 +157,7 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co } std::shared_ptr<Kernel::ReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const { + const auto guard = Lock(); auto* const display = FindDisplay(display_id); if (display == nullptr) { @@ -160,20 +167,16 @@ std::shared_ptr<Kernel::ReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) return display->GetVSyncEvent(); } -BufferQueue& NVFlinger::FindBufferQueue(u32 id) { +BufferQueue* NVFlinger::FindBufferQueue(u32 id) { + const auto guard = Lock(); 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; -} - -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; }); + if (itr == buffer_queues.end()) { + return nullptr; + } - ASSERT(itr != buffer_queues.end()); - return *itr; + return &*itr; } VI::Display* NVFlinger::FindDisplay(u64 display_id) { diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 1ebe949c0..ce1347d6d 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -75,10 +75,7 @@ public: [[nodiscard]] std::shared_ptr<Kernel::ReadableEvent> FindVsyncEvent(u64 display_id) const; /// Obtains a buffer queue identified by the ID. - [[nodiscard]] BufferQueue& FindBufferQueue(u32 id); - - /// Obtains a buffer queue identified by the ID. - [[nodiscard]] const BufferQueue& FindBufferQueue(u32 id) const; + [[nodiscard]] BufferQueue* FindBufferQueue(u32 id); /// Performs a composition request to the emulated nvidia GPU and triggers the vsync events when /// finished. @@ -86,11 +83,11 @@ public: [[nodiscard]] s64 GetNextTicks() const; +private: [[nodiscard]] std::unique_lock<std::mutex> Lock() const { return std::unique_lock{*guard}; } -private: /// Finds the display identified by the specified ID. [[nodiscard]] VI::Display* FindDisplay(u64 display_id); |