diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/kernel/readable_event.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/readable_event.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/timer.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/timer.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/wait_object.h | 6 | ||||
-rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 66 | ||||
-rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.h | 35 | ||||
-rw-r--r-- | src/core/hle/service/vi/vi.cpp | 10 |
8 files changed, 70 insertions, 59 deletions
diff --git a/src/core/hle/kernel/readable_event.cpp b/src/core/hle/kernel/readable_event.cpp index 6973e580c..0e5083f70 100644 --- a/src/core/hle/kernel/readable_event.cpp +++ b/src/core/hle/kernel/readable_event.cpp @@ -44,8 +44,4 @@ ResultCode ReadableEvent::Reset() { return RESULT_SUCCESS; } -void ReadableEvent::WakeupAllWaitingThreads() { - WaitObject::WakeupAllWaitingThreads(); -} - } // namespace Kernel diff --git a/src/core/hle/kernel/readable_event.h b/src/core/hle/kernel/readable_event.h index 80b3b0aba..77a9c362c 100644 --- a/src/core/hle/kernel/readable_event.h +++ b/src/core/hle/kernel/readable_event.h @@ -39,8 +39,6 @@ public: bool ShouldWait(Thread* thread) const override; void Acquire(Thread* thread) override; - void WakeupAllWaitingThreads() override; - /// Unconditionally clears the readable event's state. void Clear(); diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 2c4f50e2b..3afe60469 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -66,10 +66,6 @@ void Timer::Clear() { signaled = false; } -void Timer::WakeupAllWaitingThreads() { - WaitObject::WakeupAllWaitingThreads(); -} - void Timer::Signal(int cycles_late) { LOG_TRACE(Kernel, "Timer {} fired", GetObjectId()); diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index 12915c1b1..ce3e74426 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -51,8 +51,6 @@ public: bool ShouldWait(Thread* thread) const override; void Acquire(Thread* thread) override; - void WakeupAllWaitingThreads() override; - /** * Starts the timer, with the specified initial delay and interval. * @param initial Delay until the timer is first fired diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index d70b67893..5987fb971 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h @@ -33,19 +33,19 @@ public: * Add a thread to wait on this object * @param thread Pointer to thread to add */ - virtual void AddWaitingThread(SharedPtr<Thread> thread); + void AddWaitingThread(SharedPtr<Thread> thread); /** * Removes a thread from waiting on this object (e.g. if it was resumed already) * @param thread Pointer to thread to remove */ - virtual void RemoveWaitingThread(Thread* thread); + void RemoveWaitingThread(Thread* thread); /** * Wake up all threads waiting on this object that can be awoken, in priority order, * and set the synchronization result and output of the thread. */ - virtual void WakeupAllWaitingThreads(); + void WakeupAllWaitingThreads(); /** * Wakes up a single thread waiting on this object. diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 6a613aeab..8dfc0df03 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -5,7 +5,6 @@ #include <algorithm> #include <optional> -#include "common/alignment.h" #include "common/assert.h" #include "common/logging/log.h" #include "common/microprofile.h" @@ -22,7 +21,6 @@ #include "core/hle/service/nvflinger/nvflinger.h" #include "core/perf_stats.h" #include "video_core/renderer_base.h" -#include "video_core/video_core.h" namespace Service::NVFlinger { @@ -30,12 +28,6 @@ constexpr std::size_t SCREEN_REFRESH_RATE = 60; constexpr u64 frame_ticks = static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE); NVFlinger::NVFlinger() { - // Add the different displays to the list of displays. - displays.emplace_back(0, "Default"); - displays.emplace_back(1, "External"); - displays.emplace_back(2, "Edid"); - displays.emplace_back(3, "Internal"); - // Schedule the screen composition events composition_event = CoreTiming::RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) { @@ -55,13 +47,13 @@ void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { } u64 NVFlinger::OpenDisplay(std::string_view name) { - LOG_WARNING(Service, "Opening display {}", name); + LOG_DEBUG(Service, "Opening \"{}\" display", name); // TODO(Subv): Currently we only support the Default display. ASSERT(name == "Default"); - auto itr = std::find_if(displays.begin(), displays.end(), - [&](const Display& display) { return display.name == name; }); + const auto itr = std::find_if(displays.begin(), displays.end(), + [&](const Display& display) { return display.name == name; }); ASSERT(itr != displays.end()); @@ -69,48 +61,66 @@ u64 NVFlinger::OpenDisplay(std::string_view name) { } u64 NVFlinger::CreateLayer(u64 display_id) { - auto& display = GetDisplay(display_id); + auto& display = FindDisplay(display_id); ASSERT_MSG(display.layers.empty(), "Only one layer is supported per display at the moment"); - u64 layer_id = next_layer_id++; - u32 buffer_queue_id = next_buffer_queue_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.layers.emplace_back(layer_id, buffer_queue); buffer_queues.emplace_back(std::move(buffer_queue)); return layer_id; } -u32 NVFlinger::GetBufferQueueId(u64 display_id, u64 layer_id) { - const auto& layer = GetLayer(display_id, layer_id); +u32 NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const { + const auto& layer = FindLayer(display_id, layer_id); return layer.buffer_queue->GetId(); } Kernel::SharedPtr<Kernel::ReadableEvent> NVFlinger::GetVsyncEvent(u64 display_id) { - return GetDisplay(display_id).vsync_event.readable; + return FindDisplay(display_id).vsync_event.readable; } -std::shared_ptr<BufferQueue> NVFlinger::GetBufferQueue(u32 id) const { - auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), - [&](const auto& queue) { return queue->GetId() == id; }); +std::shared_ptr<BufferQueue> NVFlinger::FindBufferQueue(u32 id) const { + const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), + [&](const auto& queue) { return queue->GetId() == id; }); ASSERT(itr != buffer_queues.end()); return *itr; } -Display& NVFlinger::GetDisplay(u64 display_id) { - auto itr = std::find_if(displays.begin(), displays.end(), - [&](const Display& display) { return display.id == display_id; }); +Display& NVFlinger::FindDisplay(u64 display_id) { + const auto itr = std::find_if(displays.begin(), displays.end(), + [&](const Display& display) { return display.id == display_id; }); + + ASSERT(itr != displays.end()); + return *itr; +} + +const Display& NVFlinger::FindDisplay(u64 display_id) const { + const auto itr = std::find_if(displays.begin(), displays.end(), + [&](const Display& display) { return display.id == display_id; }); ASSERT(itr != displays.end()); return *itr; } -Layer& NVFlinger::GetLayer(u64 display_id, u64 layer_id) { - auto& display = GetDisplay(display_id); +Layer& NVFlinger::FindLayer(u64 display_id, u64 layer_id) { + auto& display = FindDisplay(display_id); + + const auto itr = std::find_if(display.layers.begin(), display.layers.end(), + [&](const Layer& layer) { return layer.id == layer_id; }); + + ASSERT(itr != display.layers.end()); + return *itr; +} + +const Layer& NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { + const auto& display = FindDisplay(display_id); - auto itr = std::find_if(display.layers.begin(), display.layers.end(), - [&](const Layer& layer) { return layer.id == layer_id; }); + const auto itr = std::find_if(display.layers.begin(), display.layers.end(), + [&](const Layer& layer) { return layer.id == layer_id; }); ASSERT(itr != display.layers.end()); return *itr; @@ -145,7 +155,7 @@ void NVFlinger::Compose() { continue; } - auto& igbp_buffer = buffer->get().igbp_buffer; + const auto& igbp_buffer = buffer->get().igbp_buffer; // Now send the buffer to the GPU for drawing. // TODO(Subv): Support more than just disp0. The display device selection is probably based diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 9abba555b..83e974ed3 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -4,6 +4,7 @@ #pragma once +#include <array> #include <memory> #include <string> #include <string_view> @@ -56,35 +57,47 @@ public: /// Sets the NVDrv module instance to use to send buffers to the GPU. void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance); - /// Opens the specified display and returns the id. + /// Opens the specified display and returns the ID. u64 OpenDisplay(std::string_view name); - /// Creates a layer on the specified display and returns the layer id. + /// Creates a layer on the specified display and returns the layer ID. u64 CreateLayer(u64 display_id); - /// Gets the buffer queue id of the specified layer in the specified display. - u32 GetBufferQueueId(u64 display_id, u64 layer_id); + /// Finds the buffer queue ID of the specified layer in the specified display. + u32 FindBufferQueueId(u64 display_id, u64 layer_id) const; /// Gets the vsync event for the specified display. Kernel::SharedPtr<Kernel::ReadableEvent> GetVsyncEvent(u64 display_id); - /// Obtains a buffer queue identified by the id. - std::shared_ptr<BufferQueue> GetBufferQueue(u32 id) const; + /// Obtains a buffer queue identified by the ID. + std::shared_ptr<BufferQueue> FindBufferQueue(u32 id) const; /// Performs a composition request to the emulated nvidia GPU and triggers the vsync events when /// finished. void Compose(); private: - /// Returns the display identified by the specified id. - Display& GetDisplay(u64 display_id); + /// Finds the display identified by the specified ID. + Display& FindDisplay(u64 display_id); - /// Returns the layer identified by the specified id in the desired display. - Layer& GetLayer(u64 display_id, u64 layer_id); + /// Finds the display identified by the specified ID. + const Display& FindDisplay(u64 display_id) const; + + /// Finds the layer identified by the specified ID in the desired display. + Layer& FindLayer(u64 display_id, u64 layer_id); + + /// Finds the layer identified by the specified ID in the desired display. + const Layer& FindLayer(u64 display_id, u64 layer_id) const; std::shared_ptr<Nvidia::Module> nvdrv; - std::vector<Display> displays; + std::array<Display, 5> displays{{ + {0, "Default"}, + {1, "External"}, + {2, "Edid"}, + {3, "Internal"}, + {4, "Null"}, + }}; std::vector<std::shared_ptr<BufferQueue>> buffer_queues; /// Id to use for the next layer that is created, this counter is shared among all displays. diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 0f2c25182..fe08c38f2 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -524,7 +524,7 @@ private: LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, static_cast<u32>(transaction), flags); - auto buffer_queue = nv_flinger->GetBufferQueue(id); + auto buffer_queue = nv_flinger->FindBufferQueue(id); if (transaction == TransactionId::Connect) { IGBPConnectRequestParcel request{ctx.ReadBuffer()}; @@ -558,7 +558,7 @@ private: [=](Kernel::SharedPtr<Kernel::Thread> thread, Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) { // Repeat TransactParcel DequeueBuffer when a buffer is available - auto buffer_queue = nv_flinger->GetBufferQueue(id); + auto buffer_queue = nv_flinger->FindBufferQueue(id); std::optional<u32> slot = buffer_queue->DequeueBuffer(width, height); ASSERT_MSG(slot != std::nullopt, "Could not dequeue buffer."); @@ -628,7 +628,7 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); - const auto buffer_queue = nv_flinger->GetBufferQueue(id); + const auto buffer_queue = nv_flinger->FindBufferQueue(id); // TODO(Subv): Find out what this actually is. IPC::ResponseBuilder rb{ctx, 2, 1}; @@ -1044,7 +1044,7 @@ private: LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid); const u64 display_id = nv_flinger->OpenDisplay(display_name); - const u32 buffer_queue_id = nv_flinger->GetBufferQueueId(display_id, layer_id); + const u32 buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, layer_id); NativeWindow native_window{buffer_queue_id}; IPC::ResponseBuilder rb{ctx, 4}; @@ -1063,7 +1063,7 @@ private: // TODO(Subv): What's the difference between a Stray and a Managed layer? const u64 layer_id = nv_flinger->CreateLayer(display_id); - const u32 buffer_queue_id = nv_flinger->GetBufferQueueId(display_id, layer_id); + const u32 buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, layer_id); NativeWindow native_window{buffer_queue_id}; IPC::ResponseBuilder rb{ctx, 6}; |