mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 03:25:36 +00:00
PostProcessing/FX: Alternate between two 'backbuffers'
Saves video memory, and also fixes shaders that expect each pass's input to be the output of the previous path without explicitly referencing the render target.
This commit is contained in:
parent
80cfe59dbe
commit
1aabcf1ba7
@ -1161,6 +1161,11 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
m_textures.push_back(std::move(tex));
|
||||
}
|
||||
|
||||
// need potentially up to two backbuffers
|
||||
std::array<std::optional<TextureID>, 2> backbuffer_texture_ids;
|
||||
std::optional<TextureID> read_backbuffer;
|
||||
u32 current_backbuffer = 0;
|
||||
|
||||
for (const reshadefx::technique& tech : mod.techniques)
|
||||
{
|
||||
for (const reshadefx::pass& pi : tech.passes)
|
||||
@ -1201,6 +1206,15 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// swap to the other backbuffer, sample from the previous written
|
||||
if (backbuffer_texture_ids[current_backbuffer].has_value())
|
||||
{
|
||||
read_backbuffer = backbuffer_texture_ids[current_backbuffer];
|
||||
current_backbuffer ^= 1;
|
||||
}
|
||||
|
||||
if (!backbuffer_texture_ids[current_backbuffer].has_value())
|
||||
{
|
||||
Texture new_rt;
|
||||
new_rt.format = backbuffer_format;
|
||||
@ -1208,10 +1222,15 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
new_rt.storage_access = false;
|
||||
new_rt.render_target_width = 0;
|
||||
new_rt.render_target_height = 0;
|
||||
pass.render_targets.push_back(static_cast<TextureID>(m_textures.size()));
|
||||
new_rt.reshade_name = fmt::format("| BackBuffer{} |", current_backbuffer);
|
||||
|
||||
backbuffer_texture_ids[current_backbuffer] = static_cast<TextureID>(m_textures.size());
|
||||
m_textures.push_back(std::move(new_rt));
|
||||
}
|
||||
|
||||
pass.render_targets.push_back(backbuffer_texture_ids[current_backbuffer].value());
|
||||
}
|
||||
|
||||
u32 texture_slot = 0;
|
||||
Assert(pi.texture_bindings.size() == pi.sampler_bindings.size());
|
||||
for (size_t tb_index = 0; tb_index < pi.texture_bindings.size(); tb_index++)
|
||||
@ -1232,7 +1251,7 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
// found the texture, now look for our side of it
|
||||
if (ti.semantic == "COLOR")
|
||||
{
|
||||
sampler.texture_id = INPUT_COLOR_TEXTURE;
|
||||
sampler.texture_id = read_backbuffer.value_or(INPUT_COLOR_TEXTURE);
|
||||
break;
|
||||
}
|
||||
else if (ti.semantic == "DEPTH")
|
||||
|
Loading…
x
Reference in New Issue
Block a user