Description

Drawing a material to a render target when that material samples an RVT can cause an editor crash.

In our testing, the check() did not always occur on the first PIE session, but would always occur on the second PIE session.

Internally, the chain of events is as follows:

Draw Material to Render Target BP node triggers a call to FRendererModule::DrawTileMesh().
FRendererModule::DrawTileMesh() will call FVirtualTextureSystem::Update() if the material is using VTs, which means the virtual texture update triggers outside of regular scene rendering.
FVirtualTextureSystem::Update() calls FVirtualTextureSystem::SubmitRequests(), which calls FRuntimeVirtualTextureProducer::RequestPageData(), which returns EVTRequestPageStatus::Pending as the finalizer is not ready due to the fact we're not in a regular scene rendering pass.
EVTRequestPageStatus::Pending state gets overridden in FVirtualTextureSystem::SubmitRequests() due to bSyncProduceLockedTiles constant being true in editor.
Therefore the state ends up being forced to EVTRequestPageStatus::Available which triggers a call to FRuntimeVirtualTextureProducer::ProducePageData(), which registers the tile with the finalizer.
FRuntimeVirtualTextureFinalizer::Finalize() is called, which calls RenderPages(). RenderPages() checks if the scene is currently rendering, which it is not. Because it's not rendering, it calls RenderPagesStandAlone(), which starts scene rendering. This calls FScene::Update(), which fails the check check(!UE::RenderCommandPipe::IsReplaying())

Also tested on UE5-Main, CL: 34762151

 

Steps to Reproduce

1. Download the Licensee test project, compile, and launch through debugger
2. Open the map "/Game/TestMap"
3. Select the Runtime Virtual Texture Volume, and click the SetBounds button in the Details Panel.
4. Run PIE. If it does not breakpoint, exit PIE and run it again.
5. Observe the failed check(!UE::RenderCommandPipe::IsReplaying()); in FScene::Update(...) from RenderScene.cpp

Callstack
>	UnrealEditor-Renderer.dll!FScene::Update(FRDGBuilder & GraphBuilder, const FScene::FUpdateParameters & Parameters) Line 5471	C++
 	UnrealEditor-Renderer.dll!FScene::UpdateAllPrimitiveSceneInfos(FRDGBuilder & GraphBuilder, EUpdateAllPrimitiveSceneInfosAsyncOps AsyncOps) Line 5460	C++
 	UnrealEditor-Renderer.dll!FScenePrimitiveRenderingContext::FScenePrimitiveRenderingContext(FRDGBuilder & GraphBuilder, FScene & Scene, FSceneViewFamily * InViewFamily) Line 5310	C++
 	UnrealEditor-Renderer.dll!FRendererModule::BeginScenePrimitiveRendering(FRDGBuilder & GraphBuilder, FSceneInterface & InScene) Line 5354	C++
 	UnrealEditor-Renderer.dll!RuntimeVirtualTexture::RenderPagesStandAlone(FRDGBuilder & GraphBuilder, const RuntimeVirtualTexture::FRenderPageBatchDesc & InDesc) Line 1584	C++
 	UnrealEditor-Renderer.dll!RuntimeVirtualTexture::RenderPages(FRDGBuilder & GraphBuilder, const RuntimeVirtualTexture::FRenderPageBatchDesc & InDesc) Line 1619	C++
 	UnrealEditor-Renderer.dll!FRuntimeVirtualTextureFinalizer::Finalize(FRDGBuilder & GraphBuilder) Line 136	C++
 	UnrealEditor-Renderer.dll!FVirtualTextureSystem::FinalizeRequests(FRDGBuilder & GraphBuilder) Line 2431	C++
 	UnrealEditor-Renderer.dll!FVirtualTextureSystem::EndUpdate(FRDGBuilder & GraphBuilder, TUniquePtr<FVirtualTextureUpdater,TDefaultDelete<FVirtualTextureUpdater>> && Updater, ERHIFeatureLevel::Type FeatureLevel) Line 2847	C++
 	UnrealEditor-Renderer.dll!FVirtualTextureSystem::Update(FRDGBuilder & GraphBuilder, ERHIFeatureLevel::Type FeatureLevel, FScene * Scene, const FVirtualTextureUpdateSettings & InSettings) Line 2870	C++
 	UnrealEditor-Renderer.dll!FRendererModule::DrawTileMesh(FCanvasRenderContext & RenderContext, FMeshPassProcessorRenderState & DrawRenderState, const FSceneView & SceneView, FMeshBatch & Mesh, bool bIsHitTesting, const FHitProxyId & HitProxyId, bool bUse128bitRT) Line 335	C++
 	UnrealEditor-Engine.dll!FCanvasTileRendererItem::FRenderData::RenderTiles(FCanvasRenderContext & RenderContext, FMeshPassProcessorRenderState & DrawRenderState, const FSceneView & View, bool bIsHitTesting, bool bUse128bitRT) Line 204	C++
 	UnrealEditor-Engine.dll!FCanvasTileRendererItem::Render_GameThread::__l9::<lambda_3>::operator()(FCanvasRenderContext & RenderContext) Line 308	C++
 	[Inline Frame] UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<0>,void __cdecl(FCanvasRenderContext &)>::operator()(FCanvasRenderContext &) Line 555	C++
 	UnrealEditor-Engine.dll!FCanvasRenderThreadScope::{dtor}::__l2::<lambda_1>::operator()(FRHICommandListImmediate & RHICmdList) Line 561	C++
 	[Inline Frame] UnrealEditor-RenderCore.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<1>,void __cdecl(FRHICommandListImmediate &)>::operator()(FRHICommandListImmediate &) Line 555	C++
 	UnrealEditor-RenderCore.dll!FRenderThreadCommandPipe::EnqueueAndLaunch::__l5::<lambda_1>::operator()() Line 1751	C++
 	[Inline Frame] UnrealEditor-RenderCore.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<1>,void __cdecl(void)>::operator()() Line 555	C++
 	[Inline Frame] UnrealEditor-RenderCore.dll!TFunctionGraphTaskImpl<void __cdecl(void),1>::DoTaskImpl(TUniqueFunction<void __cdecl(void)> & Function, ENamedThreads::Type) Line 1733	C++
 	[Inline Frame] UnrealEditor-RenderCore.dll!TFunctionGraphTaskImpl<void __cdecl(void),1>::DoTask(ENamedThreads::Type) Line 1726	C++
 	UnrealEditor-RenderCore.dll!TGraphTask<TFunctionGraphTaskImpl<void __cdecl(void),1>>::ExecuteTask(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & NewTasks, ENamedThreads::Type CurrentThread, bool bDeleteOnCompletion) Line 1235	C++
 	[Inline Frame] UnrealEditor-Core.dll!FBaseGraphTask::Execute(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & CurrentThread, ENamedThreads::Type) Line 840	C++
 	UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread(int QueueIndex, bool bAllowStall) Line 760	C++
 	UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 651	C++
 	UnrealEditor-RenderCore.dll!RenderingThreadMain(FEvent * TaskGraphBoundSyncEvent) Line 413	C++
 	UnrealEditor-RenderCore.dll!FRenderingThread::Run() Line 566	C++
 	UnrealEditor-Core.dll!FRunnableThreadWin::Run() Line 149	C++
 	UnrealEditor-Core.dll!FRunnableThreadWin::GuardedRun() Line 71	C++
 	[External Code] 

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-219361 in the post.

3
Login to Vote

Fixed
ComponentUE - Rendering Architecture
Affects Versions5.45.4.2
Target Fix5.5
Fix Commit34901204
CreatedJul 15, 2024
ResolvedJul 18, 2024
UpdatedSep 23, 2024
View Jira Issue