summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar lat9nq2020-07-09 22:42:09 -0400
committerGravatar GitHub2020-07-09 22:42:09 -0400
commit63d23835ef4445b3a010cc0e8b1e73ebe012ac08 (patch)
treeb243c1167280dbf2e3f5af4597b6638fb707f091 /src/video_core
parentMerge pull request #4281 from RealJohnGalt/linkfix2 (diff)
downloadyuzu-63d23835ef4445b3a010cc0e8b1e73ebe012ac08.tar.gz
yuzu-63d23835ef4445b3a010cc0e8b1e73ebe012ac08.tar.xz
yuzu-63d23835ef4445b3a010cc0e8b1e73ebe012ac08.zip
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer In order to add full per-game settings, we need to be able to tell yuzu to switch to using either the global or game configuration. Using a pointer makes it easier to switch. * configuration: add new UI without changing existing funcitonality The new UI also adds General, System, Graphics, Advanced Graphics, and Audio tabs, but as yet they do nothing. This commit keeps yuzu to the same functionality as originally branched. * configuration: Rename files These weren't included in the last commit. Now they are. * configuration: setup global configuration checkbox Global config checkbox now enables/disables the appropriate tabs in the game properties dialog. The use global configuration setting is now saved to the config, defaulting to true. This also addresses some changes requested in the PR. * configuration: swap to per-game config memory for properties dialog Does not set memory going in-game. Swaps to game values when opening the properties dialog, then swaps back when closing it. Uses a `memcpy` to swap. Also implements saving config files, limited to certain groups of configurations so as to not risk setting unsafe configurations. * configuration: change config interfaces to use config-specific pointers When a game is booted, we need to be able to open the configuration dialogs without changing the settings pointer in the game's emualtion. A new pointer specific to just the configuration dialogs can be used to separate changes to just those config dialogs without affecting the emulation. * configuration: boot a game using per-game settings Swaps values where needed to boot a game. * configuration: user correct config during emulation Creates a new pointer specifically for modifying the configuration while emulation is in progress. Both the regular configuration dialog and the game properties dialog now use the pointer Settings::config_values to focus edits to the correct struct. * settings: split Settings::values into two different structs By splitting the settings into two mutually exclusive structs, it becomes easier, as a developer, to determine how to use the Settings structs after per-game configurations is merged. Other benefits include only duplicating the required settings in memory. * settings: move use_docked_mode to Controls group `use_docked_mode` is set in the input settings and cannot be accessed from the system settings. Grouping it with system settings causes it to be saved with per-game settings, which may make transferring configs more difficult later on, especially since docked mode cannot be set from within the game properties dialog. * configuration: Fix the other yuzu executables and a regression In main.cpp, we have to get the title ID before the ROM is loaded, else the renderer will reflect only the global settings and now the user's game specific settings. * settings: use a template to duplicate memory for each setting Replaces the type of each variable in the Settings::Values struct with a new class that allows basic data reading and writing. The new struct Settings::Setting duplicates the data in memory and can manage global overrides per each setting. * configuration: correct add-ons config and swap settings when apropriate Any add-ons interaction happens directly through the global values struct. Swapping bewteen structs now also includes copying the necessary global configs that cannot be changed nor saved in per-game settings. General and System config menus now update based on whether it is viewing the global or per-game settings. * settings: restore old values struct No longer needed with the Settings::Setting class template. * configuration: implement hierarchical game properties dialog This sets the apropriate global or local data in each setting. * clang format * clang format take 2 can the docker container save this? * address comments and style issues * config: read and write settings with global awareness Adds new functions to read and write settings while keeping the global state in focus. Files now generated per-game are much smaller since often they only need address the global state. * settings: restore global state when necessary Upon closing a game or the game properties dialog, we need to restore all global settings to the original global state so that we can properly open the configuration dialog or boot a different game. * configuration: guard setting values incorrectly This disables setting values while a game is running if the setting is overwritten by a per game setting. * config: don't write local settings in the global config Simple guards to prevent writing the wrong settings in the wrong files. * configuration: add comments, assume less, and clang format No longer assumes that a disabled UI element means the global state is turned off, instead opting to directly answer that question. Still however assumes a game is running if it is in that state. * configuration: fix a logic error Should not be negated * restore settings' global state regardless of accept/cancel Fixes loading a properties dialog and causing the global config dialog to show local settings. * fix more logic errors Fixed the frame limit would set the global setting from the game properties dialog. Also strengthened the Settings::Setting member variables and simplified the logic in config reading (ReadSettingGlobal). * fix another logic error In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered condition. * configure_audio: set toggle_stretched_audio to tristate * fixed custom rtc and rng seed overwriting the global value * clang format * rebased * clang format take 4 * address my own review Basically revert unintended changes * settings: literal instead of casting "No need to cast, use 1U instead" Thanks, Morph! Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> * Revert "settings: literal instead of casting " This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f. * main: fix status buttons reporting wrong settings after stop emulation * settings: Log UseDockedMode in the Controls group This should have happened when use_docked_mode was moved over to the controls group internally. This just reflects this in the log. * main: load settings if the file has a title id In other words, don't exit if the loader has trouble getting a title id. * use a zero * settings: initalize resolution factor with constructor instead of casting * Revert "settings: initalize resolution factor with constructor instead of casting" This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8. * configure_graphics: guard device selector when Vulkan is global Prevents the user from editing the device selector if Vulkan is the global renderer backend. Also resets the vulkan_device variable when the users switches back-and-forth between global and Vulkan. * address reviewer concerns Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static. Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com> * main: load per-game settings after LoadROM This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug. * Revert "main: load per-game settings after LoadROM" This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804. * main: only restore global settings when necessary Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug. * configuration_shared: address reviewer concerns except operator overrides Dropping operator override usage in next commit. Co-Authored-By: LC <lioncash@users.noreply.github.com> * settings: Drop operator overrides from Setting template Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog. * complete rebase * configuration_shared: translate "Use global configuration" Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared. * configure_per_game: address reviewer concern As far as I understand, it prevents the program from unnecessarily copying strings. Co-Authored-By: LC <lioncash@users.noreply.github.com> Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> Co-authored-by: VolcaEM <volcaem@users.noreply.github.com> Co-authored-by: LC <lioncash@users.noreply.github.com>
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h6
-rw-r--r--src/video_core/gpu.cpp2
-rw-r--r--src/video_core/query_cache.h2
-rw-r--r--src/video_core/renderer_base.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_device.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.cpp2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp8
-rw-r--r--src/video_core/renderer_vulkan/renderer_vulkan.cpp2
-rw-r--r--src/video_core/texture_cache/texture_cache.h2
-rw-r--r--src/video_core/textures/texture.cpp2
-rw-r--r--src/video_core/video_core.cpp8
11 files changed, 23 insertions, 21 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index c6479af9f..dd7ce8c99 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -96,7 +96,8 @@ public:
96 } 96 }
97 if (is_written) { 97 if (is_written) {
98 map->MarkAsModified(true, GetModifiedTicks()); 98 map->MarkAsModified(true, GetModifiedTicks());
99 if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { 99 if (Settings::IsGPULevelHigh() &&
100 Settings::values.use_asynchronous_gpu_emulation.GetValue()) {
100 MarkForAsyncFlush(map); 101 MarkForAsyncFlush(map);
101 } 102 }
102 if (!map->is_written) { 103 if (!map->is_written) {
@@ -369,7 +370,8 @@ private:
369 } 370 }
370 if (modified_inheritance) { 371 if (modified_inheritance) {
371 map->MarkAsModified(true, GetModifiedTicks()); 372 map->MarkAsModified(true, GetModifiedTicks());
372 if (Settings::IsGPULevelHigh() && Settings::values.use_asynchronous_gpu_emulation) { 373 if (Settings::IsGPULevelHigh() &&
374 Settings::values.use_asynchronous_gpu_emulation.GetValue()) {
373 MarkForAsyncFlush(map); 375 MarkForAsyncFlush(map);
374 } 376 }
375 } 377 }
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 482e49711..758bfe148 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -157,7 +157,7 @@ u64 GPU::GetTicks() const {
157 constexpr u64 gpu_ticks_den = 625; 157 constexpr u64 gpu_ticks_den = 625;
158 158
159 u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count(); 159 u64 nanoseconds = system.CoreTiming().GetGlobalTimeNs().count();
160 if (Settings::values.use_fast_gpu_time) { 160 if (Settings::values.use_fast_gpu_time.GetValue()) {
161 nanoseconds /= 256; 161 nanoseconds /= 256;
162 } 162 }
163 const u64 nanoseconds_num = nanoseconds / gpu_ticks_den; 163 const u64 nanoseconds_num = nanoseconds / gpu_ticks_den;
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h
index e12dab899..0d3a88765 100644
--- a/src/video_core/query_cache.h
+++ b/src/video_core/query_cache.h
@@ -132,7 +132,7 @@ public:
132 } 132 }
133 133
134 query->BindCounter(Stream(type).Current(), timestamp); 134 query->BindCounter(Stream(type).Current(), timestamp);
135 if (Settings::values.use_asynchronous_gpu_emulation) { 135 if (Settings::values.use_asynchronous_gpu_emulation.GetValue()) {
136 AsyncFlushQuery(cpu_addr); 136 AsyncFlushQuery(cpu_addr);
137 } 137 }
138 } 138 }
diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp
index 919d1f2d4..dfb06e87e 100644
--- a/src/video_core/renderer_base.cpp
+++ b/src/video_core/renderer_base.cpp
@@ -18,7 +18,7 @@ RendererBase::~RendererBase() = default;
18void RendererBase::RefreshBaseSettings() { 18void RendererBase::RefreshBaseSettings() {
19 UpdateCurrentFramebufferLayout(); 19 UpdateCurrentFramebufferLayout();
20 20
21 renderer_settings.use_framelimiter = Settings::values.use_frame_limit; 21 renderer_settings.use_framelimiter = Settings::values.use_frame_limit.GetValue();
22 renderer_settings.set_background_color = true; 22 renderer_settings.set_background_color = true;
23} 23}
24 24
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp
index 208fc6167..c1f20f0ab 100644
--- a/src/video_core/renderer_opengl/gl_device.cpp
+++ b/src/video_core/renderer_opengl/gl_device.cpp
@@ -229,15 +229,15 @@ Device::Device()
229 // uniform buffers as "push constants" 229 // uniform buffers as "push constants"
230 has_fast_buffer_sub_data = is_nvidia && !disable_fast_buffer_sub_data; 230 has_fast_buffer_sub_data = is_nvidia && !disable_fast_buffer_sub_data;
231 231
232 use_assembly_shaders = Settings::values.use_assembly_shaders && GLAD_GL_NV_gpu_program5 && 232 use_assembly_shaders = Settings::values.use_assembly_shaders.GetValue() &&
233 GLAD_GL_NV_compute_program5 && GLAD_GL_NV_transform_feedback && 233 GLAD_GL_NV_gpu_program5 && GLAD_GL_NV_compute_program5 &&
234 GLAD_GL_NV_transform_feedback2; 234 GLAD_GL_NV_transform_feedback && GLAD_GL_NV_transform_feedback2;
235 235
236 LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi); 236 LOG_INFO(Render_OpenGL, "Renderer_VariableAOFFI: {}", has_variable_aoffi);
237 LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug); 237 LOG_INFO(Render_OpenGL, "Renderer_ComponentIndexingBug: {}", has_component_indexing_bug);
238 LOG_INFO(Render_OpenGL, "Renderer_PreciseBug: {}", has_precise_bug); 238 LOG_INFO(Render_OpenGL, "Renderer_PreciseBug: {}", has_precise_bug);
239 239
240 if (Settings::values.use_assembly_shaders && !use_assembly_shaders) { 240 if (Settings::values.use_assembly_shaders.GetValue() && !use_assembly_shaders) {
241 LOG_ERROR(Render_OpenGL, "Assembly shaders enabled but not supported"); 241 LOG_ERROR(Render_OpenGL, "Assembly shaders enabled but not supported");
242 } 242 }
243} 243}
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
index 653c3f2f9..2dcc2b0eb 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
@@ -213,7 +213,7 @@ ShaderDiskCacheOpenGL::~ShaderDiskCacheOpenGL() = default;
213std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTransferable() { 213std::optional<std::vector<ShaderDiskCacheEntry>> ShaderDiskCacheOpenGL::LoadTransferable() {
214 // Skip games without title id 214 // Skip games without title id
215 const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0; 215 const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0;
216 if (!Settings::values.use_disk_shader_cache || !has_title_id) { 216 if (!Settings::values.use_disk_shader_cache.GetValue() || !has_title_id) {
217 return {}; 217 return {};
218 } 218 }
219 219
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index c40adb6e7..e66cdc083 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -455,8 +455,8 @@ void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color
455void RendererOpenGL::InitOpenGLObjects() { 455void RendererOpenGL::InitOpenGLObjects() {
456 frame_mailbox = std::make_unique<FrameMailbox>(); 456 frame_mailbox = std::make_unique<FrameMailbox>();
457 457
458 glClearColor(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue, 458 glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
459 0.0f); 459 Settings::values.bg_blue.GetValue(), 0.0f);
460 460
461 // Create shader programs 461 // Create shader programs
462 OGLShader vertex_shader; 462 OGLShader vertex_shader;
@@ -561,8 +561,8 @@ void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
561void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { 561void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
562 if (renderer_settings.set_background_color) { 562 if (renderer_settings.set_background_color) {
563 // Update background color before drawing 563 // Update background color before drawing
564 glClearColor(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue, 564 glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(),
565 0.0f); 565 Settings::values.bg_blue.GetValue(), 0.0f);
566 } 566 }
567 567
568 // Set projection matrix 568 // Set projection matrix
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp
index 2d9b18ed9..2258479f5 100644
--- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp
+++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp
@@ -409,7 +409,7 @@ bool RendererVulkan::PickDevices() {
409 return false; 409 return false;
410 } 410 }
411 411
412 const s32 device_index = Settings::values.vulkan_device; 412 const s32 device_index = Settings::values.vulkan_device.GetValue();
413 if (device_index < 0 || device_index >= static_cast<s32>(devices->size())) { 413 if (device_index < 0 || device_index >= static_cast<s32>(devices->size())) {
414 LOG_ERROR(Render_Vulkan, "Invalid device index {}!", device_index); 414 LOG_ERROR(Render_Vulkan, "Invalid device index {}!", device_index);
415 return false; 415 return false;
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 6207d8dfe..cdcddb225 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -249,7 +249,7 @@ public:
249 auto& surface = render_targets[index].target; 249 auto& surface = render_targets[index].target;
250 surface->MarkAsRenderTarget(false, NO_RT); 250 surface->MarkAsRenderTarget(false, NO_RT);
251 const auto& cr_params = surface->GetSurfaceParams(); 251 const auto& cr_params = surface->GetSurfaceParams();
252 if (!cr_params.is_tiled && Settings::values.use_asynchronous_gpu_emulation) { 252 if (!cr_params.is_tiled && Settings::values.use_asynchronous_gpu_emulation.GetValue()) {
253 AsyncFlushSurface(surface); 253 AsyncFlushSurface(surface);
254 } 254 }
255 } 255 }
diff --git a/src/video_core/textures/texture.cpp b/src/video_core/textures/texture.cpp
index d1939d744..4171e3ef2 100644
--- a/src/video_core/textures/texture.cpp
+++ b/src/video_core/textures/texture.cpp
@@ -48,7 +48,7 @@ constexpr std::array<float, 256> SRGB_CONVERSION_LUT = {
48}; 48};
49 49
50unsigned SettingsMinimumAnisotropy() noexcept { 50unsigned SettingsMinimumAnisotropy() noexcept {
51 switch (static_cast<Anisotropy>(Settings::values.max_anisotropy)) { 51 switch (static_cast<Anisotropy>(Settings::values.max_anisotropy.GetValue())) {
52 default: 52 default:
53 case Anisotropy::Default: 53 case Anisotropy::Default:
54 return 1U; 54 return 1U;
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index f60bdc60a..45f360bdd 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -19,7 +19,7 @@ namespace {
19std::unique_ptr<VideoCore::RendererBase> CreateRenderer(Core::Frontend::EmuWindow& emu_window, 19std::unique_ptr<VideoCore::RendererBase> CreateRenderer(Core::Frontend::EmuWindow& emu_window,
20 Core::System& system, 20 Core::System& system,
21 Core::Frontend::GraphicsContext& context) { 21 Core::Frontend::GraphicsContext& context) {
22 switch (Settings::values.renderer_backend) { 22 switch (Settings::values.renderer_backend.GetValue()) {
23 case Settings::RendererBackend::OpenGL: 23 case Settings::RendererBackend::OpenGL:
24 return std::make_unique<OpenGL::RendererOpenGL>(emu_window, system, context); 24 return std::make_unique<OpenGL::RendererOpenGL>(emu_window, system, context);
25#ifdef HAS_VULKAN 25#ifdef HAS_VULKAN
@@ -42,7 +42,7 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor
42 return nullptr; 42 return nullptr;
43 } 43 }
44 44
45 if (Settings::values.use_asynchronous_gpu_emulation) { 45 if (Settings::values.use_asynchronous_gpu_emulation.GetValue()) {
46 return std::make_unique<VideoCommon::GPUAsynch>(system, std::move(renderer), 46 return std::make_unique<VideoCommon::GPUAsynch>(system, std::move(renderer),
47 std::move(context)); 47 std::move(context));
48 } 48 }
@@ -51,8 +51,8 @@ std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Cor
51 51
52u16 GetResolutionScaleFactor(const RendererBase& renderer) { 52u16 GetResolutionScaleFactor(const RendererBase& renderer) {
53 return static_cast<u16>( 53 return static_cast<u16>(
54 Settings::values.resolution_factor != 0 54 Settings::values.resolution_factor.GetValue() != 0
55 ? Settings::values.resolution_factor 55 ? Settings::values.resolution_factor.GetValue()
56 : renderer.GetRenderWindow().GetFramebufferLayout().GetScalingRatio()); 56 : renderer.GetRenderWindow().GetFramebufferLayout().GetScalingRatio());
57} 57}
58 58