Fix GPU Crash in SetupLogLuminanceCS Post process

Hello Epic Support Team!

I want to share the details about GPU crash that I found by inspecting code related to breadcrumbs tag LocalExposure - Blurred Luminance, which was collected in many crashes, but with no shader debug data.

Just by looking at SetupLogLuminanceCS we see that it expects input and output sizes to be 8x8 aligned as THREADGROUP_SIZEX==THREADGROUP_SIZEY==8.

By inspecting C++ code we can learn engine uses very low MIP of main texture for post process when CVarPostProcessingQuarterResolutionDownsample == 0.

const uint32 BlurredLumMip = bProcessEighthResolution ? 2 : (bProcessQuarterResolution ? 3 : 4);

which results in SceneDownsampleChain.GetTexture(4).

At this moments it’s already obvious that not many resolutions could be down scaled 3 or 4 times and still be divisible by 8 for each dimension. Take this resolution for example 720 / (2*2*2) = 90. 90 is not divisible by 8 without remainder (90/8=11.25).

You can either make sure textures are always have 8x8 aligned size at c++ side or check size in shader as in PR below.

https://github.com/EpicGames/UnrealEngine/pull/14007

I cannot provide no additional logs or breadcrumbs for this issue, but I can answer other questions in order to help you to reproduce this issue.

Looking forward for a p4 CL or github link so I can cherry pick this fix from Epic.

Best regards

Steps to Reproduce

I can’t provide steps to crash a GPU with 100%, but here is how you can see there is a problem if inspecting a c++/shader code is not enough.

Set CVarPostProcessingQuarterResolutionDownsample == 0

In Runtime\Renderer\Private\PostProcess\PostProcessLocalExposure.cpp function AddLocalExposureBlurredLogLuminancePass add check to make sure input and output textures size 8x8 blocks aligned like this.

check((SizeX&7)==0);

check((SizeY&7)==0);

Run the game set some low resolution and catch exception in checks you made via Visual Studio.

That’s all now it’s obvious that GPU code could read/write out of bounds and we need to fix it.

Thank you for sending in this fix and for the extra details, we also received the GitHub PR and a rendering engineer is assigned to investigate. We’ll likely take the fix as is, if there are no perf issues and should know more next week. The GitHub PR should be marked as merged if we merge it as is. Thanks again!