Skip to content

Commit 4800a4e

Browse files
committed
PostProcessing: Avoid creating zero-sized intermediate targets
1 parent 962454b commit 4800a4e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/util/postprocessing_shader_fx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,8 +1586,8 @@ bool PostProcessing::ReShadeFXShader::ResizeTargets(u32 source_width, u32 source
15861586
if (!tex.render_target)
15871587
continue;
15881588

1589-
const u32 t_width = (tex.render_target_width > 0) ? tex.render_target_width : target_width;
1590-
const u32 t_height = (tex.render_target_height > 0) ? tex.render_target_height : target_height;
1589+
const u32 t_width = (tex.render_target_width > 0) ? tex.render_target_width : std::max<u32>(target_width, 1);
1590+
const u32 t_height = (tex.render_target_height > 0) ? tex.render_target_height : std::max<u32>(target_height, 1);
15911591
if (!g_gpu_device->ResizeTexture(&tex.texture, t_width, t_height, GPUTexture::Type::RenderTarget, tex.format,
15921592
tex.storage_access ? GPUTexture::Flags::AllowBindAsImage : GPUTexture::Flags::None,
15931593
false, error))

src/util/postprocessing_shader_slang.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,10 +1996,12 @@ bool PostProcessing::SlangShader::ResizeTargets(u32 source_width, u32 source_hei
19961996
if (pass.output_texture_id < 0)
19971997
continue;
19981998

1999-
const u32 tex_width =
2000-
apply_scale(pass.output_scale[0].first, pass.output_scale[0].second, prev_width, viewport_width, source_width);
2001-
const u32 tex_height =
2002-
apply_scale(pass.output_scale[1].first, pass.output_scale[1].second, prev_height, viewport_height, source_height);
1999+
const u32 tex_width = std::max<u32>(
2000+
apply_scale(pass.output_scale[0].first, pass.output_scale[0].second, prev_width, viewport_width, source_width),
2001+
1);
2002+
const u32 tex_height = std::max<u32>(
2003+
apply_scale(pass.output_scale[1].first, pass.output_scale[1].second, prev_height, viewport_height, source_height),
2004+
1);
20032005

20042006
// Source for the next pass is the previous pass's output.
20052007
prev_width = tex_width;

0 commit comments

Comments
 (0)