summaryrefslogtreecommitdiff
path: root/src/yuzu_tester
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu_tester')
-rw-r--r--src/yuzu_tester/CMakeLists.txt32
-rw-r--r--src/yuzu_tester/config.cpp194
-rw-r--r--src/yuzu_tester/config.h24
-rw-r--r--src/yuzu_tester/default_ini.h182
-rw-r--r--src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp146
-rw-r--r--src/yuzu_tester/emu_window/emu_window_sdl2_hide.h37
-rw-r--r--src/yuzu_tester/resource.h16
-rw-r--r--src/yuzu_tester/service/yuzutest.cpp115
-rw-r--r--src/yuzu_tester/service/yuzutest.h25
-rw-r--r--src/yuzu_tester/yuzu.cpp268
-rw-r--r--src/yuzu_tester/yuzu.rc17
11 files changed, 0 insertions, 1056 deletions
diff --git a/src/yuzu_tester/CMakeLists.txt b/src/yuzu_tester/CMakeLists.txt
deleted file mode 100644
index d8a2a1511..000000000
--- a/src/yuzu_tester/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
1set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
2
3add_executable(yuzu-tester
4 config.cpp
5 config.h
6 default_ini.h
7 emu_window/emu_window_sdl2_hide.cpp
8 emu_window/emu_window_sdl2_hide.h
9 resource.h
10 service/yuzutest.cpp
11 service/yuzutest.h
12 yuzu.cpp
13 yuzu.rc
14)
15
16create_target_directory_groups(yuzu-tester)
17
18target_link_libraries(yuzu-tester PRIVATE common core input_common)
19target_link_libraries(yuzu-tester PRIVATE inih glad)
20if (MSVC)
21 target_link_libraries(yuzu-tester PRIVATE getopt)
22endif()
23target_link_libraries(yuzu-tester PRIVATE ${PLATFORM_LIBRARIES} SDL2 Threads::Threads)
24
25if(UNIX AND NOT APPLE)
26 install(TARGETS yuzu-tester RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
27endif()
28
29if (MSVC)
30 include(CopyYuzuSDLDeps)
31 copy_yuzu_SDL_deps(yuzu-tester)
32endif()
diff --git a/src/yuzu_tester/config.cpp b/src/yuzu_tester/config.cpp
deleted file mode 100644
index 0aa143e1f..000000000
--- a/src/yuzu_tester/config.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <memory>
6#include <sstream>
7#include <SDL.h>
8#include <inih/cpp/INIReader.h>
9#include "common/file_util.h"
10#include "common/logging/log.h"
11#include "common/param_package.h"
12#include "core/hle/service/acc/profile_manager.h"
13#include "core/settings.h"
14#include "input_common/main.h"
15#include "yuzu_tester/config.h"
16#include "yuzu_tester/default_ini.h"
17
18namespace FS = Common::FS;
19
20Config::Config() {
21 // TODO: Don't hardcode the path; let the frontend decide where to put the config files.
22 sdl2_config_loc = FS::GetUserPath(FS::UserPath::ConfigDir) + "sdl2-tester-config.ini";
23 sdl2_config = std::make_unique<INIReader>(sdl2_config_loc);
24
25 Reload();
26}
27
28Config::~Config() = default;
29
30bool Config::LoadINI(const std::string& default_contents, bool retry) {
31 const char* location = this->sdl2_config_loc.c_str();
32 if (sdl2_config->ParseError() < 0) {
33 if (retry) {
34 LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location);
35 FS::CreateFullPath(location);
36 FS::WriteStringToFile(true, default_contents, location);
37 sdl2_config = std::make_unique<INIReader>(location); // Reopen file
38
39 return LoadINI(default_contents, false);
40 }
41 LOG_ERROR(Config, "Failed.");
42 return false;
43 }
44 LOG_INFO(Config, "Successfully loaded {}", location);
45 return true;
46}
47
48void Config::ReadValues() {
49 // Controls
50 for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) {
51 for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
52 Settings::values.players.GetValue()[p].buttons[i] = "";
53 }
54
55 for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
56 Settings::values.players.GetValue()[p].analogs[i] = "";
57 }
58 }
59
60 Settings::values.mouse_enabled = false;
61 for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
62 Settings::values.mouse_buttons[i] = "";
63 }
64
65 Settings::values.motion_device = "";
66
67 Settings::values.keyboard_enabled = false;
68
69 Settings::values.debug_pad_enabled = false;
70 for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
71 Settings::values.debug_pad_buttons[i] = "";
72 }
73
74 for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
75 Settings::values.debug_pad_analogs[i] = "";
76 }
77
78 Settings::values.vibration_enabled.SetValue(true);
79 Settings::values.enable_accurate_vibrations.SetValue(false);
80 Settings::values.motion_enabled.SetValue(true);
81 Settings::values.touchscreen.enabled = "";
82 Settings::values.touchscreen.device = "";
83 Settings::values.touchscreen.finger = 0;
84 Settings::values.touchscreen.rotation_angle = 0;
85 Settings::values.touchscreen.diameter_x = 15;
86 Settings::values.touchscreen.diameter_y = 15;
87
88 Settings::values.use_docked_mode.SetValue(
89 sdl2_config->GetBoolean("Controls", "use_docked_mode", true));
90
91 // Data Storage
92 Settings::values.use_virtual_sd =
93 sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
94 FS::GetUserPath(Common::FS::UserPath::NANDDir,
95 sdl2_config->Get("Data Storage", "nand_directory",
96 Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)));
97 FS::GetUserPath(Common::FS::UserPath::SDMCDir,
98 sdl2_config->Get("Data Storage", "sdmc_directory",
99 Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)));
100
101 // System
102 Settings::values.current_user = std::clamp<int>(
103 sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1);
104
105 const auto rng_seed_enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false);
106 if (rng_seed_enabled) {
107 Settings::values.rng_seed.SetValue(sdl2_config->GetInteger("System", "rng_seed", 0));
108 } else {
109 Settings::values.rng_seed.SetValue(std::nullopt);
110 }
111
112 const auto custom_rtc_enabled = sdl2_config->GetBoolean("System", "custom_rtc_enabled", false);
113 if (custom_rtc_enabled) {
114 Settings::values.custom_rtc.SetValue(
115 std::chrono::seconds(sdl2_config->GetInteger("System", "custom_rtc", 0)));
116 } else {
117 Settings::values.custom_rtc.SetValue(std::nullopt);
118 }
119
120 // Core
121 Settings::values.use_multi_core.SetValue(
122 sdl2_config->GetBoolean("Core", "use_multi_core", false));
123
124 // Renderer
125 Settings::values.aspect_ratio.SetValue(
126 static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)));
127 Settings::values.max_anisotropy.SetValue(
128 static_cast<int>(sdl2_config->GetInteger("Renderer", "max_anisotropy", 0)));
129 Settings::values.use_frame_limit.SetValue(false);
130 Settings::values.frame_limit.SetValue(100);
131 Settings::values.use_disk_shader_cache.SetValue(
132 sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", false));
133 const int gpu_accuracy_level = sdl2_config->GetInteger("Renderer", "gpu_accuracy", 0);
134 Settings::values.gpu_accuracy.SetValue(static_cast<Settings::GPUAccuracy>(gpu_accuracy_level));
135 Settings::values.use_asynchronous_gpu_emulation.SetValue(
136 sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false));
137 Settings::values.use_fast_gpu_time.SetValue(
138 sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true));
139
140 Settings::values.bg_red.SetValue(
141 static_cast<float>(sdl2_config->GetReal("Renderer", "bg_red", 0.0)));
142 Settings::values.bg_green.SetValue(
143 static_cast<float>(sdl2_config->GetReal("Renderer", "bg_green", 0.0)));
144 Settings::values.bg_blue.SetValue(
145 static_cast<float>(sdl2_config->GetReal("Renderer", "bg_blue", 0.0)));
146
147 // Audio
148 Settings::values.sink_id = "null";
149 Settings::values.enable_audio_stretching.SetValue(false);
150 Settings::values.audio_device_id = "auto";
151 Settings::values.volume.SetValue(0);
152
153 Settings::values.language_index.SetValue(
154 sdl2_config->GetInteger("System", "language_index", 1));
155
156 // Miscellaneous
157 Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace");
158 Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false);
159
160 // Debugging
161 Settings::values.program_args = "";
162 Settings::values.dump_exefs = sdl2_config->GetBoolean("Debugging", "dump_exefs", false);
163 Settings::values.dump_nso = sdl2_config->GetBoolean("Debugging", "dump_nso", false);
164
165 const auto title_list = sdl2_config->Get("AddOns", "title_ids", "");
166 std::stringstream ss(title_list);
167 std::string line;
168 while (std::getline(ss, line, '|')) {
169 const auto title_id = std::stoul(line, nullptr, 16);
170 const auto disabled_list = sdl2_config->Get("AddOns", "disabled_" + line, "");
171
172 std::stringstream inner_ss(disabled_list);
173 std::string inner_line;
174 std::vector<std::string> out;
175 while (std::getline(inner_ss, inner_line, '|')) {
176 out.push_back(inner_line);
177 }
178
179 Settings::values.disabled_addons.insert_or_assign(title_id, out);
180 }
181
182 // Web Service
183 Settings::values.enable_telemetry =
184 sdl2_config->GetBoolean("WebService", "enable_telemetry", true);
185 Settings::values.web_api_url =
186 sdl2_config->Get("WebService", "web_api_url", "https://api.yuzu-emu.org");
187 Settings::values.yuzu_username = sdl2_config->Get("WebService", "yuzu_username", "");
188 Settings::values.yuzu_token = sdl2_config->Get("WebService", "yuzu_token", "");
189}
190
191void Config::Reload() {
192 LoadINI(DefaultINI::sdl2_config_file);
193 ReadValues();
194}
diff --git a/src/yuzu_tester/config.h b/src/yuzu_tester/config.h
deleted file mode 100644
index 3b68e5bc9..000000000
--- a/src/yuzu_tester/config.h
+++ /dev/null
@@ -1,24 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <string>
9
10class INIReader;
11
12class Config {
13 std::unique_ptr<INIReader> sdl2_config;
14 std::string sdl2_config_loc;
15
16 bool LoadINI(const std::string& default_contents = "", bool retry = true);
17 void ReadValues();
18
19public:
20 Config();
21 ~Config();
22
23 void Reload();
24};
diff --git a/src/yuzu_tester/default_ini.h b/src/yuzu_tester/default_ini.h
deleted file mode 100644
index 779c3791b..000000000
--- a/src/yuzu_tester/default_ini.h
+++ /dev/null
@@ -1,182 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7namespace DefaultINI {
8
9const char* sdl2_config_file = R"(
10[Core]
11# Whether to use multi-core for CPU emulation
12# 0 (default): Disabled, 1: Enabled
13use_multi_core=
14
15[Cpu]
16# Enable inline page tables optimization (faster guest memory access)
17# 0: Disabled, 1 (default): Enabled
18cpuopt_page_tables =
19
20# Enable block linking CPU optimization (reduce block dispatcher use during predictable jumps)
21# 0: Disabled, 1 (default): Enabled
22cpuopt_block_linking =
23
24# Enable return stack buffer CPU optimization (reduce block dispatcher use during predictable returns)
25# 0: Disabled, 1 (default): Enabled
26cpuopt_return_stack_buffer =
27
28# Enable fast dispatcher CPU optimization (use a two-tiered dispatcher architecture)
29# 0: Disabled, 1 (default): Enabled
30cpuopt_fast_dispatcher =
31
32# Enable context elimination CPU Optimization (reduce host memory use for guest context)
33# 0: Disabled, 1 (default): Enabled
34cpuopt_context_elimination =
35
36# Enable constant propagation CPU optimization (basic IR optimization)
37# 0: Disabled, 1 (default): Enabled
38cpuopt_const_prop =
39
40# Enable miscellaneous CPU optimizations (basic IR optimization)
41# 0: Disabled, 1 (default): Enabled
42cpuopt_misc_ir =
43
44# Enable reduction of memory misalignment checks (reduce memory fallbacks for misaligned access)
45# 0: Disabled, 1 (default): Enabled
46cpuopt_reduce_misalign_checks =
47
48[Renderer]
49# Whether to use software or hardware rendering.
50# 0: Software, 1 (default): Hardware
51use_hw_renderer =
52
53# Whether to use the Just-In-Time (JIT) compiler for shader emulation
54# 0: Interpreter (slow), 1 (default): JIT (fast)
55use_shader_jit =
56
57# Aspect ratio
58# 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window
59aspect_ratio =
60
61# Anisotropic filtering
62# 0: Default, 1: 2x, 2: 4x, 3: 8x, 4: 16x
63max_anisotropy =
64
65# Whether to enable V-Sync (caps the framerate at 60FPS) or not.
66# 0 (default): Off, 1: On
67use_vsync =
68
69# Whether to use disk based shader cache
70# 0 (default): Off, 1 : On
71use_disk_shader_cache =
72
73# Whether to use accurate GPU emulation
74# 0 (default): Off (fast), 1 : On (slow)
75use_accurate_gpu_emulation =
76
77# Whether to use asynchronous GPU emulation
78# 0 : Off (slow), 1 (default): On (fast)
79use_asynchronous_gpu_emulation =
80
81# The clear color for the renderer. What shows up on the sides of the bottom screen.
82# Must be in range of 0.0-1.0. Defaults to 1.0 for all.
83bg_red =
84bg_blue =
85bg_green =
86
87[Layout]
88# Layout for the screen inside the render window.
89# 0 (default): Default Top Bottom Screen, 1: Single Screen Only, 2: Large Screen Small Screen
90layout_option =
91
92# Toggle custom layout (using the settings below) on or off.
93# 0 (default): Off, 1: On
94custom_layout =
95
96# Screen placement when using Custom layout option
97# 0x, 0y is the top left corner of the render window.
98custom_top_left =
99custom_top_top =
100custom_top_right =
101custom_top_bottom =
102custom_bottom_left =
103custom_bottom_top =
104custom_bottom_right =
105custom_bottom_bottom =
106
107# Swaps the prominent screen with the other screen.
108# For example, if Single Screen is chosen, setting this to 1 will display the bottom screen instead of the top screen.
109# 0 (default): Top Screen is prominent, 1: Bottom Screen is prominent
110swap_screen =
111
112[Data Storage]
113# Whether to create a virtual SD card.
114# 1 (default): Yes, 0: No
115use_virtual_sd =
116
117[System]
118# Whether the system is docked
119# 1 (default): Yes, 0: No
120use_docked_mode =
121
122# Allow the use of NFC in games
123# 1 (default): Yes, 0 : No
124enable_nfc =
125
126# Sets the seed for the RNG generator built into the switch
127# rng_seed will be ignored and randomly generated if rng_seed_enabled is false
128rng_seed_enabled =
129rng_seed =
130
131# Sets the current time (in seconds since 12:00 AM Jan 1, 1970) that will be used by the time service
132# This will auto-increment, with the time set being the time the game is started
133# This override will only occur if custom_rtc_enabled is true, otherwise the current time is used
134custom_rtc_enabled =
135custom_rtc =
136
137# Sets the account username, max length is 32 characters
138# yuzu (default)
139username = yuzu
140
141# Sets the systems language index
142# 0: Japanese, 1: English (default), 2: French, 3: German, 4: Italian, 5: Spanish, 6: Chinese,
143# 7: Korean, 8: Dutch, 9: Portuguese, 10: Russian, 11: Taiwanese, 12: British English, 13: Canadian French,
144# 14: Latin American Spanish, 15: Simplified Chinese, 16: Traditional Chinese
145language_index =
146
147# The system region that yuzu will use during emulation
148# -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan
149region_value =
150
151[Miscellaneous]
152# A filter which removes logs below a certain logging level.
153# Examples: *:Debug Kernel.SVC:Trace Service.*:Critical
154log_filter = *:Trace
155
156[Debugging]
157# Arguments to be passed to argv/argc in the emulated program. It is preferable to use the testing service datastring
158program_args=
159# Determines whether or not yuzu will dump the ExeFS of all games it attempts to load while loading them
160dump_exefs=false
161# Determines whether or not yuzu will dump all NSOs it attempts to load while loading them
162dump_nso=false
163
164[WebService]
165# Whether or not to enable telemetry
166# 0: No, 1 (default): Yes
167enable_telemetry =
168# URL for Web API
169web_api_url = https://api.yuzu-emu.org
170# Username and token for yuzu Web Service
171# See https://profile.yuzu-emu.org/ for more info
172yuzu_username =
173yuzu_token =
174
175[AddOns]
176# Used to disable add-ons
177# List of title IDs of games that will have add-ons disabled (separated by '|'):
178title_ids =
179# For each title ID, have a key/value pair called `disabled_<title_id>` equal to the names of the add-ons to disable (sep. by '|')
180# e.x. disabled_0100000000010000 = Update|DLC <- disables Updates and DLC on Super Mario Odyssey
181)";
182}
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp
deleted file mode 100644
index 358e03870..000000000
--- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <algorithm>
6#include <cstdlib>
7#include <string>
8
9#include <fmt/format.h>
10
11#define SDL_MAIN_HANDLED
12#include <SDL.h>
13
14#include <glad/glad.h>
15
16#include "common/logging/log.h"
17#include "common/scm_rev.h"
18#include "core/settings.h"
19#include "input_common/main.h"
20#include "yuzu_tester/emu_window/emu_window_sdl2_hide.h"
21
22bool EmuWindow_SDL2_Hide::SupportsRequiredGLExtensions() {
23 std::vector<std::string> unsupported_ext;
24
25 if (!GLAD_GL_ARB_direct_state_access)
26 unsupported_ext.push_back("ARB_direct_state_access");
27 if (!GLAD_GL_ARB_vertex_type_10f_11f_11f_rev)
28 unsupported_ext.push_back("ARB_vertex_type_10f_11f_11f_rev");
29 if (!GLAD_GL_ARB_texture_mirror_clamp_to_edge)
30 unsupported_ext.push_back("ARB_texture_mirror_clamp_to_edge");
31 if (!GLAD_GL_ARB_multi_bind)
32 unsupported_ext.push_back("ARB_multi_bind");
33
34 // Extensions required to support some texture formats.
35 if (!GLAD_GL_EXT_texture_compression_s3tc)
36 unsupported_ext.push_back("EXT_texture_compression_s3tc");
37 if (!GLAD_GL_ARB_texture_compression_rgtc)
38 unsupported_ext.push_back("ARB_texture_compression_rgtc");
39 if (!GLAD_GL_ARB_depth_buffer_float)
40 unsupported_ext.push_back("ARB_depth_buffer_float");
41
42 for (const std::string& ext : unsupported_ext)
43 LOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext);
44
45 return unsupported_ext.empty();
46}
47
48EmuWindow_SDL2_Hide::EmuWindow_SDL2_Hide() {
49 // Initialize the window
50 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
51 LOG_CRITICAL(Frontend, "Failed to initialize SDL2! Exiting...");
52 exit(1);
53 }
54
55 input_subsystem->Initialize();
56
57 SDL_SetMainReady();
58
59 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
60 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
61 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
62 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
63 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
64 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
65 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
66 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
67
68 std::string window_title = fmt::format("yuzu-tester {} | {}-{}", Common::g_build_fullname,
69 Common::g_scm_branch, Common::g_scm_desc);
70 render_window = SDL_CreateWindow(window_title.c_str(),
71 SDL_WINDOWPOS_UNDEFINED, // x position
72 SDL_WINDOWPOS_UNDEFINED, // y position
73 Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height,
74 SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE |
75 SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN);
76
77 if (render_window == nullptr) {
78 LOG_CRITICAL(Frontend, "Failed to create SDL2 window! {}", SDL_GetError());
79 exit(1);
80 }
81
82 gl_context = SDL_GL_CreateContext(render_window);
83
84 if (gl_context == nullptr) {
85 LOG_CRITICAL(Frontend, "Failed to create SDL2 GL context! {}", SDL_GetError());
86 exit(1);
87 }
88
89 if (!gladLoadGLLoader(static_cast<GLADloadproc>(SDL_GL_GetProcAddress))) {
90 LOG_CRITICAL(Frontend, "Failed to initialize GL functions! {}", SDL_GetError());
91 exit(1);
92 }
93
94 if (!SupportsRequiredGLExtensions()) {
95 LOG_CRITICAL(Frontend, "GPU does not support all required OpenGL extensions! Exiting...");
96 exit(1);
97 }
98
99 SDL_PumpEvents();
100 SDL_GL_SetSwapInterval(false);
101 LOG_INFO(Frontend, "yuzu-tester Version: {} | {}-{}", Common::g_build_fullname,
102 Common::g_scm_branch, Common::g_scm_desc);
103 Settings::LogSettings();
104}
105
106EmuWindow_SDL2_Hide::~EmuWindow_SDL2_Hide() {
107 input_subsystem->Shutdown();
108 SDL_GL_DeleteContext(gl_context);
109 SDL_Quit();
110}
111
112bool EmuWindow_SDL2_Hide::IsShown() const {
113 return false;
114}
115
116class SDLGLContext : public Core::Frontend::GraphicsContext {
117public:
118 explicit SDLGLContext() {
119 // create a hidden window to make the shared context against
120 window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 0, 0,
121 SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL);
122 context = SDL_GL_CreateContext(window);
123 }
124
125 ~SDLGLContext() {
126 DoneCurrent();
127 SDL_GL_DeleteContext(context);
128 SDL_DestroyWindow(window);
129 }
130
131 void MakeCurrent() override {
132 SDL_GL_MakeCurrent(window, context);
133 }
134
135 void DoneCurrent() override {
136 SDL_GL_MakeCurrent(window, nullptr);
137 }
138
139private:
140 SDL_Window* window;
141 SDL_GLContext context;
142};
143
144std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2_Hide::CreateSharedContext() const {
145 return std::make_unique<SDLGLContext>();
146}
diff --git a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h b/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h
deleted file mode 100644
index adccdf35e..000000000
--- a/src/yuzu_tester/emu_window/emu_window_sdl2_hide.h
+++ /dev/null
@@ -1,37 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/frontend/emu_window.h"
8
9struct SDL_Window;
10
11namespace InputCommon {
12class InputSubsystem;
13}
14
15class EmuWindow_SDL2_Hide : public Core::Frontend::EmuWindow {
16public:
17 explicit EmuWindow_SDL2_Hide();
18 ~EmuWindow_SDL2_Hide();
19
20 /// Whether the screen is being shown or not.
21 bool IsShown() const override;
22
23 std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override;
24
25private:
26 /// Whether the GPU and driver supports the OpenGL extension required
27 bool SupportsRequiredGLExtensions();
28
29 std::unique_ptr<InputCommon::InputSubsystem> input_subsystem;
30
31 /// Internal SDL2 render window
32 SDL_Window* render_window;
33
34 using SDL_GLContext = void*;
35 /// The OpenGL context associated with the window
36 SDL_GLContext gl_context;
37};
diff --git a/src/yuzu_tester/resource.h b/src/yuzu_tester/resource.h
deleted file mode 100644
index df8e459e4..000000000
--- a/src/yuzu_tester/resource.h
+++ /dev/null
@@ -1,16 +0,0 @@
1//{{NO_DEPENDENCIES}}
2// Microsoft Visual C++ generated include file.
3// Used by pcafe.rc
4//
5#define IDI_ICON3 103
6
7// Next default values for new objects
8//
9#ifdef APSTUDIO_INVOKED
10#ifndef APSTUDIO_READONLY_SYMBOLS
11#define _APS_NEXT_RESOURCE_VALUE 105
12#define _APS_NEXT_COMMAND_VALUE 40001
13#define _APS_NEXT_CONTROL_VALUE 1001
14#define _APS_NEXT_SYMED_VALUE 101
15#endif
16#endif
diff --git a/src/yuzu_tester/service/yuzutest.cpp b/src/yuzu_tester/service/yuzutest.cpp
deleted file mode 100644
index e257fae25..000000000
--- a/src/yuzu_tester/service/yuzutest.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <memory>
6#include "common/string_util.h"
7#include "core/core.h"
8#include "core/hle/ipc_helpers.h"
9#include "core/hle/service/service.h"
10#include "core/hle/service/sm/sm.h"
11#include "yuzu_tester/service/yuzutest.h"
12
13namespace Service::Yuzu {
14
15constexpr u64 SERVICE_VERSION = 0x00000002;
16
17class YuzuTest final : public ServiceFramework<YuzuTest> {
18public:
19 explicit YuzuTest(Core::System& system_, std::string data_,
20 std::function<void(std::vector<TestResult>)> finish_callback_)
21 : ServiceFramework{system_, "yuzutest"}, data{std::move(data_)}, finish_callback{std::move(
22 finish_callback_)} {
23 static const FunctionInfo functions[] = {
24 {0, &YuzuTest::Initialize, "Initialize"},
25 {1, &YuzuTest::GetServiceVersion, "GetServiceVersion"},
26 {2, &YuzuTest::GetData, "GetData"},
27 {10, &YuzuTest::StartIndividual, "StartIndividual"},
28 {20, &YuzuTest::FinishIndividual, "FinishIndividual"},
29 {100, &YuzuTest::ExitProgram, "ExitProgram"},
30 };
31
32 RegisterHandlers(functions);
33 }
34
35private:
36 void Initialize(Kernel::HLERequestContext& ctx) {
37 LOG_DEBUG(Frontend, "called");
38 IPC::ResponseBuilder rb{ctx, 2};
39 rb.Push(RESULT_SUCCESS);
40 }
41
42 void GetServiceVersion(Kernel::HLERequestContext& ctx) {
43 LOG_DEBUG(Frontend, "called");
44 IPC::ResponseBuilder rb{ctx, 4};
45 rb.Push(RESULT_SUCCESS);
46 rb.Push(SERVICE_VERSION);
47 }
48
49 void GetData(Kernel::HLERequestContext& ctx) {
50 LOG_DEBUG(Frontend, "called");
51 const auto size = ctx.GetWriteBufferSize();
52 const auto write_size = std::min(size, data.size());
53 ctx.WriteBuffer(data.data(), write_size);
54
55 IPC::ResponseBuilder rb{ctx, 3};
56 rb.Push(RESULT_SUCCESS);
57 rb.Push<u32>(static_cast<u32>(write_size));
58 }
59
60 void StartIndividual(Kernel::HLERequestContext& ctx) {
61 const auto name_raw = ctx.ReadBuffer();
62
63 const auto name = Common::StringFromFixedZeroTerminatedBuffer(
64 reinterpret_cast<const char*>(name_raw.data()), name_raw.size());
65
66 LOG_DEBUG(Frontend, "called, name={}", name);
67
68 IPC::ResponseBuilder rb{ctx, 2};
69 rb.Push(RESULT_SUCCESS);
70 }
71
72 void FinishIndividual(Kernel::HLERequestContext& ctx) {
73 IPC::RequestParser rp{ctx};
74
75 const auto code = rp.PopRaw<u32>();
76
77 const auto result_data_raw = ctx.ReadBuffer();
78 const auto test_name_raw = ctx.ReadBuffer(1);
79
80 const auto data = Common::StringFromFixedZeroTerminatedBuffer(
81 reinterpret_cast<const char*>(result_data_raw.data()), result_data_raw.size());
82 const auto test_name = Common::StringFromFixedZeroTerminatedBuffer(
83 reinterpret_cast<const char*>(test_name_raw.data()), test_name_raw.size());
84
85 LOG_INFO(Frontend, "called, result_code={:08X}, data={}, name={}", code, data, test_name);
86
87 results.push_back({code, data, test_name});
88
89 IPC::ResponseBuilder rb{ctx, 2};
90 rb.Push(RESULT_SUCCESS);
91 }
92
93 void ExitProgram(Kernel::HLERequestContext& ctx) {
94 LOG_DEBUG(Frontend, "called");
95
96 IPC::ResponseBuilder rb{ctx, 2};
97 rb.Push(RESULT_SUCCESS);
98
99 finish_callback(std::move(results));
100 }
101
102 std::string data;
103
104 std::vector<TestResult> results;
105 std::function<void(std::vector<TestResult>)> finish_callback;
106};
107
108void InstallInterfaces(Core::System& system, std::string data,
109 std::function<void(std::vector<TestResult>)> finish_callback) {
110 auto& sm = system.ServiceManager();
111 std::make_shared<YuzuTest>(system, std::move(data), std::move(finish_callback))
112 ->InstallAsService(sm);
113}
114
115} // namespace Service::Yuzu
diff --git a/src/yuzu_tester/service/yuzutest.h b/src/yuzu_tester/service/yuzutest.h
deleted file mode 100644
index 7794814fa..000000000
--- a/src/yuzu_tester/service/yuzutest.h
+++ /dev/null
@@ -1,25 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <functional>
8#include <string>
9
10namespace Core {
11class System;
12}
13
14namespace Service::Yuzu {
15
16struct TestResult {
17 u32 code;
18 std::string data;
19 std::string name;
20};
21
22void InstallInterfaces(Core::System& system, std::string data,
23 std::function<void(std::vector<TestResult>)> finish_callback);
24
25} // namespace Service::Yuzu
diff --git a/src/yuzu_tester/yuzu.cpp b/src/yuzu_tester/yuzu.cpp
deleted file mode 100644
index 09cf2ad77..000000000
--- a/src/yuzu_tester/yuzu.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <chrono>
6#include <iostream>
7#include <memory>
8#include <string>
9#include <thread>
10
11#include <fmt/ostream.h>
12
13#include "common/common_paths.h"
14#include "common/detached_tasks.h"
15#include "common/file_util.h"
16#include "common/logging/backend.h"
17#include "common/logging/filter.h"
18#include "common/logging/log.h"
19#include "common/microprofile.h"
20#include "common/scm_rev.h"
21#include "common/scope_exit.h"
22#include "common/string_util.h"
23#include "common/telemetry.h"
24#include "core/core.h"
25#include "core/crypto/key_manager.h"
26#include "core/file_sys/registered_cache.h"
27#include "core/file_sys/vfs_real.h"
28#include "core/hle/service/filesystem/filesystem.h"
29#include "core/loader/loader.h"
30#include "core/settings.h"
31#include "core/telemetry_session.h"
32#include "video_core/renderer_base.h"
33#include "yuzu_tester/config.h"
34#include "yuzu_tester/emu_window/emu_window_sdl2_hide.h"
35#include "yuzu_tester/service/yuzutest.h"
36
37#ifdef _WIN32
38// windows.h needs to be included before shellapi.h
39#include <windows.h>
40
41#include <shellapi.h>
42#endif
43
44#undef _UNICODE
45#include <getopt.h>
46#ifndef _MSC_VER
47#include <unistd.h>
48#endif
49
50#ifdef _WIN32
51extern "C" {
52// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable
53// graphics
54__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
55__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
56}
57#endif
58
59static void PrintHelp(const char* argv0) {
60 std::cout << "Usage: " << argv0
61 << " [options] <filename>\n"
62 "-h, --help Display this help and exit\n"
63 "-v, --version Output version information and exit\n"
64 "-d, --datastring Pass following string as data to test service command #2\n"
65 "-l, --log Log to console in addition to file (will log to file only "
66 "by default)\n";
67}
68
69static void PrintVersion() {
70 std::cout << "yuzu [Test Utility] " << Common::g_scm_branch << " " << Common::g_scm_desc
71 << std::endl;
72}
73
74static void InitializeLogging(bool console) {
75 Log::Filter log_filter(Log::Level::Debug);
76 log_filter.ParseFilterString(Settings::values.log_filter);
77 Log::SetGlobalFilter(log_filter);
78
79 if (console)
80 Log::AddBackend(std::make_unique<Log::ColorConsoleBackend>());
81
82 const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir);
83 Common::FS::CreateFullPath(log_dir);
84 Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE));
85#ifdef _WIN32
86 Log::AddBackend(std::make_unique<Log::DebuggerBackend>());
87#endif
88}
89
90/// Application entry point
91int main(int argc, char** argv) {
92 Common::DetachedTasks detached_tasks;
93 Config config;
94
95 int option_index = 0;
96
97#ifdef _WIN32
98 int argc_w;
99 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
100
101 if (argv_w == nullptr) {
102 std::cout << "Failed to get command line arguments" << std::endl;
103 return -1;
104 }
105#endif
106 std::string filepath;
107
108 static struct option long_options[] = {
109 {"help", no_argument, 0, 'h'},
110 {"version", no_argument, 0, 'v'},
111 {"datastring", optional_argument, 0, 'd'},
112 {"log", no_argument, 0, 'l'},
113 {0, 0, 0, 0},
114 };
115
116 bool console_log = false;
117 std::string datastring;
118
119 while (optind < argc) {
120 int arg = getopt_long(argc, argv, "hvdl::", long_options, &option_index);
121 if (arg != -1) {
122 switch (static_cast<char>(arg)) {
123 case 'h':
124 PrintHelp(argv[0]);
125 return 0;
126 case 'v':
127 PrintVersion();
128 return 0;
129 case 'd':
130 datastring = argv[optind];
131 ++optind;
132 break;
133 case 'l':
134 console_log = true;
135 break;
136 }
137 } else {
138#ifdef _WIN32
139 filepath = Common::UTF16ToUTF8(argv_w[optind]);
140#else
141 filepath = argv[optind];
142#endif
143 optind++;
144 }
145 }
146
147 InitializeLogging(console_log);
148
149#ifdef _WIN32
150 LocalFree(argv_w);
151#endif
152
153 MicroProfileOnThreadCreate("EmuThread");
154 SCOPE_EXIT({ MicroProfileShutdown(); });
155
156 if (filepath.empty()) {
157 LOG_CRITICAL(Frontend, "Failed to load application: No application specified");
158 std::cout << "Failed to load application: No application specified" << std::endl;
159 PrintHelp(argv[0]);
160 return -1;
161 }
162
163 Core::System& system{Core::System::GetInstance()};
164
165 Settings::Apply(system);
166
167 const auto emu_window{std::make_unique<EmuWindow_SDL2_Hide>()};
168
169 bool finished = false;
170 int return_value = 0;
171 const auto callback = [&finished,
172 &return_value](std::vector<Service::Yuzu::TestResult> results) {
173 finished = true;
174 return_value = 0;
175
176 // Find the minimum length needed to fully enclose all test names (and the header field) in
177 // the fmt::format column by first finding the maximum size of any test name and comparing
178 // that to 9, the string length of 'Test Name'
179 const auto needed_length_name =
180 std::max<u64>(std::max_element(results.begin(), results.end(),
181 [](const auto& lhs, const auto& rhs) {
182 return lhs.name.size() < rhs.name.size();
183 })
184 ->name.size(),
185 9ull);
186
187 std::size_t passed = 0;
188 std::size_t failed = 0;
189
190 std::cout << fmt::format("Result [Res Code] | {:<{}} | Extra Data", "Test Name",
191 needed_length_name)
192 << std::endl;
193
194 for (const auto& res : results) {
195 const auto main_res = res.code == 0 ? "PASSED" : "FAILED";
196 if (res.code == 0)
197 ++passed;
198 else
199 ++failed;
200 std::cout << fmt::format("{} [{:08X}] | {:<{}} | {}", main_res, res.code, res.name,
201 needed_length_name, res.data)
202 << std::endl;
203 }
204
205 std::cout << std::endl
206 << fmt::format("{:4d} Passed | {:4d} Failed | {:4d} Total | {:2.2f} Passed Ratio",
207 passed, failed, passed + failed,
208 static_cast<float>(passed) / (passed + failed))
209 << std::endl
210 << (failed == 0 ? "PASSED" : "FAILED") << std::endl;
211
212 if (failed > 0)
213 return_value = -1;
214 };
215
216 system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
217 system.SetFilesystem(std::make_shared<FileSys::RealVfsFilesystem>());
218 system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
219
220 SCOPE_EXIT({ system.Shutdown(); });
221
222 const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)};
223
224 switch (load_result) {
225 case Core::System::ResultStatus::ErrorGetLoader:
226 LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
227 return -1;
228 case Core::System::ResultStatus::ErrorLoader:
229 LOG_CRITICAL(Frontend, "Failed to load ROM!");
230 return -1;
231 case Core::System::ResultStatus::ErrorNotInitialized:
232 LOG_CRITICAL(Frontend, "CPUCore not initialized");
233 return -1;
234 case Core::System::ResultStatus::ErrorVideoCore:
235 LOG_CRITICAL(Frontend, "Failed to initialize VideoCore!");
236 return -1;
237 case Core::System::ResultStatus::Success:
238 break; // Expected case
239 default:
240 if (static_cast<u32>(load_result) >
241 static_cast<u32>(Core::System::ResultStatus::ErrorLoader)) {
242 const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader);
243 const u16 error_id = static_cast<u16>(load_result) - loader_id;
244 LOG_CRITICAL(Frontend,
245 "While attempting to load the ROM requested, an error occurred. Please "
246 "refer to the yuzu wiki for more information or the yuzu discord for "
247 "additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}",
248 loader_id, error_id, static_cast<Loader::ResultStatus>(error_id));
249 }
250 break;
251 }
252
253 Service::Yuzu::InstallInterfaces(system, datastring, callback);
254
255 system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend",
256 "SDLHideTester");
257
258 system.GPU().Start();
259
260 void(system.Run());
261 while (!finished) {
262 std::this_thread::sleep_for(std::chrono::milliseconds(1));
263 }
264 void(system.Pause());
265
266 detached_tasks.WaitForAllTasks();
267 return return_value;
268}
diff --git a/src/yuzu_tester/yuzu.rc b/src/yuzu_tester/yuzu.rc
deleted file mode 100644
index 0cde75e2f..000000000
--- a/src/yuzu_tester/yuzu.rc
+++ /dev/null
@@ -1,17 +0,0 @@
1#include "winresrc.h"
2/////////////////////////////////////////////////////////////////////////////
3//
4// Icon
5//
6
7// Icon with lowest ID value placed first to ensure application icon
8// remains consistent on all systems.
9YUZU_ICON ICON "../../dist/yuzu.ico"
10
11
12/////////////////////////////////////////////////////////////////////////////
13//
14// RT_MANIFEST
15//
16
170 RT_MANIFEST "../../dist/yuzu.manifest"