Running a game with -d3ddebug triggers an error about OMSetDepthBounds

Hi, we were running a game with -d3ddebug and at some point during open an internal UI map got this error from d3d debug layer:

D3D12 ERROR: ID3D12CommandList::OMSetDepthBounds: Min=0.00 is greater than Max=-7.39. [ STATE_SETTING ERROR #1043: SETDEPTHBOUNDS_INVALIDARGS] LogD3D12RHI: Error: ID3D12CommandList::OMSetDepthBounds: Min=0.00 is greater than Max=-7.39. (ID 1043)Running then same scenario with -rdgimmediate -forcerhibypass -onethread gave us following callstack:

FD3D12CommandContext::SetDepthBounds(float MinDepth, float MaxDepth) Line 1996 C++ FD3D12StateCache::ApplyState(ED3D12PipelineType PipelineType) Line 548 C++ FD3D12CommandContext::RHIDrawPrimitive(unsigned int BaseVertexIndex, unsigned int NumPrimitives, unsigned int NumInstances) Line 1582 C++ FRHICommandList::DrawPrimitive(unsigned int) Line 3738 C++ DrawClearQuadMRT(FRHICommandList & RHICmdList, bool bClearColor, int NumClearColors, const FLinearColor * ClearColorArray, bool bClearDepth, float Depth, bool bClearStencil, unsigned int Stencil, FClearQuadCallbacks ClearQuadCallbacks) Line 125 C++ DrawClearQuad(FRHICommandList &) Line 77 C++ AddAmbientOcclusionPass::__l20::<lambda>(FRHICommandList & RHICmdList) Line 916 C++It seems the issue came from the line where it calculates DepthFar = FMath::Min(1.0f, Far.Z / Far.W); producing -7.39f. Should it be clamped instead? Or there is another way to fix the issue for this specific code?

Steps to Reproduce

const FVector4f Far = (FVector4f)ProjectionMatrix.TransformFVector4(FVector4(0, 0, Settings.AmbientOcclusionFadeDistance)); DepthFar = FMath::Min(1.0f, Far.Z / Far.W);Hi there,

It looks like this issue is occurring in the calculation in the above code snippet. As far as I can tell, the only way this could end up negative is if something in your project is setting AmbientOcclusionFadeDistance to a negative value.

This is generally set on your post process volume. In editor, and blueprint, this value is called the Fade Out Distance, under the ambient occlusion -> advanced section in the post process volume. It can also be set on individual camera’s post processing settings. When you change this value in the editor details panel, it is clamped. However, if you change it via blueprint, or C++, you need to manually clamp it yourself, otherwise it could end up with invalid values.

Regards,

Lance