From fa4dc2cf427ddb464d73d532ba941513828b9b7a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 21 Feb 2019 10:43:26 -0500 Subject: [PATCH 1/3] service/nvflinger: Move display specifics over to vi_display With the display and layer structures relocated to the vi service, we can begin giving these a proper interface before beginning to properly support the display types. This converts the display struct into a class and provides it with the necessary functions to preserve behavior within the NVFlinger class. --- src/core/hle/service/nvflinger/nvflinger.cpp | 53 ++++++-------- src/core/hle/service/nvflinger/nvflinger.h | 2 +- .../hle/service/vi/display/vi_display.cpp | 49 +++++++++++++ src/core/hle/service/vi/display/vi_display.h | 72 ++++++++++++++++++- 4 files changed, 141 insertions(+), 35 deletions(-) diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index b5d452db1a..6cc31050f6 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -28,9 +28,13 @@ namespace Service::NVFlinger { constexpr std::size_t SCREEN_REFRESH_RATE = 60; constexpr u64 frame_ticks = static_cast(Core::Timing::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE); -NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) - : displays{{0, "Default"}, {1, "External"}, {2, "Edid"}, {3, "Internal"}, {4, "Null"}}, - core_timing{core_timing} { +NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_timing} { + displays.emplace_back(0, "Default"); + displays.emplace_back(1, "External"); + displays.emplace_back(2, "Edid"); + displays.emplace_back(3, "Internal"); + displays.emplace_back(4, "Null"); + // Schedule the screen composition events composition_event = core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) { @@ -55,13 +59,14 @@ std::optional NVFlinger::OpenDisplay(std::string_view name) { // TODO(Subv): Currently we only support the Default display. ASSERT(name == "Default"); - const auto itr = std::find_if(displays.begin(), displays.end(), - [&](const VI::Display& display) { return display.name == name; }); + const auto itr = + std::find_if(displays.begin(), displays.end(), + [&](const VI::Display& display) { return display.GetName() == name; }); if (itr == displays.end()) { return {}; } - return itr->id; + return itr->GetID(); } std::optional NVFlinger::CreateLayer(u64 display_id) { @@ -71,12 +76,10 @@ std::optional NVFlinger::CreateLayer(u64 display_id) { return {}; } - ASSERT_MSG(display->layers.empty(), "Only one layer is supported per display at the moment"); - const u64 layer_id = next_layer_id++; const u32 buffer_queue_id = next_buffer_queue_id++; auto buffer_queue = std::make_shared(buffer_queue_id, layer_id); - display->layers.emplace_back(layer_id, buffer_queue); + display->CreateLayer(layer_id, buffer_queue); buffer_queues.emplace_back(std::move(buffer_queue)); return layer_id; } @@ -98,7 +101,7 @@ Kernel::SharedPtr NVFlinger::FindVsyncEvent(u64 display_i return nullptr; } - return display->vsync_event.readable; + return display->GetVSyncEvent(); } std::shared_ptr NVFlinger::FindBufferQueue(u32 id) const { @@ -112,7 +115,7 @@ std::shared_ptr NVFlinger::FindBufferQueue(u32 id) const { VI::Display* NVFlinger::FindDisplay(u64 display_id) { const auto itr = std::find_if(displays.begin(), displays.end(), - [&](const VI::Display& display) { return display.id == display_id; }); + [&](const VI::Display& display) { return display.GetID() == display_id; }); if (itr == displays.end()) { return nullptr; @@ -124,7 +127,7 @@ VI::Display* NVFlinger::FindDisplay(u64 display_id) { const VI::Display* NVFlinger::FindDisplay(u64 display_id) const { const auto itr = std::find_if(displays.begin(), displays.end(), - [&](const VI::Display& display) { return display.id == display_id; }); + [&](const VI::Display& display) { return display.GetID() == display_id; }); if (itr == displays.end()) { return nullptr; @@ -140,14 +143,7 @@ VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) { return nullptr; } - const auto itr = std::find_if(display->layers.begin(), display->layers.end(), - [&](const VI::Layer& layer) { return layer.id == layer_id; }); - - if (itr == display->layers.end()) { - return nullptr; - } - - return &*itr; + return display->FindLayer(layer_id); } const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { @@ -157,29 +153,20 @@ const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const { return nullptr; } - const auto itr = std::find_if(display->layers.begin(), display->layers.end(), - [&](const VI::Layer& layer) { return layer.id == layer_id; }); - - if (itr == display->layers.end()) { - return nullptr; - } - - return &*itr; + return display->FindLayer(layer_id); } void NVFlinger::Compose() { for (auto& display : displays) { // Trigger vsync for this display at the end of drawing - SCOPE_EXIT({ display.vsync_event.writable->Signal(); }); + SCOPE_EXIT({ display.SignalVSyncEvent(); }); // Don't do anything for displays without layers. - if (display.layers.empty()) + if (!display.HasLayers()) continue; // TODO(Subv): Support more than 1 layer. - ASSERT_MSG(display.layers.size() == 1, "Max 1 layer per display is supported"); - - VI::Layer& layer = display.layers[0]; + VI::Layer& layer = display.GetLayer(0); auto& buffer_queue = layer.buffer_queue; // Search for a queued buffer and acquire it diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 2e000af915..4741b13638 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -28,7 +28,7 @@ class Module; } // namespace Service::Nvidia namespace Service::VI { -struct Display; +class Display; struct Layer; } // namespace Service::VI diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index a108e468f0..4d77c3353f 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -2,8 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include + #include +#include "common/assert.h" #include "core/core.h" #include "core/hle/kernel/readable_event.h" #include "core/hle/service/vi/display/vi_display.h" @@ -19,4 +23,49 @@ Display::Display(u64 id, std::string name) : id{id}, name{std::move(name)} { Display::~Display() = default; +Layer& Display::GetLayer(std::size_t index) { + return layers.at(index); +} + +const Layer& Display::GetLayer(std::size_t index) const { + return layers.at(index); +} + +Kernel::SharedPtr Display::GetVSyncEvent() const { + return vsync_event.readable; +} + +void Display::SignalVSyncEvent() { + vsync_event.writable->Signal(); +} + +void Display::CreateLayer(u64 id, std::shared_ptr buffer_queue) { + // TODO(Subv): Support more than 1 layer. + ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); + + layers.emplace_back(id, std::move(buffer_queue)); +} + +Layer* Display::FindLayer(u64 id) { + const auto itr = std::find_if(layers.begin(), layers.end(), + [id](const VI::Layer& layer) { return layer.id == id; }); + + if (itr == layers.end()) { + return nullptr; + } + + return &*itr; +} + +const Layer* Display::FindLayer(u64 id) const { + const auto itr = std::find_if(layers.begin(), layers.end(), + [id](const VI::Layer& layer) { return layer.id == id; }); + + if (itr == layers.end()) { + return nullptr; + } + + return &*itr; +} + } // namespace Service::VI diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index df44db3066..22b8315925 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -10,14 +10,84 @@ #include "common/common_types.h" #include "core/hle/kernel/writable_event.h" +namespace Service::NVFlinger { +class BufferQueue; +} + namespace Service::VI { struct Layer; -struct Display { +/// Represents a single display type +class Display { +public: + /// Constructs a display with a given unique ID and name. + /// + /// @param id The unique ID for this display. + /// @param name The name for this display. + /// Display(u64 id, std::string name); ~Display(); + Display(const Display&) = delete; + Display& operator=(const Display&) = delete; + + Display(Display&&) = default; + Display& operator=(Display&&) = default; + + /// Gets the unique ID assigned to this display. + u64 GetID() const { + return id; + } + + /// Gets the name of this display + const std::string& GetName() const { + return name; + } + + /// Whether or not this display has any layers added to it. + bool HasLayers() const { + return !layers.empty(); + } + + /// Gets a layer for this display based off an index. + Layer& GetLayer(std::size_t index); + + /// Gets a layer for this display based off an index. + const Layer& GetLayer(std::size_t index) const; + + /// Gets the readable vsync event. + Kernel::SharedPtr GetVSyncEvent() const; + + /// Signals the internal vsync event. + void SignalVSyncEvent(); + + /// Creates and adds a layer to this display with the given ID. + /// + /// @param id The ID to assign to the created layer. + /// @param buffer_queue The buffer queue for the layer instance to use. + /// + void CreateLayer(u64 id, std::shared_ptr buffer_queue); + + /// Attempts to find a layer with the given ID. + /// + /// @param id The layer ID. + /// + /// @returns If found, the Layer instance with the given ID. + /// If not found, then nullptr is returned. + /// + Layer* FindLayer(u64 id); + + /// Attempts to find a layer with the given ID. + /// + /// @param id The layer ID. + /// + /// @returns If found, the Layer instance with the given ID. + /// If not found, then nullptr is returned. + /// + const Layer* FindLayer(u64 id) const; + +private: u64 id; std::string name; From fd15730767860659bdb58e8cd33074530a708295 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 21 Feb 2019 10:56:20 -0500 Subject: [PATCH 2/3] service/vi/vi_layer: Convert Layer struct into a class Like the previous changes made to the Display struct, this prepares the Layer struct for changes to its interface. Given Layer will be given more invariants in the future, we convert it into a class to better signify that. --- src/core/hle/service/nvflinger/nvflinger.cpp | 8 ++--- src/core/hle/service/nvflinger/nvflinger.h | 2 +- .../hle/service/vi/display/vi_display.cpp | 4 +-- src/core/hle/service/vi/display/vi_display.h | 2 +- src/core/hle/service/vi/layer/vi_layer.cpp | 6 +++- src/core/hle/service/vi/layer/vi_layer.h | 31 ++++++++++++++++++- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 6cc31050f6..95bb55bbb6 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -91,7 +91,7 @@ std::optional NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) co return {}; } - return layer->buffer_queue->GetId(); + return layer->GetBufferQueue().GetId(); } Kernel::SharedPtr NVFlinger::FindVsyncEvent(u64 display_id) const { @@ -167,10 +167,10 @@ void NVFlinger::Compose() { // TODO(Subv): Support more than 1 layer. VI::Layer& layer = display.GetLayer(0); - auto& buffer_queue = layer.buffer_queue; + auto& buffer_queue = layer.GetBufferQueue(); // Search for a queued buffer and acquire it - auto buffer = buffer_queue->AcquireBuffer(); + auto buffer = buffer_queue.AcquireBuffer(); MicroProfileFlip(); @@ -195,7 +195,7 @@ void NVFlinger::Compose() { igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, buffer->get().transform, buffer->get().crop_rect); - buffer_queue->ReleaseBuffer(buffer->get().slot); + buffer_queue.ReleaseBuffer(buffer->get().slot); } } diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 4741b13638..f9458745ae 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -29,7 +29,7 @@ class Module; namespace Service::VI { class Display; -struct Layer; +class Layer; } // namespace Service::VI namespace Service::NVFlinger { diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 4d77c3353f..9c0afd152d 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -48,7 +48,7 @@ void Display::CreateLayer(u64 id, std::shared_ptr buffer Layer* Display::FindLayer(u64 id) { const auto itr = std::find_if(layers.begin(), layers.end(), - [id](const VI::Layer& layer) { return layer.id == id; }); + [id](const VI::Layer& layer) { return layer.GetID() == id; }); if (itr == layers.end()) { return nullptr; @@ -59,7 +59,7 @@ Layer* Display::FindLayer(u64 id) { const Layer* Display::FindLayer(u64 id) const { const auto itr = std::find_if(layers.begin(), layers.end(), - [id](const VI::Layer& layer) { return layer.id == id; }); + [id](const VI::Layer& layer) { return layer.GetID() == id; }); if (itr == layers.end()) { return nullptr; diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 22b8315925..8948102bc1 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -16,7 +16,7 @@ class BufferQueue; namespace Service::VI { -struct Layer; +class Layer; /// Represents a single display type class Display { diff --git a/src/core/hle/service/vi/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp index 3a83e5b953..48f4c57cb2 100644 --- a/src/core/hle/service/vi/layer/vi_layer.cpp +++ b/src/core/hle/service/vi/layer/vi_layer.cpp @@ -2,12 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/assert.h" #include "core/hle/service/vi/layer/vi_layer.h" namespace Service::VI { Layer::Layer(u64 id, std::shared_ptr queue) - : id{id}, buffer_queue{std::move(queue)} {} + : id{id}, buffer_queue{std::move(queue)} +{ + ASSERT_MSG(buffer_queue != nullptr, "buffer_queue may not be null."); +} Layer::~Layer() = default; diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h index df328e09fb..dd4f7e5967 100644 --- a/src/core/hle/service/vi/layer/vi_layer.h +++ b/src/core/hle/service/vi/layer/vi_layer.h @@ -14,10 +14,39 @@ class BufferQueue; namespace Service::VI { -struct Layer { +/// Represents a single display layer. +class Layer { +public: + /// Constructs a layer with a given ID and buffer queue. + /// + /// @param id The ID to assign to this layer. + /// @param queue The buffer queue for this layer to use. + /// Layer(u64 id, std::shared_ptr queue); ~Layer(); + Layer(const Layer&) = delete; + Layer& operator=(const Layer&) = delete; + + Layer(Layer&&) = default; + Layer& operator=(Layer&&) = default; + + /// Gets the ID for this layer. + u64 GetID() const { + return id; + } + + /// Gets a reference to the buffer queue this layer is using. + NVFlinger::BufferQueue& GetBufferQueue() { + return *buffer_queue; + } + + /// Gets a const reference to the buffer queue this layer is using. + const NVFlinger::BufferQueue& GetBufferQueue() const { + return *buffer_queue; + } + +private: u64 id; std::shared_ptr buffer_queue; }; From 90528f132678ea7dfa9ac4588ae2b8c7808d4685 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 21 Feb 2019 11:31:53 -0500 Subject: [PATCH 3/3] service/nvflinger: Store BufferQueue instances as regular data members The NVFlinger service is already passed into services that need to guarantee its lifetime, so the BufferQueue instances will already live as long as they're needed. Making them std::shared_ptr instances in this case is unnecessary. --- src/core/hle/service/nvflinger/nvflinger.cpp | 17 ++++++++---- src/core/hle/service/nvflinger/nvflinger.h | 7 +++-- .../hle/service/vi/display/vi_display.cpp | 4 +-- src/core/hle/service/vi/display/vi_display.h | 2 +- src/core/hle/service/vi/layer/vi_layer.cpp | 7 +---- src/core/hle/service/vi/layer/vi_layer.h | 12 ++++----- src/core/hle/service/vi/vi.cpp | 26 +++++++++---------- 7 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 95bb55bbb6..56f31e2ac4 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -78,9 +78,8 @@ std::optional NVFlinger::CreateLayer(u64 display_id) { const u64 layer_id = next_layer_id++; const u32 buffer_queue_id = next_buffer_queue_id++; - auto buffer_queue = std::make_shared(buffer_queue_id, layer_id); - display->CreateLayer(layer_id, buffer_queue); - buffer_queues.emplace_back(std::move(buffer_queue)); + buffer_queues.emplace_back(buffer_queue_id, layer_id); + display->CreateLayer(layer_id, buffer_queues.back()); return layer_id; } @@ -104,9 +103,17 @@ Kernel::SharedPtr NVFlinger::FindVsyncEvent(u64 display_i return display->GetVSyncEvent(); } -std::shared_ptr NVFlinger::FindBufferQueue(u32 id) const { +BufferQueue& NVFlinger::FindBufferQueue(u32 id) { const auto itr = std::find_if(buffer_queues.begin(), buffer_queues.end(), - [&](const auto& queue) { return queue->GetId() == id; }); + [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; }); ASSERT(itr != buffer_queues.end()); return *itr; diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index f9458745ae..c0a83fffb8 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h @@ -65,7 +65,10 @@ public: Kernel::SharedPtr FindVsyncEvent(u64 display_id) const; /// Obtains a buffer queue identified by the ID. - std::shared_ptr FindBufferQueue(u32 id) const; + BufferQueue& FindBufferQueue(u32 id); + + /// Obtains a buffer queue identified by the ID. + const BufferQueue& FindBufferQueue(u32 id) const; /// Performs a composition request to the emulated nvidia GPU and triggers the vsync events when /// finished. @@ -87,7 +90,7 @@ private: std::shared_ptr nvdrv; std::vector displays; - std::vector> buffer_queues; + std::vector buffer_queues; /// Id to use for the next layer that is created, this counter is shared among all displays. u64 next_layer_id = 1; diff --git a/src/core/hle/service/vi/display/vi_display.cpp b/src/core/hle/service/vi/display/vi_display.cpp index 9c0afd152d..01d80311b8 100644 --- a/src/core/hle/service/vi/display/vi_display.cpp +++ b/src/core/hle/service/vi/display/vi_display.cpp @@ -39,11 +39,11 @@ void Display::SignalVSyncEvent() { vsync_event.writable->Signal(); } -void Display::CreateLayer(u64 id, std::shared_ptr buffer_queue) { +void Display::CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue) { // TODO(Subv): Support more than 1 layer. ASSERT_MSG(layers.empty(), "Only one layer is supported per display at the moment"); - layers.emplace_back(id, std::move(buffer_queue)); + layers.emplace_back(id, buffer_queue); } Layer* Display::FindLayer(u64 id) { diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.h index 8948102bc1..2acd46ff8a 100644 --- a/src/core/hle/service/vi/display/vi_display.h +++ b/src/core/hle/service/vi/display/vi_display.h @@ -67,7 +67,7 @@ public: /// @param id The ID to assign to the created layer. /// @param buffer_queue The buffer queue for the layer instance to use. /// - void CreateLayer(u64 id, std::shared_ptr buffer_queue); + void CreateLayer(u64 id, NVFlinger::BufferQueue& buffer_queue); /// Attempts to find a layer with the given ID. /// diff --git a/src/core/hle/service/vi/layer/vi_layer.cpp b/src/core/hle/service/vi/layer/vi_layer.cpp index 48f4c57cb2..954225c26f 100644 --- a/src/core/hle/service/vi/layer/vi_layer.cpp +++ b/src/core/hle/service/vi/layer/vi_layer.cpp @@ -2,16 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/assert.h" #include "core/hle/service/vi/layer/vi_layer.h" namespace Service::VI { -Layer::Layer(u64 id, std::shared_ptr queue) - : id{id}, buffer_queue{std::move(queue)} -{ - ASSERT_MSG(buffer_queue != nullptr, "buffer_queue may not be null."); -} +Layer::Layer(u64 id, NVFlinger::BufferQueue& queue) : id{id}, buffer_queue{queue} {} Layer::~Layer() = default; diff --git a/src/core/hle/service/vi/layer/vi_layer.h b/src/core/hle/service/vi/layer/vi_layer.h index dd4f7e5967..c6bfd01f6e 100644 --- a/src/core/hle/service/vi/layer/vi_layer.h +++ b/src/core/hle/service/vi/layer/vi_layer.h @@ -4,8 +4,6 @@ #pragma once -#include - #include "common/common_types.h" namespace Service::NVFlinger { @@ -22,14 +20,14 @@ public: /// @param id The ID to assign to this layer. /// @param queue The buffer queue for this layer to use. /// - Layer(u64 id, std::shared_ptr queue); + Layer(u64 id, NVFlinger::BufferQueue& queue); ~Layer(); Layer(const Layer&) = delete; Layer& operator=(const Layer&) = delete; Layer(Layer&&) = default; - Layer& operator=(Layer&&) = default; + Layer& operator=(Layer&&) = delete; /// Gets the ID for this layer. u64 GetID() const { @@ -38,17 +36,17 @@ public: /// Gets a reference to the buffer queue this layer is using. NVFlinger::BufferQueue& GetBufferQueue() { - return *buffer_queue; + return buffer_queue; } /// Gets a const reference to the buffer queue this layer is using. const NVFlinger::BufferQueue& GetBufferQueue() const { - return *buffer_queue; + return buffer_queue; } private: u64 id; - std::shared_ptr buffer_queue; + NVFlinger::BufferQueue& buffer_queue; }; } // namespace Service::VI diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index a317a2885e..7369a09ecc 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -525,7 +525,7 @@ private: LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id, static_cast(transaction), flags); - auto buffer_queue = nv_flinger->FindBufferQueue(id); + auto& buffer_queue = nv_flinger->FindBufferQueue(id); if (transaction == TransactionId::Connect) { IGBPConnectRequestParcel request{ctx.ReadBuffer()}; @@ -538,7 +538,7 @@ private: } else if (transaction == TransactionId::SetPreallocatedBuffer) { IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()}; - buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer); + buffer_queue.SetPreallocatedBuffer(request.data.slot, request.buffer); IGBPSetPreallocatedBufferResponseParcel response{}; ctx.WriteBuffer(response.Serialize()); @@ -546,7 +546,7 @@ private: IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()}; const u32 width{request.data.width}; const u32 height{request.data.height}; - std::optional slot = buffer_queue->DequeueBuffer(width, height); + std::optional slot = buffer_queue.DequeueBuffer(width, height); if (slot) { // Buffer is available @@ -559,8 +559,8 @@ private: [=](Kernel::SharedPtr thread, Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) { // Repeat TransactParcel DequeueBuffer when a buffer is available - auto buffer_queue = nv_flinger->FindBufferQueue(id); - std::optional slot = buffer_queue->DequeueBuffer(width, height); + auto& buffer_queue = nv_flinger->FindBufferQueue(id); + std::optional slot = buffer_queue.DequeueBuffer(width, height); ASSERT_MSG(slot != std::nullopt, "Could not dequeue buffer."); IGBPDequeueBufferResponseParcel response{*slot}; @@ -568,28 +568,28 @@ private: IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); }, - buffer_queue->GetWritableBufferWaitEvent()); + buffer_queue.GetWritableBufferWaitEvent()); } } else if (transaction == TransactionId::RequestBuffer) { IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()}; - auto& buffer = buffer_queue->RequestBuffer(request.slot); + auto& buffer = buffer_queue.RequestBuffer(request.slot); IGBPRequestBufferResponseParcel response{buffer}; ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::QueueBuffer) { IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; - buffer_queue->QueueBuffer(request.data.slot, request.data.transform, - request.data.GetCropRect()); + buffer_queue.QueueBuffer(request.data.slot, request.data.transform, + request.data.GetCropRect()); IGBPQueueBufferResponseParcel response{1280, 720}; ctx.WriteBuffer(response.Serialize()); } else if (transaction == TransactionId::Query) { IGBPQueryRequestParcel request{ctx.ReadBuffer()}; - u32 value = - buffer_queue->Query(static_cast(request.type)); + const u32 value = + buffer_queue.Query(static_cast(request.type)); IGBPQueryResponseParcel response{value}; ctx.WriteBuffer(response.Serialize()); @@ -629,12 +629,12 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown); - const auto buffer_queue = nv_flinger->FindBufferQueue(id); + const auto& buffer_queue = nv_flinger->FindBufferQueue(id); // TODO(Subv): Find out what this actually is. IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(buffer_queue->GetBufferWaitEvent()); + rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent()); } std::shared_ptr nv_flinger;