From 25b2ba013bd6112bea50e47244d4b03d97a9dba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Dec 2018 00:22:16 +0100 Subject: [PATCH 1/2] VK: Add INI options to disable some vendor checks, and to disable the shader cache. --- Core/Config.cpp | 2 ++ Core/Config.h | 2 ++ GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp | 4 +++- GPU/Vulkan/GPU_Vulkan.cpp | 12 +++++++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index dd8e45681f..11bb6d597d 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -605,6 +605,8 @@ static ConfigSetting graphicsSettings[] = { #ifdef _WIN32 ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false), #endif + ConfigSetting("VendorChecksEnabled", &g_Config.bVendorChecksEnabled, true, false, false), + ConfigSetting("ShaderCacheEnabled", &g_Config.bShaderCacheEnabled, true, false, false), ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), diff --git a/Core/Config.h b/Core/Config.h index 311516d769..c36bd2eb43 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -131,6 +131,8 @@ public: bool bSoftwareRendering; bool bHardwareTransform; // only used in the GLES backend bool bSoftwareSkinning; // may speed up some games + bool bVendorChecksEnabled; + bool bShaderCacheEnabled; int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering int iTexFiltering; // 1 = off , 2 = nearest , 3 = linear , 4 = linear(CG) diff --git a/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp b/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp index 1a880efc8f..2250a70f47 100644 --- a/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp +++ b/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp @@ -86,7 +86,9 @@ bool GenerateVulkanGLSLFragmentShader(const FShaderID &id, char *buffer, uint32_ bool earlyFragmentTests = ((!enableAlphaTest && !enableColorTest) || testForceToZero) && !gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); bool hasStencilOutput = stencilToAlpha != REPLACE_ALPHA_NO || id.Bit(FS_BIT_REPLACE_ALPHA_WITH_STENCIL_TYPE) == 0; - bool isAdreno = vulkanVendorId == VULKAN_VENDOR_QUALCOMM; + // TODO: This is a bug affecting shader cache generality - we CANNOT check anything but the shader ID and (indirectly) the game ID in here really. + // Need to move this check somehow to the shader ID generator. That's tricky though because it's generic... + bool isAdreno = vulkanVendorId == VULKAN_VENDOR_QUALCOMM && g_Config.bVendorChecksEnabled; if (earlyFragmentTests) { WRITE(p, "layout (early_fragment_tests) in;\n"); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 6b81da93d1..2b95a8ea46 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -101,7 +101,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) // Load shader cache. std::string discID = g_paramSFO.GetDiscID(); - if (discID.size()) { + if (discID.size() && g_Config.bShaderCacheEnabled) { File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE)); shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + discID + ".vkshadercache"; shaderCacheLoaded_ = false; @@ -201,6 +201,10 @@ void GPU_Vulkan::CheckGPUFeatures() { break; } + // Might enable this later - in the first round we are mostly looking at depth/stencil/discard. + // if (g_Config.bDisableVendorChecks) + // features |= GPU_SUPPORTS_ACCURATE_DEPTH; + // Mandatory features on Vulkan, which may be checked in "centralized" code features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; features |= GPU_SUPPORTS_FBO; @@ -224,7 +228,7 @@ void GPU_Vulkan::CheckGPUFeatures() { // We thought we had a bug here on nVidia but turns out we accidentally #ifdef-ed out crucial // code on Android. case VULKAN_VENDOR_INTEL: - // Workaround for Intel driver bug. + // Workaround for Intel driver bug. TODO: Re-enable after some driver version break; case VULKAN_VENDOR_AMD: // See issue #10074, and also #10065 (AMD) and #10109 for the choice of the driver version to check for @@ -235,6 +239,8 @@ void GPU_Vulkan::CheckGPUFeatures() { features |= GPU_SUPPORTS_DUALSOURCE_BLEND; break; } + if (!g_Config.bVendorChecksEnabled) + features |= GPU_SUPPORTS_DUALSOURCE_BLEND; } if (vulkan_->GetFeaturesEnabled().logicOp) { features |= GPU_SUPPORTS_LOGIC_OP; @@ -501,7 +507,7 @@ void GPU_Vulkan::DeviceLost() { while (!IsReady()) { sleep_ms(10); } - if (!shaderCachePath_.empty()) { + if (!shaderCachePath_.empty() && g_Config.bShaderCacheEnabled) { SaveCache(shaderCachePath_); } DestroyDeviceObjects(); From d82ec339eedff71571a32694c31917c0ac7ac076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 15 Dec 2018 10:44:05 +0100 Subject: [PATCH 2/2] Remove the DisableShaderCache setting, rename the other --- Core/Config.cpp | 3 +-- Core/Config.h | 3 +-- GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 11bb6d597d..3c1773b020 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -605,8 +605,7 @@ static ConfigSetting graphicsSettings[] = { #ifdef _WIN32 ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false), #endif - ConfigSetting("VendorChecksEnabled", &g_Config.bVendorChecksEnabled, true, false, false), - ConfigSetting("ShaderCacheEnabled", &g_Config.bShaderCacheEnabled, true, false, false), + ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), diff --git a/Core/Config.h b/Core/Config.h index c36bd2eb43..c020cfd689 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -131,8 +131,7 @@ public: bool bSoftwareRendering; bool bHardwareTransform; // only used in the GLES backend bool bSoftwareSkinning; // may speed up some games - bool bVendorChecksEnabled; - bool bShaderCacheEnabled; + bool bVendorBugChecksEnabled; int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering int iTexFiltering; // 1 = off , 2 = nearest , 3 = linear , 4 = linear(CG) diff --git a/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp b/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp index 2250a70f47..92196f2a1e 100644 --- a/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp +++ b/GPU/Vulkan/FragmentShaderGeneratorVulkan.cpp @@ -88,7 +88,7 @@ bool GenerateVulkanGLSLFragmentShader(const FShaderID &id, char *buffer, uint32_ // TODO: This is a bug affecting shader cache generality - we CANNOT check anything but the shader ID and (indirectly) the game ID in here really. // Need to move this check somehow to the shader ID generator. That's tricky though because it's generic... - bool isAdreno = vulkanVendorId == VULKAN_VENDOR_QUALCOMM && g_Config.bVendorChecksEnabled; + bool isAdreno = vulkanVendorId == VULKAN_VENDOR_QUALCOMM && g_Config.bVendorBugChecksEnabled; if (earlyFragmentTests) { WRITE(p, "layout (early_fragment_tests) in;\n"); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 2b95a8ea46..b41eff7888 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -101,7 +101,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) // Load shader cache. std::string discID = g_paramSFO.GetDiscID(); - if (discID.size() && g_Config.bShaderCacheEnabled) { + if (discID.size()) { File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE)); shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + discID + ".vkshadercache"; shaderCacheLoaded_ = false; @@ -202,7 +202,7 @@ void GPU_Vulkan::CheckGPUFeatures() { } // Might enable this later - in the first round we are mostly looking at depth/stencil/discard. - // if (g_Config.bDisableVendorChecks) + // if (g_Config.bDisableVendorBugChecks) // features |= GPU_SUPPORTS_ACCURATE_DEPTH; // Mandatory features on Vulkan, which may be checked in "centralized" code @@ -239,7 +239,7 @@ void GPU_Vulkan::CheckGPUFeatures() { features |= GPU_SUPPORTS_DUALSOURCE_BLEND; break; } - if (!g_Config.bVendorChecksEnabled) + if (!g_Config.bVendorBugChecksEnabled) features |= GPU_SUPPORTS_DUALSOURCE_BLEND; } if (vulkan_->GetFeaturesEnabled().logicOp) { @@ -507,7 +507,7 @@ void GPU_Vulkan::DeviceLost() { while (!IsReady()) { sleep_ms(10); } - if (!shaderCachePath_.empty() && g_Config.bShaderCacheEnabled) { + if (!shaderCachePath_.empty()) { SaveCache(shaderCachePath_); } DestroyDeviceObjects();