ShaderCache: Add a data version field

We can increment this to prevent people's shader caches from growing too
large with shader changes.
This commit is contained in:
Connor McLaughlin
2021-01-11 14:50:25 +10:00
parent 97971464d1
commit fd166a4485
14 changed files with 56 additions and 29 deletions

View File

@ -84,6 +84,7 @@ add_library(core
save_state_version.h
settings.cpp
settings.h
shader_cache_version.h
shadergen.cpp
shadergen.h
sio.cpp

View File

@ -224,6 +224,7 @@
<ClInclude Include="save_state_version.h" />
<ClInclude Include="settings.h" />
<ClInclude Include="shadergen.h" />
<ClInclude Include="shader_cache_version.h" />
<ClInclude Include="sio.h" />
<ClInclude Include="spu.h" />
<ClInclude Include="system.h" />

View File

@ -56,6 +56,7 @@
<ClCompile Include="gpu_sw_backend.cpp" />
<ClCompile Include="libcrypt_game_codes.cpp" />
<ClCompile Include="texture_replacements.cpp" />
<ClCompile Include="gdb_protocol.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="types.h" />
@ -66,7 +67,6 @@
<ClInclude Include="cpu_disasm.h" />
<ClInclude Include="bus.h" />
<ClInclude Include="dma.h" />
<ClInclude Include="gdb_protocol.h" />
<ClInclude Include="gpu.h" />
<ClInclude Include="gpu_hw_opengl.h" />
<ClInclude Include="gpu_hw.h" />
@ -115,5 +115,6 @@
<ClInclude Include="gpu_sw_backend.h" />
<ClInclude Include="libcrypt_game_codes.h" />
<ClInclude Include="texture_replacements.h" />
<ClInclude Include="shader_cache_version.h" />
</ItemGroup>
</Project>

View File

@ -6,6 +6,7 @@
#include "gpu_hw_shadergen.h"
#include "host_display.h"
#include "host_interface.h"
#include "shader_cache_version.h"
#include "system.h"
Log_SetChannel(GPU_HW_D3D11);
@ -447,7 +448,7 @@ void GPU_HW_D3D11::DestroyStateObjects()
bool GPU_HW_D3D11::CompileShaders()
{
D3D11::ShaderCache shader_cache;
shader_cache.Open(g_host_interface->GetShaderCacheBasePath(), m_device->GetFeatureLevel(),
shader_cache.Open(g_host_interface->GetShaderCacheBasePath(), m_device->GetFeatureLevel(), SHADER_CACHE_VERSION,
g_settings.gpu_use_debug_device);
GPU_HW_ShaderGen shadergen(m_host_display->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,

View File

@ -4,6 +4,7 @@
#include "common/timer.h"
#include "gpu_hw_shadergen.h"
#include "host_display.h"
#include "shader_cache_version.h"
#include "system.h"
#include "texture_replacements.h"
Log_SetChannel(GPU_HW_OpenGL);
@ -398,7 +399,7 @@ bool GPU_HW_OpenGL::CreateTextureBuffer()
bool GPU_HW_OpenGL::CompilePrograms()
{
GL::ShaderCache shader_cache;
shader_cache.Open(IsGLES(), g_host_interface->GetShaderCacheBasePath());
shader_cache.Open(IsGLES(), g_host_interface->GetShaderCacheBasePath(), SHADER_CACHE_VERSION);
const bool use_binding_layout = GPU_HW_ShaderGen::UseGLSLBindingLayout();
GPU_HW_ShaderGen shadergen(m_host_display->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading,

View File

@ -0,0 +1,4 @@
#pragma once
#include "types.h"
static constexpr u32 SHADER_CACHE_VERSION = 1;