diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 6c45e6c177..992f253e34 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -241,6 +241,7 @@ set(pcsx2Headers R5900.h R5900OpcodeTables.h SaveState.h + ShaderCacheVersion.h Sifcmd.h Sif.h SingleRegisterTypes.h diff --git a/pcsx2/Frontend/VulkanHostDisplay.cpp b/pcsx2/Frontend/VulkanHostDisplay.cpp index 75847d224e..2cefb50225 100644 --- a/pcsx2/Frontend/VulkanHostDisplay.cpp +++ b/pcsx2/Frontend/VulkanHostDisplay.cpp @@ -1,6 +1,7 @@ #include "PrecompiledHeader.h" #include "VulkanHostDisplay.h" +#include "ShaderCacheVersion.h" #include "common/Align.h" #include "common/Assertions.h" #include "common/Console.h" @@ -15,8 +16,6 @@ #include "imgui_impl_vulkan.h" #include -static constexpr u32 SHADER_CACHE_VERSION = 4; - class VulkanHostDisplayTexture : public HostDisplayTexture { public: diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 97cb387c28..e197858f68 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -22,6 +22,7 @@ #include "GS/GSUtil.h" #include "Host.h" #include "HostDisplay.h" +#include "ShaderCacheVersion.h" #include "common/StringUtil.h" #include #include @@ -91,14 +92,14 @@ bool GSDevice11::Create() if (!GSConfig.DisableShaderCache) { - if (!m_shader_cache.Open(EmuFolders::Cache, m_dev->GetFeatureLevel(), SHADER_VERSION, GSConfig.UseDebugDevice)) + if (!m_shader_cache.Open(EmuFolders::Cache, m_dev->GetFeatureLevel(), SHADER_CACHE_VERSION, GSConfig.UseDebugDevice)) { Console.Warning("Shader cache failed to open."); } } else { - m_shader_cache.Open({}, m_dev->GetFeatureLevel(), SHADER_VERSION, GSConfig.UseDebugDevice); + m_shader_cache.Open({}, m_dev->GetFeatureLevel(), SHADER_CACHE_VERSION, GSConfig.UseDebugDevice); Console.WriteLn("Not using shader cache."); } diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.h b/pcsx2/GS/Renderers/DX11/GSDevice11.h index 3194eb1cc4..0875f4d238 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.h +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.h @@ -108,9 +108,6 @@ public: }; private: - // Increment this constant whenever shaders change, to invalidate user's shader cache. - static constexpr u32 SHADER_VERSION = 1; - static constexpr u32 MAX_TEXTURES = 4; static constexpr u32 MAX_SAMPLERS = 2; diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index 2893b5dd65..30d2c933a6 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -29,6 +29,7 @@ #include "GS/GSUtil.h" #include "Host.h" #include "HostDisplay.h" +#include "ShaderCacheVersion.h" #include #include @@ -113,14 +114,14 @@ bool GSDevice12::Create() if (!GSConfig.DisableShaderCache) { - if (!m_shader_cache.Open(EmuFolders::Cache, g_d3d12_context->GetFeatureLevel(), SHADER_VERSION, GSConfig.UseDebugDevice)) + if (!m_shader_cache.Open(EmuFolders::Cache, g_d3d12_context->GetFeatureLevel(), SHADER_CACHE_VERSION, GSConfig.UseDebugDevice)) { Console.Warning("Shader cache failed to open."); } } else { - m_shader_cache.Open({}, g_d3d12_context->GetFeatureLevel(), SHADER_VERSION, GSConfig.UseDebugDevice); + m_shader_cache.Open({}, g_d3d12_context->GetFeatureLevel(), SHADER_CACHE_VERSION, GSConfig.UseDebugDevice); Console.WriteLn("Not using shader cache."); } diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.h b/pcsx2/GS/Renderers/DX12/GSDevice12.h index 899fcb0eca..942d8c803b 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.h +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.h @@ -133,8 +133,6 @@ public: }; private: - static constexpr u32 SHADER_VERSION = 1; - ComPtr m_tfx_root_signature; ComPtr m_utility_root_signature; diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 2415a4641b..faa8da6466 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -22,6 +22,7 @@ #include "GS/GSUtil.h" #include "Host.h" #include "HostDisplay.h" +#include "ShaderCacheVersion.h" #include #include #include @@ -206,7 +207,7 @@ bool GSDeviceOGL::Create() if (!theApp.GetConfigB("disable_shader_cache")) { - if (!m_shader_cache.Open(false, EmuFolders::Cache, SHADER_VERSION)) + if (!m_shader_cache.Open(false, EmuFolders::Cache, SHADER_CACHE_VERSION)) Console.Warning("Shader cache failed to open."); } else diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h index 4cbf7a5add..328fb187ff 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h @@ -211,9 +211,6 @@ public: static int m_shader_reg; private: - // Increment this constant whenever shaders change, to invalidate user's program binary cache. - static constexpr u32 SHADER_VERSION = 3; - static FILE* m_debug_gl_file; bool m_disable_hw_gl_draw; diff --git a/pcsx2/ShaderCacheVersion.h b/pcsx2/ShaderCacheVersion.h new file mode 100644 index 0000000000..1e930fa067 --- /dev/null +++ b/pcsx2/ShaderCacheVersion.h @@ -0,0 +1,18 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2022 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +/// Version number for GS and other shaders. Increment whenever any of the contents of the +/// shaders change, to invalidate the cache. +static constexpr u32 SHADER_CACHE_VERSION = 10; diff --git a/pcsx2/pcsx2.vcxproj b/pcsx2/pcsx2.vcxproj index ec6114d43f..468b6d4b39 100644 --- a/pcsx2/pcsx2.vcxproj +++ b/pcsx2/pcsx2.vcxproj @@ -869,6 +869,7 @@ + diff --git a/pcsx2/pcsx2.vcxproj.filters b/pcsx2/pcsx2.vcxproj.filters index 4328d14c04..4fe0482703 100644 --- a/pcsx2/pcsx2.vcxproj.filters +++ b/pcsx2/pcsx2.vcxproj.filters @@ -2996,6 +2996,9 @@ Host + + System\Include + @@ -3158,4 +3161,4 @@ AppHost\Resources - \ No newline at end of file + diff --git a/pcsx2/pcsx2core.vcxproj b/pcsx2/pcsx2core.vcxproj index 32bc4f8e89..2ef4c94201 100644 --- a/pcsx2/pcsx2core.vcxproj +++ b/pcsx2/pcsx2core.vcxproj @@ -566,6 +566,7 @@ +