mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Merge pull request #6968 from bunnei/nvflinger-event
core: hle: service: nvflinger/vi: Improve management of KEvent.
This commit is contained in:
commit
d9ce179ec2
4 changed files with 30 additions and 16 deletions
|
@ -61,12 +61,13 @@ void NVFlinger::SplitVSync() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NVFlinger::NVFlinger(Core::System& system_) : system(system_) {
|
NVFlinger::NVFlinger(Core::System& system_)
|
||||||
displays.emplace_back(0, "Default", system);
|
: system(system_), service_context(system_, "nvflinger") {
|
||||||
displays.emplace_back(1, "External", system);
|
displays.emplace_back(0, "Default", service_context, system);
|
||||||
displays.emplace_back(2, "Edid", system);
|
displays.emplace_back(1, "External", service_context, system);
|
||||||
displays.emplace_back(3, "Internal", system);
|
displays.emplace_back(2, "Edid", service_context, system);
|
||||||
displays.emplace_back(4, "Null", system);
|
displays.emplace_back(3, "Internal", service_context, system);
|
||||||
|
displays.emplace_back(4, "Null", service_context, system);
|
||||||
guard = std::make_shared<std::mutex>();
|
guard = std::make_shared<std::mutex>();
|
||||||
|
|
||||||
// Schedule the screen composition events
|
// Schedule the screen composition events
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class Event;
|
class Event;
|
||||||
|
@ -135,6 +136,8 @@ private:
|
||||||
std::unique_ptr<std::thread> vsync_thread;
|
std::unique_ptr<std::thread> vsync_thread;
|
||||||
std::unique_ptr<Common::Event> wait_event;
|
std::unique_ptr<Common::Event> wait_event;
|
||||||
std::atomic<bool> is_running{};
|
std::atomic<bool> is_running{};
|
||||||
|
|
||||||
|
KernelHelpers::ServiceContext service_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::NVFlinger
|
} // namespace Service::NVFlinger
|
||||||
|
|
|
@ -12,18 +12,21 @@
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
#include "core/hle/kernel/k_readable_event.h"
|
#include "core/hle/kernel/k_readable_event.h"
|
||||||
#include "core/hle/kernel/k_writable_event.h"
|
#include "core/hle/kernel/k_writable_event.h"
|
||||||
|
#include "core/hle/service/kernel_helpers.h"
|
||||||
#include "core/hle/service/vi/display/vi_display.h"
|
#include "core/hle/service/vi/display/vi_display.h"
|
||||||
#include "core/hle/service/vi/layer/vi_layer.h"
|
#include "core/hle/service/vi/layer/vi_layer.h"
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
Display::Display(u64 id, std::string name_, Core::System& system)
|
Display::Display(u64 id, std::string name_, KernelHelpers::ServiceContext& service_context_,
|
||||||
: display_id{id}, name{std::move(name_)}, vsync_event{system.Kernel()} {
|
Core::System& system_)
|
||||||
Kernel::KAutoObject::Create(std::addressof(vsync_event));
|
: display_id{id}, name{std::move(name_)}, service_context{service_context_} {
|
||||||
vsync_event.Initialize(fmt::format("Display VSync Event {}", id));
|
vsync_event = service_context.CreateEvent(fmt::format("Display VSync Event {}", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Display::~Display() = default;
|
Display::~Display() {
|
||||||
|
service_context.CloseEvent(vsync_event);
|
||||||
|
}
|
||||||
|
|
||||||
Layer& Display::GetLayer(std::size_t index) {
|
Layer& Display::GetLayer(std::size_t index) {
|
||||||
return *layers.at(index);
|
return *layers.at(index);
|
||||||
|
@ -34,11 +37,11 @@ const Layer& Display::GetLayer(std::size_t index) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::KReadableEvent& Display::GetVSyncEvent() {
|
Kernel::KReadableEvent& Display::GetVSyncEvent() {
|
||||||
return vsync_event.GetReadableEvent();
|
return vsync_event->GetReadableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::SignalVSyncEvent() {
|
void Display::SignalVSyncEvent() {
|
||||||
vsync_event.GetWritableEvent().Signal();
|
vsync_event->GetWritableEvent().Signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) {
|
void Display::CreateLayer(u64 layer_id, NVFlinger::BufferQueue& buffer_queue) {
|
||||||
|
|
|
@ -18,6 +18,9 @@ class KEvent;
|
||||||
namespace Service::NVFlinger {
|
namespace Service::NVFlinger {
|
||||||
class BufferQueue;
|
class BufferQueue;
|
||||||
}
|
}
|
||||||
|
namespace Service::KernelHelpers {
|
||||||
|
class ServiceContext;
|
||||||
|
} // namespace Service::KernelHelpers
|
||||||
|
|
||||||
namespace Service::VI {
|
namespace Service::VI {
|
||||||
|
|
||||||
|
@ -32,9 +35,12 @@ public:
|
||||||
/// Constructs a display with a given unique ID and name.
|
/// Constructs a display with a given unique ID and name.
|
||||||
///
|
///
|
||||||
/// @param id The unique ID for this display.
|
/// @param id The unique ID for this display.
|
||||||
|
/// @param service_context_ The ServiceContext for the owning service.
|
||||||
/// @param name_ The name for this display.
|
/// @param name_ The name for this display.
|
||||||
|
/// @param system_ The global system instance.
|
||||||
///
|
///
|
||||||
Display(u64 id, std::string name_, Core::System& system);
|
Display(u64 id, std::string name_, KernelHelpers::ServiceContext& service_context_,
|
||||||
|
Core::System& system_);
|
||||||
~Display();
|
~Display();
|
||||||
|
|
||||||
/// Gets the unique ID assigned to this display.
|
/// Gets the unique ID assigned to this display.
|
||||||
|
@ -98,9 +104,10 @@ public:
|
||||||
private:
|
private:
|
||||||
u64 display_id;
|
u64 display_id;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
KernelHelpers::ServiceContext& service_context;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Layer>> layers;
|
std::vector<std::shared_ptr<Layer>> layers;
|
||||||
Kernel::KEvent vsync_event;
|
Kernel::KEvent* vsync_event{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::VI
|
} // namespace Service::VI
|
||||||
|
|
Loading…
Reference in a new issue