Postprocessing/FX: Ensure RT isn't bound as sampler

Prevents possible Vulkan spec violation in some shaders.
This commit is contained in:
Stenzek 2024-06-15 23:55:32 +10:00
parent ef69c31e9f
commit 964b94960e
No known key found for this signature in database
1 changed files with 9 additions and 0 deletions

View File

@ -1765,6 +1765,15 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUTexture* final
std::bitset<GPUDevice::MAX_TEXTURE_SAMPLERS> 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),