From 534607879199e700dbd143317e71218140a58b56 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 13 Aug 2016 22:08:46 +1000 Subject: [PATCH] VideoCommon: Add config fields for multithreading and validation layers --- Source/Core/DolphinWX/VideoConfigDiag.cpp | 16 ++++++++++++++++ Source/Core/VideoBackends/D3D/main.cpp | 1 + Source/Core/VideoBackends/D3D12/main.cpp | 1 + Source/Core/VideoBackends/Null/NullBackend.cpp | 1 + Source/Core/VideoBackends/OGL/main.cpp | 1 + Source/Core/VideoBackends/Software/SWmain.cpp | 1 + Source/Core/VideoCommon/VideoConfig.cpp | 9 +++++++++ Source/Core/VideoCommon/VideoConfig.h | 7 +++++++ 8 files changed, 37 insertions(+) diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index a6e04c583e..147ff94376 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -272,6 +272,12 @@ static wxString stereo_convergence_desc = static wxString stereo_swap_desc = wxTRANSLATE("Swaps the left and right eye. Mostly useful if you want to view side-by-side " "cross-eyed.\n\nIf unsure, leave this unchecked."); +static wxString validation_layer_desc = + wxTRANSLATE("Enables validation of API calls made by the video backend, which may assist in " + "debugging graphical issues.\n\nIf unsure, leave this unchecked."); +static wxString backend_multithreading_desc = + wxTRANSLATE("Enables multi-threading in the video backend, which may result in performance " + "gains in some scenarios.\n\nIf unsure, leave this unchecked."); #if !defined(__APPLE__) // Search for available resolutions - TODO: Move to Common? @@ -471,6 +477,13 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title) CreateCheckBox(page_general, _("Render to Main Window"), wxGetTranslation(render_to_main_win_desc), SConfig::GetInstance().bRenderToMain)); + + if (vconfig.backend_info.bSupportsMultithreading) + { + szr_other->Add(CreateCheckBox(page_general, _("Enable Multi-threading"), + wxGetTranslation(backend_multithreading_desc), + vconfig.bBackendMultithreading)); + } } wxStaticBoxSizer* const group_basic = @@ -760,6 +773,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title) wxGetTranslation(show_stats_desc), vconfig.bOverlayStats)); szr_debug->Add(CreateCheckBox(page_advanced, _("Texture Format Overlay"), wxGetTranslation(texfmt_desc), vconfig.bTexFmtOverlayEnable)); + szr_debug->Add(CreateCheckBox(page_advanced, _("Enable API Validation Layers"), + wxGetTranslation(validation_layer_desc), + vconfig.bEnableValidationLayer)); wxStaticBoxSizer* const group_debug = new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Debugging")); diff --git a/Source/Core/VideoBackends/D3D/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp index 92020481d4..887e585266 100644 --- a/Source/Core/VideoBackends/D3D/main.cpp +++ b/Source/Core/VideoBackends/D3D/main.cpp @@ -73,6 +73,7 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsClipControl = true; g_Config.backend_info.bSupportsDepthClamp = true; g_Config.backend_info.bSupportsReversedDepthRange = false; + g_Config.backend_info.bSupportsMultithreading = false; IDXGIFactory* factory; IDXGIAdapter* ad; diff --git a/Source/Core/VideoBackends/D3D12/main.cpp b/Source/Core/VideoBackends/D3D12/main.cpp index 0036a4a2f2..4184d5ab31 100644 --- a/Source/Core/VideoBackends/D3D12/main.cpp +++ b/Source/Core/VideoBackends/D3D12/main.cpp @@ -76,6 +76,7 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsClipControl = true; g_Config.backend_info.bSupportsDepthClamp = true; g_Config.backend_info.bSupportsReversedDepthRange = false; + g_Config.backend_info.bSupportsMultithreading = false; IDXGIFactory* factory; IDXGIAdapter* ad; diff --git a/Source/Core/VideoBackends/Null/NullBackend.cpp b/Source/Core/VideoBackends/Null/NullBackend.cpp index 4cab977f18..5321c522ff 100644 --- a/Source/Core/VideoBackends/Null/NullBackend.cpp +++ b/Source/Core/VideoBackends/Null/NullBackend.cpp @@ -34,6 +34,7 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsPostProcessing = false; g_Config.backend_info.bSupportsPaletteConversion = true; g_Config.backend_info.bSupportsClipControl = true; + g_Config.backend_info.bSupportsMultithreading = false; // aamodes: We only support 1 sample, so no MSAA g_Config.backend_info.AAModes = {1}; diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index b351ef48bb..5951959253 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -103,6 +103,7 @@ void VideoBackend::InitBackendInfo() g_Config.backend_info.bSupportsPostProcessing = true; g_Config.backend_info.bSupportsSSAA = true; g_Config.backend_info.bSupportsReversedDepthRange = true; + g_Config.backend_info.bSupportsMultithreading = false; // Overwritten in Render.cpp later g_Config.backend_info.bSupportsDualSourceBlend = true; diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index ab1910fd1e..47bfa694bf 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -130,6 +130,7 @@ void VideoSoftware::InitBackendInfo() g_Config.backend_info.bSupportsEarlyZ = true; g_Config.backend_info.bSupportsOversizedViewports = true; g_Config.backend_info.bSupportsPrimitiveRestart = false; + g_Config.backend_info.bSupportsMultithreading = false; // aamodes g_Config.backend_info.AAModes = {1}; diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 1e4a5b4973..e232a94af2 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -41,6 +41,10 @@ VideoConfig::VideoConfig() // disable all features by default backend_info.api_type = APIType::Nothing; backend_info.bSupportsExclusiveFullscreen = false; + backend_info.bSupportsMultithreading = false; + + bEnableValidationLayer = false; + bBackendMultithreading = true; } void VideoConfig::Load(const std::string& ini_file) @@ -82,6 +86,8 @@ void VideoConfig::Load(const std::string& ini_file) settings->Get("WireFrame", &bWireFrame, 0); settings->Get("DisableFog", &bDisableFog, 0); settings->Get("BorderlessFullscreen", &bBorderlessFullscreen, false); + settings->Get("EnableValidationLayer", &bEnableValidationLayer, false); + settings->Get("BackendMultithreading", &bBackendMultithreading, true); settings->Get("SWZComploc", &bZComploc, true); settings->Get("SWZFreeze", &bZFreeze, true); @@ -188,6 +194,7 @@ void VideoConfig::GameIniLoad() } CHECK_SETTING("Video_Settings", "DisableFog", bDisableFog); + CHECK_SETTING("Video_Settings", "BackendMultithreading", bBackendMultithreading); CHECK_SETTING("Video_Enhancements", "ForceFiltering", bForceFiltering); CHECK_SETTING("Video_Enhancements", "MaxAnisotropy", @@ -291,6 +298,8 @@ void VideoConfig::Save(const std::string& ini_file) settings->Set("Wireframe", bWireFrame); settings->Set("DisableFog", bDisableFog); settings->Set("BorderlessFullscreen", bBorderlessFullscreen); + settings->Set("EnableValidationLayer", bEnableValidationLayer); + settings->Set("BackendMultithreading", bBackendMultithreading); settings->Set("SWZComploc", bZComploc); settings->Set("SWZFreeze", bZFreeze); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index c948077acc..930331e601 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -143,6 +143,12 @@ struct VideoConfig final bool bDumpTevStages; bool bDumpTevTextureFetches; + // Enable API validation layers, currently only supported with Vulkan. + bool bEnableValidationLayer; + + // Multithreaded submission, currently only supported with Vulkan. + bool bBackendMultithreading; + // Static config per API // TODO: Move this out of VideoConfig struct @@ -173,6 +179,7 @@ struct VideoConfig final bool bSupportsSSAA; bool bSupportsDepthClamp; // Needed by VertexShaderGen, so must stay in VideoCommon bool bSupportsReversedDepthRange; + bool bSupportsMultithreading; } backend_info; // Utility