From bd27752bde39065be520ece39c30df80f14815e3 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 28 Mar 2018 14:41:50 +0100 Subject: [PATCH] clear shader cache when changing options in the game settings screen, fixes changes to realtime scaling options not being applied directly. --- GPU/Common/ShaderCommon.h | 7 +++---- GPU/Common/TextureCacheCommon.cpp | 1 + GPU/Directx9/PixelShaderGeneratorDX9.cpp | 13 ++----------- GPU/GPUCommon.cpp | 2 +- UI/GameSettingsScreen.cpp | 1 + Windows/MainWindowMenu.cpp | 4 ++-- Windows/resource.h | 2 +- 7 files changed, 11 insertions(+), 19 deletions(-) diff --git a/GPU/Common/ShaderCommon.h b/GPU/Common/ShaderCommon.h index 93e4464ea9..09867f07af 100644 --- a/GPU/Common/ShaderCommon.h +++ b/GPU/Common/ShaderCommon.h @@ -82,12 +82,11 @@ enum : uint64_t { // These are for hardware tessellation DIRTY_BEZIERSPLINE = 1ULL << 32, DIRTY_TEXCLAMP = 1ULL << 33, + DIRTY_TEXSIZE = 1ULL << 34, - DIRTY_TEXSIZE = 1ULL << 33, + // space for 5 more uniforms. - // space for 6 more uniforms. - - DIRTY_ALL_UNIFORMS = 0x3FFFFFFFFULL, + DIRTY_ALL_UNIFORMS = 0x7FFFFFFFFULL, DIRTY_ALL_LIGHTS = DIRTY_LIGHT0 | DIRTY_LIGHT1 | DIRTY_LIGHT2 | DIRTY_LIGHT3, // Other dirty elements that aren't uniforms! diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index aaf5cec2de..1363bbfdc4 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -496,6 +496,7 @@ void TextureCacheCommon::SetTexture(bool force) { gstate_c.curTextureWidth = w; gstate_c.curTextureHeight = h; + gstate_c.Dirty(DIRTY_TEXSIZE); // Before we go reading the texture from memory, let's check for render-to-texture. // We must do this early so we have the right w/h. diff --git a/GPU/Directx9/PixelShaderGeneratorDX9.cpp b/GPU/Directx9/PixelShaderGeneratorDX9.cpp index 0caf177e74..9a8816eabc 100644 --- a/GPU/Directx9/PixelShaderGeneratorDX9.cpp +++ b/GPU/Directx9/PixelShaderGeneratorDX9.cpp @@ -262,16 +262,7 @@ static const char* sampler_xbrz = " res2 = lerp(res2, lerp(F, B, px.y), maximos.y);\n" " res2 = lerp(res2, lerp(D, H, px.w), maximos.w);\n" "\n" - " float4 res = lerp(res1, res2, step(c_df(E, res1), c_df(E, res2)));\n" - " return res;\n" -// " float texel_alpha = tex_sample_direct(tc * u_texSize.zw).a;\n" -// "\n" -// " return float4(E, texel_alpha);\n" -// " return tex_sample_direct(coord);\n" -// " return tex_sample_direct(coord * u_texSize.xy * u_texSize.zw);\n" -// " return float4(res2, texel_alpha);\n" -// " return float4(res.r, 0.0f, 0.0f, texel_alpha);\n" -// " return float4(res, texel_alpha);\n" + " return lerp(res1, res2, step(c_df(E, res1), c_df(E, res2)));\n" "}\n"; @@ -393,7 +384,7 @@ bool GenerateFragmentShaderHLSL(const FShaderID &id, char *buffer, ShaderLanguag } WRITE(p, "};\n"); - if (doTexture) { + if (!isModeClear && doTexture) { WRITE(p, "float4 tex_sample_direct(float2 coord) {\n"); if (lang == HLSL_D3D11 || lang == HLSL_D3D11_LEVEL9) { diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 8a03e53297..76db1dc639 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1407,7 +1407,7 @@ void GPUCommon::Execute_TexSize0(u32 op, u32 diff) { // Don't reset it unless the size is different / the texture has changed. if (diff || gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS)) { gstate_c.curTextureWidth = gstate.getTextureWidth(0); - gstate_c.curTextureHeight = gstate.getTextureHeight(0); + gstate_c.curTextureHeight = gstate.getTextureHeight(0); gstate_c.Dirty(DIRTY_UVSCALEOFFSET); // We will need to reset the texture now. gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3fb3e8643f..792280da67 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1038,6 +1038,7 @@ void GameSettingsScreen::onFinish(DialogResult result) { // Wipe some caches after potentially changing settings. NativeMessageReceived("gpu_resized", ""); NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_clearShaderCache", ""); } void GameSettingsScreen::CallbackRenderingBackend(bool yes) { diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index f0fb114c1c..c6217462d6 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -770,8 +770,8 @@ namespace MainWindow { case ID_TEXTURESCALING_HYBRID: setTexScalingType(TextureScalerCommon::HYBRID); break; case ID_TEXTURESCALING_BICUBIC: setTexScalingType(TextureScalerCommon::BICUBIC); break; case ID_TEXTURESCALING_HYBRID_BICUBIC: setTexScalingType(TextureScalerCommon::HYBRID_BICUBIC); break; - case ID_TEXTURESCALING_GAUSSIAN: setTexScalingType(TextureScalerCommon::GAUSSIAN); break; - case ID_TEXTURESCALING_COSINE: setTexScalingType(TextureScalerCommon::COSINE); break; + case ID_TEXTURESCALING_GAUSSIAN: setTexScalingType(TextureScalerCommon::GAUSSIAN); break; + case ID_TEXTURESCALING_COSINE: setTexScalingType(TextureScalerCommon::COSINE); break; case ID_TEXTURESCALING_REALTIME: g_Config.bRealtimeTexScaling = !g_Config.bRealtimeTexScaling; diff --git a/Windows/resource.h b/Windows/resource.h index 576580b64d..4c285d0e38 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -341,7 +341,7 @@ #define ID_OPTIONS_WINDOW10X 40176 #define ID_TEXTURESCALING_REALTIME 40177 -#define ID_TEXTURESCALING_GAUSSIAN 40178 +#define ID_TEXTURESCALING_GAUSSIAN 40178 #define ID_TEXTURESCALING_COSINE 40179 // Dummy option to let the buffered rendering hotkey cycle through all the options.