From 0a42c534c397b6f99013c25c03799c1c673885b4 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sun, 24 Jul 2022 03:51:22 -0500 Subject: [PATCH] VideoCommon: Add configuration to prefer VS for line/point expansion --- Source/Core/Core/Config/GraphicsSettings.cpp | 2 ++ Source/Core/Core/Config/GraphicsSettings.h | 1 + .../Config/Graphics/AdvancedWidget.cpp | 20 ++++++++++++++++++- .../Config/Graphics/AdvancedWidget.h | 1 + Source/Core/VideoCommon/VideoConfig.cpp | 1 + Source/Core/VideoCommon/VideoConfig.h | 5 ++++- 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index 6f0ee5940c..c9091db2e2 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -84,6 +84,8 @@ const Info GFX_SHADER_PRECOMPILER_THREADS{ {System::GFX, "Settings", "ShaderPrecompilerThreads"}, -1}; const Info GFX_SAVE_TEXTURE_CACHE_TO_STATE{ {System::GFX, "Settings", "SaveTextureCacheToState"}, true}; +const Info GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION{ + {System::GFX, "Settings", "PreferVSForLinePointExpansion"}, false}; const Info GFX_SW_DUMP_OBJECTS{{System::GFX, "Settings", "SWDumpObjects"}, false}; const Info GFX_SW_DUMP_TEV_STAGES{{System::GFX, "Settings", "SWDumpTevStages"}, false}; diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index 398a3dd5a0..3497aa6281 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -73,6 +73,7 @@ extern const Info GFX_SHADER_COMPILATION_MODE; extern const Info GFX_SHADER_COMPILER_THREADS; extern const Info GFX_SHADER_PRECOMPILER_THREADS; extern const Info GFX_SAVE_TEXTURE_CACHE_TO_STATE; +extern const Info GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION; extern const Info GFX_SW_DUMP_OBJECTS; extern const Info GFX_SW_DUMP_TEV_STAGES; diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index 47fa7d3eae..dfd809f956 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -128,15 +128,18 @@ void AdvancedWidget::CreateWidgets() m_enable_prog_scan = new ToolTipCheckBox(tr("Enable Progressive Scan")); m_backend_multithreading = new GraphicsBool(tr("Backend Multithreading"), Config::GFX_BACKEND_MULTITHREADING); + m_prefer_vs_for_point_line_expansion = new GraphicsBool( + tr("Prefer VS for Point/Line Expansion"), Config::GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION); misc_layout->addWidget(m_enable_cropping, 0, 0); misc_layout->addWidget(m_enable_prog_scan, 0, 1); misc_layout->addWidget(m_backend_multithreading, 1, 0); + misc_layout->addWidget(m_prefer_vs_for_point_line_expansion, 1, 1); #ifdef _WIN32 m_borderless_fullscreen = new GraphicsBool(tr("Borderless Fullscreen"), Config::GFX_BORDERLESS_FULLSCREEN); - misc_layout->addWidget(m_borderless_fullscreen, 1, 1); + misc_layout->addWidget(m_borderless_fullscreen, 2, 0); #endif // Experimental. @@ -198,11 +201,19 @@ void AdvancedWidget::SaveSettings() void AdvancedWidget::OnBackendChanged() { m_backend_multithreading->setEnabled(g_Config.backend_info.bSupportsMultithreading); + m_prefer_vs_for_point_line_expansion->setEnabled( + Core::GetState() == Core::State::Uninitialized && + g_Config.backend_info.bSupportsGeometryShaders && + g_Config.backend_info.bSupportsVSLinePointExpand); } void AdvancedWidget::OnEmulationStateChanged(bool running) { m_enable_prog_scan->setEnabled(!running); + m_prefer_vs_for_point_line_expansion->setEnabled( + !running && + g_Config.backend_info.bSupportsGeometryShaders && + g_Config.backend_info.bSupportsVSLinePointExpand); } void AdvancedWidget::AddDescriptions() @@ -289,6 +300,11 @@ void AdvancedWidget::AddDescriptions() "this option may result in a performance improvement on systems with more than " "two CPU cores. Currently, this is limited to the Vulkan backend.

" "If unsure, leave this checked."); + static const char TR_PREFER_VS_FOR_POINT_LINE_EXPANSION_DESCRIPTION[] = + QT_TR_NOOP("On backends that support both using the geometry shader and the vertex shader " + "for expanding points and lines, selects the vertex shader for the job. May " + "affect performance." + "

If unsure, leave this unchecked."); static const char TR_DEFER_EFB_ACCESS_INVALIDATION_DESCRIPTION[] = QT_TR_NOOP( "Defers invalidation of the EFB access cache until a GPU synchronization command " "is executed. If disabled, the cache will be invalidated with every draw call. " @@ -337,6 +353,8 @@ void AdvancedWidget::AddDescriptions() m_enable_cropping->SetDescription(tr(TR_CROPPING_DESCRIPTION)); m_enable_prog_scan->SetDescription(tr(TR_PROGRESSIVE_SCAN_DESCRIPTION)); m_backend_multithreading->SetDescription(tr(TR_BACKEND_MULTITHREADING_DESCRIPTION)); + m_prefer_vs_for_point_line_expansion->SetDescription( + tr(TR_PREFER_VS_FOR_POINT_LINE_EXPANSION_DESCRIPTION)); #ifdef _WIN32 m_borderless_fullscreen->SetDescription(tr(TR_BORDERLESS_FULLSCREEN_DESCRIPTION)); #endif diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h index 4530db5fcf..8188fcb010 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h @@ -59,6 +59,7 @@ private: GraphicsBool* m_enable_cropping; ToolTipCheckBox* m_enable_prog_scan; GraphicsBool* m_backend_multithreading; + GraphicsBool* m_prefer_vs_for_point_line_expansion; GraphicsBool* m_borderless_fullscreen; // Experimental diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 91e0550715..91df848c94 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -85,6 +85,7 @@ void VideoConfig::Refresh() iBitrateKbps = Config::Get(Config::GFX_BITRATE_KBPS); bInternalResolutionFrameDumps = Config::Get(Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS); bEnableGPUTextureDecoding = Config::Get(Config::GFX_ENABLE_GPU_TEXTURE_DECODING); + bPreferVSForLinePointExpansion = Config::Get(Config::GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION); bEnablePixelLighting = Config::Get(Config::GFX_ENABLE_PIXEL_LIGHTING); bFastDepthCalc = Config::Get(Config::GFX_FAST_DEPTH_CALC); iMultisamples = Config::Get(Config::GFX_MSAA); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index dfdd0ffe79..471ff5a18f 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -106,6 +106,7 @@ struct VideoConfig final bool bInternalResolutionFrameDumps = false; bool bBorderlessFullscreen = false; bool bEnableGPUTextureDecoding = false; + bool bPreferVSForLinePointExpansion = false; int iBitrateKbps = 0; bool bGraphicMods = false; std::optional graphics_mod_config; @@ -230,7 +231,9 @@ struct VideoConfig final { if (!backend_info.bSupportsVSLinePointExpand) return false; - return !backend_info.bSupportsGeometryShaders; + if (!backend_info.bSupportsGeometryShaders) + return true; + return bPreferVSForLinePointExpansion; } bool MultisamplingEnabled() const { return iMultisamples > 1; } bool ExclusiveFullscreenEnabled() const