Add shader cache invalidation when using debug shader option via cmd line in Editor
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"Major": 1,
|
||||
"Minor": 9,
|
||||
"Revision": 0,
|
||||
"Build": 6602
|
||||
"Build": 6603
|
||||
},
|
||||
"Company": "Flax",
|
||||
"Copyright": "Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.",
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Engine/EngineService.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
#endif
|
||||
#include "Engine/Graphics/Shaders/GPUShader.h"
|
||||
#include "Engine/Graphics/Materials/MaterialShader.h"
|
||||
#include "Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h"
|
||||
@@ -184,9 +187,15 @@ bool ShaderCacheManagerService::Init()
|
||||
int32 ShaderCacheVersion = -1;
|
||||
int32 MaterialGraphVersion = -1;
|
||||
int32 ParticleGraphVersion = -1;
|
||||
bool ShaderDebug;
|
||||
};
|
||||
CacheVersion cacheVersion;
|
||||
const String cacheVerFile = rootDir / TEXT("CacheVersion");
|
||||
#if USE_EDITOR
|
||||
const bool shaderDebug = CommandLine::Options.ShaderDebug;
|
||||
#else
|
||||
const bool shaderDebug = false;
|
||||
#endif
|
||||
if (FileSystem::FileExists(cacheVerFile))
|
||||
{
|
||||
if (File::ReadAllBytes(cacheVerFile, (byte*)&cacheVersion, sizeof(cacheVersion)))
|
||||
@@ -199,6 +208,7 @@ bool ShaderCacheManagerService::Init()
|
||||
|| cacheVersion.ShaderCacheVersion != GPU_SHADER_CACHE_VERSION
|
||||
|| cacheVersion.MaterialGraphVersion != MATERIAL_GRAPH_VERSION
|
||||
|| cacheVersion.ParticleGraphVersion != PARTICLE_GPU_GRAPH_VERSION
|
||||
|| cacheVersion.ShaderDebug != shaderDebug
|
||||
)
|
||||
{
|
||||
LOG(Warning, "Shaders cache database is invalid. Performing reset.");
|
||||
@@ -216,6 +226,7 @@ bool ShaderCacheManagerService::Init()
|
||||
cacheVersion.ShaderCacheVersion = GPU_SHADER_CACHE_VERSION;
|
||||
cacheVersion.MaterialGraphVersion = MATERIAL_GRAPH_VERSION;
|
||||
cacheVersion.ParticleGraphVersion = PARTICLE_GPU_GRAPH_VERSION;
|
||||
cacheVersion.ShaderDebug = shaderDebug;
|
||||
if (File::WriteAllBytes(cacheVerFile, (byte*)&cacheVersion, sizeof(cacheVersion)))
|
||||
{
|
||||
LOG(Error, "Failed to create the shaders cache database version file.");
|
||||
|
||||
Reference in New Issue
Block a user