hle: kernel: Migrate KEvent to KAutoObject.
This commit is contained in:
parent
086db71e94
commit
addc0bf037
37 changed files with 269 additions and 266 deletions
|
@ -7,7 +7,6 @@
|
|||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/kernel/k_writable_event.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/service/nvflinger/buffer_queue.h"
|
||||
|
@ -15,9 +14,8 @@
|
|||
namespace Service::NVFlinger {
|
||||
|
||||
BufferQueue::BufferQueue(Kernel::KernelCore& kernel, u32 id, u64 layer_id)
|
||||
: id(id), layer_id(layer_id) {
|
||||
buffer_wait_event = Kernel::KEvent::Create(kernel, "BufferQueue:WaitEvent");
|
||||
buffer_wait_event->Initialize();
|
||||
: id(id), layer_id(layer_id), buffer_wait_event{kernel} {
|
||||
buffer_wait_event.Initialize("BufferQueue:WaitEvent");
|
||||
}
|
||||
|
||||
BufferQueue::~BufferQueue() = default;
|
||||
|
@ -42,7 +40,7 @@ void BufferQueue::SetPreallocatedBuffer(u32 slot, const IGBPBuffer& igbp_buffer)
|
|||
.multi_fence = {},
|
||||
};
|
||||
|
||||
buffer_wait_event->GetWritableEvent()->Signal();
|
||||
buffer_wait_event.GetWritableEvent()->Signal();
|
||||
}
|
||||
|
||||
std::optional<std::pair<u32, Service::Nvidia::MultiFence*>> BufferQueue::DequeueBuffer(u32 width,
|
||||
|
@ -120,7 +118,7 @@ void BufferQueue::CancelBuffer(u32 slot, const Service::Nvidia::MultiFence& mult
|
|||
}
|
||||
free_buffers_condition.notify_one();
|
||||
|
||||
buffer_wait_event->GetWritableEvent()->Signal();
|
||||
buffer_wait_event.GetWritableEvent()->Signal();
|
||||
}
|
||||
|
||||
std::optional<std::reference_wrapper<const BufferQueue::Buffer>> BufferQueue::AcquireBuffer() {
|
||||
|
@ -155,7 +153,7 @@ void BufferQueue::ReleaseBuffer(u32 slot) {
|
|||
}
|
||||
free_buffers_condition.notify_one();
|
||||
|
||||
buffer_wait_event->GetWritableEvent()->Signal();
|
||||
buffer_wait_event.GetWritableEvent()->Signal();
|
||||
}
|
||||
|
||||
void BufferQueue::Connect() {
|
||||
|
@ -170,7 +168,7 @@ void BufferQueue::Disconnect() {
|
|||
std::unique_lock lock{queue_sequence_mutex};
|
||||
queue_sequence.clear();
|
||||
}
|
||||
buffer_wait_event->GetWritableEvent()->Signal();
|
||||
buffer_wait_event.GetWritableEvent()->Signal();
|
||||
is_connect = false;
|
||||
free_buffers_condition.notify_one();
|
||||
}
|
||||
|
@ -190,11 +188,11 @@ u32 BufferQueue::Query(QueryType type) {
|
|||
}
|
||||
|
||||
std::shared_ptr<Kernel::KWritableEvent> BufferQueue::GetWritableBufferWaitEvent() const {
|
||||
return buffer_wait_event->GetWritableEvent();
|
||||
return buffer_wait_event.GetWritableEvent();
|
||||
}
|
||||
|
||||
std::shared_ptr<Kernel::KReadableEvent> BufferQueue::GetBufferWaitEvent() const {
|
||||
return SharedFrom(buffer_wait_event->GetReadableEvent());
|
||||
return buffer_wait_event.GetReadableEvent();
|
||||
}
|
||||
|
||||
} // namespace Service::NVFlinger
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "common/common_funcs.h"
|
||||
#include "common/math_util.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/kernel/k_readable_event.h"
|
||||
#include "core/hle/kernel/object.h"
|
||||
#include "core/hle/service/nvdrv/nvdata.h"
|
||||
|
@ -130,7 +131,7 @@ private:
|
|||
std::list<u32> free_buffers;
|
||||
std::array<Buffer, buffer_slots> buffers;
|
||||
std::list<u32> queue_sequence;
|
||||
std::shared_ptr<Kernel::KEvent> buffer_wait_event;
|
||||
Kernel::KEvent buffer_wait_event;
|
||||
|
||||
std::mutex free_buffers_mutex;
|
||||
std::condition_variable free_buffers_condition;
|
||||
|
|
|
@ -165,8 +165,8 @@ std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co
|
|||
return layer->GetBufferQueue().GetId();
|
||||
}
|
||||
|
||||
std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) const {
|
||||
const auto lock_guard = Lock();
|
||||
std::shared_ptr<Kernel::KReadableEvent> NVFlinger::FindVsyncEvent(u64 display_id) {
|
||||
const auto lock_guard = Lock();
|
||||
auto* const display = FindDisplay(display_id);
|
||||
|
||||
if (display == nullptr) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
@ -72,7 +73,7 @@ public:
|
|||
/// Gets the vsync event for the specified display.
|
||||
///
|
||||
/// If an invalid display ID is provided, then nullptr is returned.
|
||||
[[nodiscard]] std::shared_ptr<Kernel::KReadableEvent> FindVsyncEvent(u64 display_id) const;
|
||||
[[nodiscard]] std::shared_ptr<Kernel::KReadableEvent> FindVsyncEvent(u64 display_id);
|
||||
|
||||
/// Obtains a buffer queue identified by the ID.
|
||||
[[nodiscard]] BufferQueue* FindBufferQueue(u32 id);
|
||||
|
@ -106,7 +107,7 @@ private:
|
|||
|
||||
std::shared_ptr<Nvidia::Module> nvdrv;
|
||||
|
||||
std::vector<VI::Display> displays;
|
||||
std::list<VI::Display> displays;
|
||||
std::vector<std::unique_ptr<BufferQueue>> buffer_queues;
|
||||
|
||||
/// Id to use for the next layer that is created, this counter is shared among all displays.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue