Fix crash when using very small render resolution

#2261
This commit is contained in:
Wojtek Figat
2024-02-21 00:00:58 +01:00
parent 9a21cfd092
commit 149a6a29f8
2 changed files with 13 additions and 11 deletions

View File

@@ -194,8 +194,18 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input,
bool useCameraArtifacts = EnumHasAnyFlags(view.Flags, ViewFlags::CameraArtifacts) && (settings.CameraArtifacts.VignetteIntensity > 0.0f || settings.CameraArtifacts.GrainAmount > 0.0f || settings.CameraArtifacts.ChromaticDistortion > 0.0f || settings.CameraArtifacts.ScreenFadeColor.A > 0.0f);
bool useLensFlares = EnumHasAnyFlags(view.Flags, ViewFlags::LensFlares) && settings.LensFlares.Intensity > 0.0f && useBloom;
// Cache viewport sizes
int32 w1 = input->Width();
int32 w2 = w1 >> 1;
int32 w4 = w2 >> 1;
int32 w8 = w4 >> 1;
int32 h1 = input->Height();
int32 h2 = h1 >> 1;
int32 h4 = h2 >> 1;
int32 h8 = h4 >> 1;
// Ensure to have valid data and if at least one effect should be applied
if (!(useBloom || useToneMapping || useCameraArtifacts) || checkIfSkipPass())
if (!(useBloom || useToneMapping || useCameraArtifacts) || checkIfSkipPass() || w8 == 0 || h8 ==0)
{
// Resources are missing. Do not perform rendering. Just copy raw frame
context->SetViewportAndScissors((float)output->Width(), (float)output->Height());
@@ -209,16 +219,6 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input,
auto cb0 = shader->GetCB(0);
auto cb1 = shader->GetCB(1);
// Cache viewport sizes
int32 w1 = input->Width();
int32 w2 = w1 >> 1;
int32 w4 = w2 >> 1;
int32 w8 = w4 >> 1;
int32 h1 = input->Height();
int32 h2 = h1 >> 1;
int32 h4 = h2 >> 1;
int32 h8 = h4 >> 1;
////////////////////////////////////////////////////////////////////////////////////
// Setup shader

View File

@@ -176,6 +176,8 @@ void ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPUTexture
// Prepare resolutions for passes
const int32 width = buffers->GetWidth();
const int32 height = buffers->GetHeight();
if (width < 4 || height < 4)
return;
const int32 traceWidth = width / static_cast<int32>(settings.RayTracePassResolution);
const int32 traceHeight = height / static_cast<int32>(settings.RayTracePassResolution);
const int32 resolveWidth = width / static_cast<int32>(settings.RayTracePassResolution);