From 8ca3154ca358df199c744fd894dc69767b8ea694 Mon Sep 17 00:00:00 2001 From: Niko Date: Sun, 28 Aug 2022 13:47:25 -0400 Subject: [PATCH] change driverVersion to m_featureControl bool --- .../Vulkan/VulkanPipelineStableCache.cpp | 16 ++++++++-------- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 6 +++--- .../HW/Latte/Renderer/Vulkan/VulkanRenderer.h | 7 +++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp index 024f85bd..d48db52e 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineStableCache.cpp @@ -34,29 +34,29 @@ uint32 VulkanPipelineStableCache::BeginLoading(uint64 cacheTitleId) std::error_code ec; fs::create_directories(ActiveSettings::GetPath("shaderCache/transferable"), ec); const auto pathCacheFile = ActiveSettings::GetPath("shaderCache/transferable/{:016x}_vkpipeline.bin", cacheTitleId); + // init cache loader state g_vkCacheState.pipelineLoadIndex = 0; g_vkCacheState.pipelineMaxFileIndex = 0; g_vkCacheState.pipelinesLoaded = 0; g_vkCacheState.pipelinesQueued = 0; + // start async compilation threads m_compilationCount.store(0); m_compilationQueue.clear(); + + // get core count uint32 cpuCoreCount = GetPhysicalCoreCount(); m_numCompilationThreads = std::clamp(cpuCoreCount, 1u, 8u); - if (g_renderer->GetVendor() == GfxVendor::Nvidia) - { - if(VulkanRenderer::GetInstance()->GetDriverVersion() < 515) - { - forceLog_printf("Disable multi-threaded pipeline loading due to an issue with Nvidia drivers"); - m_numCompilationThreads = 1; - } - } + if (VulkanRenderer::GetInstance()->GetDisableMultithreadedCompilation()) + m_numCompilationThreads = 1; + for (uint32 i = 0; i < m_numCompilationThreads; i++) { std::thread compileThread(&VulkanPipelineStableCache::CompilerThread, this); compileThread.detach(); } + // open cache file or create it cemu_assert_debug(s_cache == nullptr); const uint32 cacheFileVersion = 1; diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 98bec9a3..3e1065cc 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -201,15 +201,15 @@ void VulkanRenderer::DetermineVendor() forceLog_printf("Driver version: %s", driverProperties.driverInfo); // needed for multithreaded pipelines on nvidia (requires 515 or higher) - driverVersion = StringHelpers::ToInt(std::string(driverProperties.driverInfo)); + m_featureControl.disableMultithreadedCompilation = (StringHelpers::ToInt(std::string(driverProperties.driverInfo)) < 515); } else { forceLog_printf("Driver version (as stored in device info): %08X", properties.properties.driverVersion); - // disables multithreaded pipeline loading on nvidia (requires 515.0 or higher) - driverVersion = -1; + // disableMultithreadedCompilation defaults to false, not like there's any other driver + // on the planet with broken multithreading except Nvidia, which will always have a driver version string } } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 18480fa3..6b6abf7a 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -547,7 +547,8 @@ private: uint32 nonCoherentAtomSize = 256; }limits; - bool debugMarkersSupported = false; // frame debugger is attached + bool debugMarkersSupported = false; // frame debugger is attached + bool disableMultithreadedCompilation = false; // for old nvidia drivers }m_featureControl{}; static bool CheckDeviceExtensionSupport(const VkPhysicalDevice device, FeatureControl& info); @@ -1012,7 +1013,7 @@ private: public: - int GetDriverVersion() { return driverVersion; } + bool GetDisableMultithreadedCompilation() { return m_featureControl.disableMultithreadedCompilation; } bool useTFViaSSBO() { return m_featureControl.mode.useTFEmulationViaSSBO; } bool IsDebugUtilsEnabled() const { @@ -1021,8 +1022,6 @@ public: private: - int driverVersion; - // debug void debug_genericBarrier();