From a342bcc9b130e9bd78720e09e04c92dcac8840d0 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Tue, 27 Nov 2018 09:18:29 -0500 Subject: kernel/event: Reference ReadableEvent from WritableEvent --- src/core/hle/service/nvflinger/buffer_queue.cpp | 14 ++++++-------- src/core/hle/service/nvflinger/buffer_queue.h | 8 ++------ src/core/hle/service/nvflinger/nvflinger.cpp | 10 ++++------ src/core/hle/service/nvflinger/nvflinger.h | 2 +- 4 files changed, 13 insertions(+), 21 deletions(-) (limited to 'src/core/hle/service/nvflinger') diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 7b07750b5..fc07d9bb8 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -16,8 +16,8 @@ namespace Service::NVFlinger { BufferQueue::BufferQueue(u32 id, u64 layer_id) : id(id), layer_id(layer_id) { auto& kernel = Core::System::GetInstance().Kernel(); - buffer_wait_event = Kernel::WritableEvent::CreateRegisteredEventPair( - kernel, Kernel::ResetType::Sticky, "BufferQueue NativeHandle"); + buffer_wait_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Sticky, + "BufferQueue NativeHandle"); } BufferQueue::~BufferQueue() = default; @@ -31,7 +31,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer) buffer.status = Buffer::Status::Free; queue.emplace_back(buffer); - buffer_wait_event->Signal(); + buffer_wait_event.writable->Signal(); } std::optional BufferQueue::DequeueBuffer(u32 width, u32 height) { @@ -90,7 +90,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) { ASSERT(itr->status == Buffer::Status::Acquired); itr->status = Buffer::Status::Free; - buffer_wait_event->Signal(); + buffer_wait_event.writable->Signal(); } u32 BufferQueue::Query(QueryType type) { @@ -108,13 +108,11 @@ u32 BufferQueue::Query(QueryType type) { } Kernel::SharedPtr BufferQueue::GetWritableBufferWaitEvent() const { - return buffer_wait_event; + return buffer_wait_event.writable; } Kernel::SharedPtr BufferQueue::GetBufferWaitEvent() const { - const auto& event{ - Core::System::GetInstance().Kernel().FindNamedEvent("BufferQueue NativeHandle")}; - return event->second; + return buffer_wait_event.readable; } } // namespace Service::NVFlinger diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 8b2a2b7de..b171f256c 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h @@ -11,16 +11,12 @@ #include "common/math_util.h" #include "common/swap.h" #include "core/hle/kernel/object.h" +#include "core/hle/kernel/writable_event.h" namespace CoreTiming { struct EventType; } -namespace Kernel { -class ReadableEvent; -class WritableEvent; -} // namespace Kernel - namespace Service::NVFlinger { struct IGBPBuffer { @@ -100,7 +96,7 @@ private: u64 layer_id; std::vector queue; - Kernel::SharedPtr buffer_wait_event; + Kernel::EventPair buffer_wait_event; }; } // namespace Service::NVFlinger diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 2a329cb8e..05af2d593 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -87,9 +87,7 @@ u32 NVFlinger::GetBufferQueueId(u64 display_id, u64 layer_id) { } Kernel::SharedPtr NVFlinger::GetVsyncEvent(u64 display_id) { - const auto& event{Core::System::GetInstance().Kernel().FindNamedEvent( - fmt::format("Display VSync Event {}", display_id))}; - return event->second; + return GetDisplay(display_id).vsync_event.readable; } std::shared_ptr NVFlinger::GetBufferQueue(u32 id) const { @@ -121,7 +119,7 @@ Layer& NVFlinger::GetLayer(u64 display_id, u64 layer_id) { void NVFlinger::Compose() { for (auto& display : displays) { // Trigger vsync for this display at the end of drawing - SCOPE_EXIT({ display.vsync_event->Signal(); }); + SCOPE_EXIT({ display.vsync_event.writable->Signal(); }); // Don't do anything for displays without layers. if (display.layers.empty()) @@ -168,8 +166,8 @@ Layer::~Layer() = default; Display::Display(u64 id, std::string name) : id(id), name(std::move(name)) { auto& kernel = Core::System::GetInstance().Kernel(); - vsync_event = Kernel::WritableEvent::CreateRegisteredEventPair( - kernel, Kernel::ResetType::Pulse, fmt::format("Display VSync Event {}", id)); + vsync_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Pulse, + fmt::format("Display VSync Event {}", id)); } Display::~Display() = default; diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 1a9e74f35..9abba555b 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -45,7 +45,7 @@ struct Display { std::string name; std::vector layers; - Kernel::SharedPtr vsync_event; + Kernel::EventPair vsync_event; }; class NVFlinger final { -- cgit v1.2.3