VERY experimental Nintendo Switch 2 emulator
C++
vi: implement CloseDisplay
Liam4351ab1ff1d8
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cppindex dad93b38e2..c3af12c90a 100644--- a/src/core/hle/service/nvflinger/nvflinger.cpp+++ b/src/core/hle/service/nvflinger/nvflinger.cpp@@ -138,6 +138,19 @@ std::optional<u64> NVFlinger::OpenDisplay(std::string_view name) {return itr->GetID();}+bool NVFlinger::CloseDisplay(u64 display_id) {+ const auto lock_guard = Lock();+ auto* const display = FindDisplay(display_id);++ if (display == nullptr) {+ return false;+ }++ display->Reset();++ return true;+}+std::optional<u64> NVFlinger::CreateLayer(u64 display_id) {const auto lock_guard = Lock();auto* const display = FindDisplay(display_id);diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.hindex b8191c5954..460bef976d 100644--- a/src/core/hle/service/nvflinger/nvflinger.h+++ b/src/core/hle/service/nvflinger/nvflinger.h@@ -58,6 +58,11 @@ public:/// If an invalid display name is provided, then an empty optional is returned.[[nodiscard]] std::optional<u64> OpenDisplay(std::string_view name);+ /// Closes the specified display by its ID.+ ///+ /// Returns false if an invalid display ID is provided.+ [[nodiscard]] bool CloseDisplay(u64 display_id);+/// Creates a layer on the specified display and returns the layer ID.////// If an invalid display ID is specified, then an empty optional is returned.diff --git a/src/core/hle/service/vi/display/vi_display.h b/src/core/hle/service/vi/display/vi_display.hindex 33d5f398cd..0b65a65da9 100644--- a/src/core/hle/service/vi/display/vi_display.h+++ b/src/core/hle/service/vi/display/vi_display.h@@ -106,6 +106,12 @@ public:///void CloseLayer(u64 layer_id);+ /// Resets the display for a new connection.+ void Reset() {+ layers.clear();+ got_vsync_event = false;+ }+/// Attempts to find a layer with the given ID.////// @param layer_id The layer ID.diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cppindex 9c917cacfe..bb283e74e3 100644--- a/src/core/hle/service/vi/vi.cpp+++ b/src/core/hle/service/vi/vi.cpp@@ -324,10 +324,10 @@ private:IPC::RequestParser rp{ctx};const u64 display = rp.Pop<u64>();- LOG_WARNING(Service_VI, "(STUBBED) called. display=0x{:016X}", display);+ const Result rc = nv_flinger.CloseDisplay(display) ? ResultSuccess : ResultUnknown;IPC::ResponseBuilder rb{ctx, 2};- rb.Push(ResultSuccess);+ rb.Push(rc);}void CreateManagedLayer(Kernel::HLERequestContext& ctx) {@@ -508,10 +508,10 @@ private:IPC::RequestParser rp{ctx};const u64 display_id = rp.Pop<u64>();- LOG_WARNING(Service_VI, "(STUBBED) called. display_id=0x{:016X}", display_id);+ const Result rc = nv_flinger.CloseDisplay(display_id) ? ResultSuccess : ResultUnknown;IPC::ResponseBuilder rb{ctx, 2};- rb.Push(ResultSuccess);+ rb.Push(rc);}// This literally does nothing internally in the actual service itself,