VERY experimental Nintendo Switch 2 emulator
C++
vi: extract types
Liama989a7ad9c3d
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex bc7f95fea9..188ca20974 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -965,6 +965,7 @@ add_library(core STATIChle/service/vi/vi_m.hhle/service/vi/vi_s.cpphle/service/vi/vi_s.h+ hle/service/vi/vi_types.hhle/service/vi/vi_u.cpphle/service/vi/vi_u.hinternal_network/network.cppdiff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cppindex 12d7e8cb18..548498e835 100644--- a/src/core/hle/service/am/service/common_state_getter.cpp+++ b/src/core/hle/service/am/service/common_state_getter.cpp@@ -11,6 +11,7 @@#include "core/hle/service/pm/pm.h"#include "core/hle/service/sm/sm.h"#include "core/hle/service/vi/vi.h"+#include "core/hle/service/vi/vi_types.h"namespace Service::AM {diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cppindex d508ed28cb..fc0880c177 100644--- a/src/core/hle/service/vi/vi.cpp+++ b/src/core/hle/service/vi/vi.cpp@@ -1,28 +1,20 @@// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project// SPDX-License-Identifier: GPL-2.0-or-later-#include <algorithm>#include <array>-#include <cstring>#include <memory>#include <optional>#include <type_traits>#include <utility>-#include "common/alignment.h"#include "common/assert.h"-#include "common/common_funcs.h"#include "common/logging/log.h"#include "common/math_util.h"#include "common/settings.h"#include "common/string_util.h"-#include "common/swap.h"-#include "core/core_timing.h"#include "core/hle/kernel/k_readable_event.h"#include "core/hle/kernel/k_thread.h"#include "core/hle/service/ipc_helpers.h"-#include "core/hle/service/nvdrv/devices/nvmap.h"-#include "core/hle/service/nvdrv/nvdata.h"#include "core/hle/service/nvdrv/nvdrv.h"#include "core/hle/service/nvnflinger/binder.h"#include "core/hle/service/nvnflinger/buffer_queue_producer.h"@@ -36,45 +28,11 @@#include "core/hle/service/vi/vi_m.h"#include "core/hle/service/vi/vi_results.h"#include "core/hle/service/vi/vi_s.h"+#include "core/hle/service/vi/vi_types.h"#include "core/hle/service/vi/vi_u.h"namespace Service::VI {-struct DisplayInfo {- /// The name of this particular display.- char display_name[0x40]{"Default"};-- /// Whether or not the display has a limited number of layers.- u8 has_limited_layers{1};- INSERT_PADDING_BYTES(7);-- /// Indicates the total amount of layers supported by the display.- /// @note This is only valid if has_limited_layers is set.- u64 max_layers{1};-- /// Maximum width in pixels.- u64 width{1920};-- /// Maximum height in pixels.- u64 height{1080};-};-static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");--class NativeWindow final {-public:- constexpr explicit NativeWindow(u32 id_) : id{id_} {}- constexpr explicit NativeWindow(const NativeWindow& other) = default;--private:- const u32 magic = 2;- const u32 process_id = 1;- const u64 id;- INSERT_PADDING_WORDS(2);- std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};- INSERT_PADDING_WORDS(2);-};-static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size");-class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {public:explicit IHOSBinderDriver(Core::System& system_, Nvnflinger::HosBinderDriverServer& server_)diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.hindex ee4bcbcfa4..e7a38fdbd0 100644--- a/src/core/hle/service/vi/vi.h+++ b/src/core/hle/service/vi/vi.h@@ -20,26 +20,7 @@ class Nvnflinger;namespace Service::VI {-enum class DisplayResolution : u32 {- DockedWidth = 1920,- DockedHeight = 1080,- UndockedWidth = 1280,- UndockedHeight = 720,-};--/// Permission level for a particular VI service instance-enum class Permission {- User,- System,- Manager,-};--/// A policy type that may be requested via GetDisplayService and-/// GetDisplayServiceWithProxyNameExchange-enum class Policy {- User,- Compositor,-};+enum class Permission;namespace detail {void GetDisplayServiceImpl(HLERequestContext& ctx, Core::System& system,diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cppindex 0f06dc2f36..b1b98cf110 100644--- a/src/core/hle/service/vi/vi_m.cpp+++ b/src/core/hle/service/vi/vi_m.cpp@@ -4,13 +4,14 @@#include "common/logging/log.h"#include "core/hle/service/vi/vi.h"#include "core/hle/service/vi/vi_m.h"+#include "core/hle/service/vi/vi_types.h"namespace Service::VI {VI_M::VI_M(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)- : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{- hos_binder_driver_server_} {+ : ServiceFramework{system_, "vi:m"}, nv_flinger{nv_flinger_},+ hos_binder_driver_server{hos_binder_driver_server_} {static const FunctionInfo functions[] = {{2, &VI_M::GetDisplayService, "GetDisplayService"},{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},diff --git a/src/core/hle/service/vi/vi_s.cpp b/src/core/hle/service/vi/vi_s.cppindex 77f7a88ff6..2400694b01 100644--- a/src/core/hle/service/vi/vi_s.cpp+++ b/src/core/hle/service/vi/vi_s.cpp@@ -4,13 +4,14 @@#include "common/logging/log.h"#include "core/hle/service/vi/vi.h"#include "core/hle/service/vi/vi_s.h"+#include "core/hle/service/vi/vi_types.h"namespace Service::VI {VI_S::VI_S(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)- : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{- hos_binder_driver_server_} {+ : ServiceFramework{system_, "vi:s"}, nv_flinger{nv_flinger_},+ hos_binder_driver_server{hos_binder_driver_server_} {static const FunctionInfo functions[] = {{1, &VI_S::GetDisplayService, "GetDisplayService"},{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},diff --git a/src/core/hle/service/vi/vi_types.h b/src/core/hle/service/vi/vi_types.hnew file mode 100644index 0000000000..59976fc72d--- /dev/null+++ b/src/core/hle/service/vi/vi_types.h@@ -0,0 +1,66 @@+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include "common/common_funcs.h"++namespace Service::VI {++enum class DisplayResolution : u32 {+ DockedWidth = 1920,+ DockedHeight = 1080,+ UndockedWidth = 1280,+ UndockedHeight = 720,+};++/// Permission level for a particular VI service instance+enum class Permission {+ User,+ System,+ Manager,+};++/// A policy type that may be requested via GetDisplayService and+/// GetDisplayServiceWithProxyNameExchange+enum class Policy {+ User,+ Compositor,+};++struct DisplayInfo {+ /// The name of this particular display.+ char display_name[0x40]{"Default"};++ /// Whether or not the display has a limited number of layers.+ u8 has_limited_layers{1};+ INSERT_PADDING_BYTES(7);++ /// Indicates the total amount of layers supported by the display.+ /// @note This is only valid if has_limited_layers is set.+ u64 max_layers{1};++ /// Maximum width in pixels.+ u64 width{1920};++ /// Maximum height in pixels.+ u64 height{1080};+};+static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");++class NativeWindow final {+public:+ constexpr explicit NativeWindow(u32 id_) : id{id_} {}+ constexpr explicit NativeWindow(const NativeWindow& other) = default;++private:+ const u32 magic = 2;+ const u32 process_id = 1;+ const u64 id;+ INSERT_PADDING_WORDS(2);+ std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};+ INSERT_PADDING_WORDS(2);+};+static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size");++} // namespace Service::VIdiff --git a/src/core/hle/service/vi/vi_u.cpp b/src/core/hle/service/vi/vi_u.cppindex 59e13c86bd..9845e2c57a 100644--- a/src/core/hle/service/vi/vi_u.cpp+++ b/src/core/hle/service/vi/vi_u.cpp@@ -3,14 +3,15 @@#include "common/logging/log.h"#include "core/hle/service/vi/vi.h"+#include "core/hle/service/vi/vi_types.h"#include "core/hle/service/vi/vi_u.h"namespace Service::VI {VI_U::VI_U(Core::System& system_, Nvnflinger::Nvnflinger& nv_flinger_,Nvnflinger::HosBinderDriverServer& hos_binder_driver_server_)- : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_}, hos_binder_driver_server{- hos_binder_driver_server_} {+ : ServiceFramework{system_, "vi:u"}, nv_flinger{nv_flinger_},+ hos_binder_driver_server{hos_binder_driver_server_} {static const FunctionInfo functions[] = {{0, &VI_U::GetDisplayService, "GetDisplayService"},{1, nullptr, "GetDisplayServiceWithProxyNameExchange"},