From 964b94960eb22e894714ba4eb36a8cc0a96e8dab Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 15 Jun 2024 23:55:32 +1000 Subject: [PATCH] Postprocessing/FX: Ensure RT isn't bound as sampler Prevents possible Vulkan spec violation in some shaders. --- src/util/postprocessing_shader_fx.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/util/postprocessing_shader_fx.cpp b/src/util/postprocessing_shader_fx.cpp index 8e8932f7a..1b1b6b433 100644 --- a/src/util/postprocessing_shader_fx.cpp +++ b/src/util/postprocessing_shader_fx.cpp @@ -1765,6 +1765,15 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUTexture* final std::bitset bound_textures = {}; for (const Sampler& sampler : pass.samplers) { + // Can't bind the RT as a sampler. + if (std::any_of(pass.render_targets.begin(), pass.render_targets.end(), + [&sampler](TextureID rt) { return rt == sampler.texture_id; })) + { + GL_INS_FMT("Not binding RT sampler {}: ID {} [{}]", sampler.slot, sampler.texture_id, + GetTextureNameForID(sampler.texture_id)); + continue; + } + GL_INS_FMT("Texture Sampler {}: ID {} [{}]", sampler.slot, sampler.texture_id, GetTextureNameForID(sampler.texture_id)); g_gpu_device->SetTextureSampler(sampler.slot, GetTextureByID(sampler.texture_id, input, final_target),