diff options
author | Liam <byteslice@airmail.cc> | 2023-12-10 18:32:44 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-12-12 18:14:23 +0100 |
commit | adc307961357243a67ed4400d18ec9979a0c55db (patch) | |
tree | c1a143b2be065e4a7cf7bd03918b77576c1e0507 /src/core/hle/service/nvnflinger | |
parent | Merge pull request #12296 from liamwhite/client-session (diff) | |
download | yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.gz yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.bz2 yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.lz yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.xz yuzu-adc307961357243a67ed4400d18ec9979a0c55db.tar.zst yuzu-adc307961357243a67ed4400d18ec9979a0c55db.zip |
Diffstat (limited to 'src/core/hle/service/nvnflinger')
-rw-r--r-- | src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp | 3 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/nvnflinger.cpp | 42 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/nvnflinger.h | 11 |
3 files changed, 30 insertions, 26 deletions
diff --git a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp index 75bf31e32..2fef6cc1a 100644 --- a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp +++ b/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp @@ -204,8 +204,9 @@ Result FbShareBufferManager::Initialize(u64* out_buffer_id, u64* out_layer_id, u // Record the display id. m_display_id = display_id; - // Create a layer for the display. + // Create and open a layer for the display. m_layer_id = m_flinger.CreateLayer(m_display_id).value(); + m_flinger.OpenLayer(m_layer_id); // Set up the buffer. m_buffer_id = m_next_buffer_id++; diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index 0745434c5..6352b09a9 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp @@ -176,17 +176,37 @@ void Nvnflinger::CreateLayerAtId(VI::Display& display, u64 layer_id) { display.CreateLayer(layer_id, buffer_id, nvdrv->container); } +void Nvnflinger::OpenLayer(u64 layer_id) { + const auto lock_guard = Lock(); + + for (auto& display : displays) { + if (auto* layer = display.FindLayer(layer_id); layer) { + layer->Open(); + } + } +} + void Nvnflinger::CloseLayer(u64 layer_id) { const auto lock_guard = Lock(); for (auto& display : displays) { - display.CloseLayer(layer_id); + if (auto* layer = display.FindLayer(layer_id); layer) { + layer->Close(); + } + } +} + +void Nvnflinger::DestroyLayer(u64 layer_id) { + const auto lock_guard = Lock(); + + for (auto& display : displays) { + display.DestroyLayer(layer_id); } } std::optional<u32> Nvnflinger::FindBufferQueueId(u64 display_id, u64 layer_id) { const auto lock_guard = Lock(); - const auto* const layer = FindOrCreateLayer(display_id, layer_id); + const auto* const layer = FindLayer(display_id, layer_id); if (layer == nullptr) { return std::nullopt; @@ -240,24 +260,6 @@ VI::Layer* Nvnflinger::FindLayer(u64 display_id, u64 layer_id) { return display->FindLayer(layer_id); } -VI::Layer* Nvnflinger::FindOrCreateLayer(u64 display_id, u64 layer_id) { - auto* const display = FindDisplay(display_id); - - if (display == nullptr) { - return nullptr; - } - - auto* layer = display->FindLayer(layer_id); - - if (layer == nullptr) { - LOG_DEBUG(Service_Nvnflinger, "Layer at id {} not found. Trying to create it.", layer_id); - CreateLayerAtId(*display, layer_id); - return display->FindLayer(layer_id); - } - - return layer; -} - void Nvnflinger::Compose() { for (auto& display : displays) { // Trigger vsync for this display at the end of drawing diff --git a/src/core/hle/service/nvnflinger/nvnflinger.h b/src/core/hle/service/nvnflinger/nvnflinger.h index f5d73acdb..871285764 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.h +++ b/src/core/hle/service/nvnflinger/nvnflinger.h @@ -73,9 +73,15 @@ public: /// If an invalid display ID is specified, then an empty optional is returned. [[nodiscard]] std::optional<u64> CreateLayer(u64 display_id); + /// Opens a layer on all displays for the given layer ID. + void OpenLayer(u64 layer_id); + /// Closes a layer on all displays for the given layer ID. void CloseLayer(u64 layer_id); + /// Destroys the given layer ID. + void DestroyLayer(u64 layer_id); + /// Finds the buffer queue ID of the specified layer in the specified display. /// /// If an invalid display ID or layer ID is provided, then an empty optional is returned. @@ -117,11 +123,6 @@ private: /// Finds the layer identified by the specified ID in the desired display. [[nodiscard]] VI::Layer* FindLayer(u64 display_id, u64 layer_id); - /// Finds the layer identified by the specified ID in the desired display, - /// or creates the layer if it is not found. - /// To be used when the system expects the specified ID to already exist. - [[nodiscard]] VI::Layer* FindOrCreateLayer(u64 display_id, u64 layer_id); - /// Creates a layer with the specified layer ID in the desired display. void CreateLayerAtId(VI::Display& display, u64 layer_id); |