Add a hidden setting to turn off the shader cache, for shader compile performance work

This commit is contained in:
Henrik Rydgård 2021-11-21 21:23:15 +01:00
parent dda425b068
commit f1cd1d535b
4 changed files with 26 additions and 5 deletions

View file

@ -914,6 +914,8 @@ static ConfigSetting graphicsSettings[] = {
ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, false),
ConfigSetting("RenderDuplicateFrames", &g_Config.bRenderDuplicateFrames, false, true, true),
ConfigSetting("ShaderCache", &g_Config.bShaderCache, true, false, false), // Doesn't save. Ini-only.
ConfigSetting(false),
};

View file

@ -224,6 +224,7 @@ public:
bool bFragmentTestCache;
int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High
bool bHardwareTessellation;
bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times.
std::vector<std::string> vPostShaderNames; // Off for chain end (only Off for no shader)
std::map<std::string, float> mPostShaderSetting;

View file

@ -103,10 +103,14 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
// Load shader cache.
std::string discID = g_paramSFO.GetDiscID();
if (discID.size()) {
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) / (discID + ".glshadercache");
// Actually precompiled by IsReady() since we're single-threaded.
shaderManagerGL_->Load(shaderCachePath_);
if (g_Config.bShaderCache) {
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) / (discID + ".glshadercache");
// Actually precompiled by IsReady() since we're single-threaded.
shaderManagerGL_->Load(shaderCachePath_);
} else {
INFO_LOG(G3D, "Shader cache disabled. Not loading.");
}
}
if (g_Config.bHardwareTessellation) {
@ -129,7 +133,11 @@ GPU_GLES::~GPU_GLES() {
// everything should already be cleared since DeviceLost has been run.
if (shaderCachePath_.Valid() && draw_) {
shaderManagerGL_->Save(shaderCachePath_);
if (g_Config.bShaderCache) {
shaderManagerGL_->Save(shaderCachePath_);
} else {
INFO_LOG(G3D, "Shader cache disabled. Not saving.");
}
}
framebufferManagerGL_->DestroyAllFBOs();

View file

@ -123,6 +123,11 @@ void GPU_Vulkan::CancelReady() {
}
void GPU_Vulkan::LoadCache(const Path &filename) {
if (!g_Config.bShaderCache) {
INFO_LOG(G3D, "Shader cache disabled. Not loading.");
return;
}
PSP_SetLoading("Loading shader cache...");
// Actually precompiled by IsReady() since we're single-threaded.
FILE *f = File::OpenCFile(filename, "rb");
@ -148,6 +153,11 @@ void GPU_Vulkan::LoadCache(const Path &filename) {
}
void GPU_Vulkan::SaveCache(const Path &filename) {
if (!g_Config.bShaderCache) {
INFO_LOG(G3D, "Shader cache disabled. Not saving.");
return;
}
if (!draw_) {
// Already got the lost message, we're in shutdown.
WARN_LOG(G3D, "Not saving shaders - shutting down from in-game.");