Crash in UnrealEditor_D3D12RHI!GetD3D12TextureFromRHITexture

It occurs on the line above the check.

Alex, should those two parameters cause a big drop in performance?

Thank you a lot Robert. I’ve relayed this information to our developers.

Michal, to clarify, I am just another Unreal customer trying to provide some more context for the Epic guys. Not sure my info here will be helpful, but I’d be happy to hear about the resolution if you do.

Let me quote our developer on the findings so far:

“It’s the nanite shading pass, and it’s an internal texture”.

There’s also a dump file, but we have to figure out sharing it (it’s 60GB).

I’m working on a similar crash and came to the same conclusion. The callstack on the RHI thread is as follows:

GetD3D12TextureFromRHITexture(FRHITexture *)
FD3D12CommandContext::RetrieveTexture(FRHITexture *)
FD3D12CommandContext::RetrieveTexture(FRHITexture *)
FD3D12CommandContext::SetRenderTargets(unsigned int NewNumSimultaneousRenderTargets, const FRHIRenderTargetView * NewRenderTargetsRHI, const FRHIDepthRenderTargetView * NewDepthStencilTargetRHI)
FD3D12CommandContext::SetRenderTargetsAndClear(const FRHISetRenderTargetsInfo & RenderTargetsInfo)
FD3D12CommandContext::RHIBeginRenderPass(const FRHIRenderPassInfo & InInfo, const wchar_t * InName)
FRHICommand<FRHICommandBeginRenderPass,FRHICommandBeginRenderPassString1804>::ExecuteAndDestruct(FRHICommandListBase & CmdList)
FRHICommandListBase::Execute()
FRHICommandListExecutor::FTranslateState::Translate(FRHICommandListBase * CmdList)
FRHICommandListExecutor::FSubmitState::Dispatch::__l19::<lambda_1>::operator()()

And like [mention removed]​ I think this indicates that CurrentBackBuffer_RHIThread->Texture must be null - and I can see how that happens: when the crash occurs, the game thread is here:

FEventWin::Wait(unsigned int WaitTime, const bool bIgnoreThreadIdleStats)
FEvent::Wait(const FTimespan &)
GameThreadWaitForTask(const UE::Tasks::Private::FTaskHandle &)
FRenderCommandFence::Wait(bool)
FlushRenderingCommands()
FD3D12Viewport::Resize(unsigned int InSizeX, unsigned int InSizeY, bool bInIsFullscreen, EPixelFormat PreferredPixelFormat)
FD3D12DynamicRHI::RHIResizeViewport(FRHIViewport * ViewportRHI, unsigned int SizeX, unsigned int SizeY, bool bIsFullscreen, EPixelFormat PreferredPixelFormat)

The root cause is that FD3D12Viewport::Resize() calls ReleaseBackBufferResource() *before* the call to FlushRenderingCommands() - those release calls are what cause CurrentBackBuffer_RHIThread->Texture to be null by the time the RHI thread gets to try to use it (in other words, this looks like a race condition bug)