From 2832edcc3791f05227e4fa534aaab7e69021d14c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 07:41:36 -0700 Subject: [PATCH] Vulkan: Allow configuring geometry shaders on/off. --- Core/Config.cpp | 1 + Core/Config.h | 1 + GPU/Vulkan/GPU_Vulkan.cpp | 5 +++-- UI/GameSettingsScreen.cpp | 9 +++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 45e396c9b7..dee26c3793 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -874,6 +874,7 @@ static ConfigSetting graphicsSettings[] = { #endif ConfigSetting("CameraDevice", &g_Config.sCameraDevice, "", true, false), ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), + ConfigSetting("UseGeometryShader", &g_Config.bUseGeometryShader, true, true, true), ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ConfigSetting("SoftwareRendererJit", &g_Config.bSoftwareRenderingJit, true, true, true), diff --git a/Core/Config.h b/Core/Config.h index 8a7f519621..65eaf74099 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -164,6 +164,7 @@ public: bool bHardwareTransform; // only used in the GLES backend bool bSoftwareSkinning; // may speed up some games bool bVendorBugChecksEnabled; + bool bUseGeometryShader; int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering int iTexFiltering; // 1 = auto , 2 = nearest , 3 = linear , 4 = auto max quality diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 6d91a3b20e..f285af82d0 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -233,9 +233,10 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { } // Fall back to geometry shader culling if we can't do vertex range culling. - if (enabledFeatures.geometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW)) { + if (enabledFeatures.geometryShader) { + const bool useGeometry = g_Config.bUseGeometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW); const bool vertexSupported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; - if (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0) { + if (useGeometry && (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0)) { // Switch to culling via the geometry shader if not fully supported in vertex. features |= GPU_SUPPORTS_GS_CULLING; features &= ~GPU_SUPPORTS_VS_RANGE_CULLING; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0c1c0d009e..876db2773e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -473,6 +473,15 @@ void GameSettingsScreen::CreateViews() { inflightChoice->OnChoice.Handle(this, &GameSettingsScreen::OnInflightFramesChoice); } + if (GetGPUBackend() == GPUBackend::VULKAN) { + const bool usable = !draw->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW); + const bool vertexSupported = draw->GetDeviceCaps().clipDistanceSupported && draw->GetDeviceCaps().cullDistanceSupported; + if (usable && !vertexSupported) { + CheckBox *geometryCulling = graphicsSettings->Add(new CheckBox(&g_Config.bUseGeometryShader, gr->T("Geometry shader culling"))); + geometryCulling->SetDisabledPtr(&g_Config.bSoftwareRendering); + } + } + if (deviceType != DEVICE_TYPE_VR) { CheckBox *hwTransform = graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gr->T("Hardware Transform"))); hwTransform->SetDisabledPtr(&g_Config.bSoftwareRendering);