Description

When a mip level higher than 0 is requested in VisualizeTexture, the engine will crash. The root cause appears to be VisualizeTexture.cpp:924, on which an incorrect mip level is used to read a non-mipped texture.

This line originates around 4.22 in CL 4588745 but was guarded by an #if until around CL 14384911.

The new behavior of VisualizeTexture is to copy the requested mip to an output texture in FVisualizeTexture::AddVisualizeTexturePass (VisualizeTexture:718). This works as expected.

The output texture is then passed to a ReadbackTexturePass on line 928. This pass uses ReadDataFlags to sample again at the requested mip; however, this texture has no mip levels, so any mip above 0 is not valid.

Steps to Reproduce

Create a blank game project in 5.5. This creates an open world level with the skylight already set up and automatically capturing.

Run the command 'vis SkyRenderTarget uv2 BMP mip1'. This will crash the editor as SaveBMP attempts to use mip1 from the OutputTexture that already contains mip1 of the target texture. OutputTexture only has 1 mip level, so mip1 is invalid.

The expectation is that mip1 would be written to disk in the Saved directory.

These steps have been tested to work in 5.1 through 5.5. 5.0 should also be susceptible to this issue.

Callstack

Due to where in RenderGraph this error occurs, the callstack does not appear to be overly helpful.

UE::Logging::Private::BasicFatalLog(const FLogCategoryBase &,const UE::Logging::Private::FStaticBasicLogRecord *,...) StructuredLog.cpp:1104
D3D12RHI::VerifyD3D12Result(HRESULT, const char *, const char *, unsigned int, ID3D12Device *, FString) D3D12Util.cpp:991
[Inlined] TSparseArray::Num() SparseArray.h:911
[Inlined] TSet::Num() Set.h:581
FD3D12CommandList::Close() D3D12CommandList.cpp:310
[Inlined] FD3D12ContextCommon::CloseCommandList() D3D12CommandContext.cpp:422
FD3D12CommandContext::CloseCommandList() D3D12CommandContext.cpp:433
[Inlined] FD3D12BindlessResourceManager::FinalizeContext(FD3D12CommandContext &) D3D12BindlessDescriptors.cpp:545
[Inlined] FD3D12BindlessDescriptorManager::FinalizeContext(FD3D12CommandContext &) D3D12BindlessDescriptors.cpp:831
FD3D12CommandContext::Finalize(TArray<…> &) D3D12CommandContext.cpp:488
[Inlined] FD3D12DynamicRHI::RHIFinalizeContext::__l2::<lambda_1>::operator()(FD3D12CommandContext *, FD3D12FinalizedCommands &) D3D12Submission.cpp:195
FD3D12DynamicRHI::RHIFinalizeContext(FDynamicRHI::FRHIFinalizeContextArgs &&, TRHIPipelineArray<…> &) D3D12Submission.cpp:223
??R<lambda_1>@?1??Finalize@FTranslateState@FRHICommandListExecutor@@QEAA?AV?$TRefCountPtr@VFBaseGraphTask@@@@XZ@QEBA@XZ() RHICommandList.cpp:959
[Inlined] UE::Core::Private::Function::TFunctionRefBase::operator()() Function.h:470
FRHICommandListExecutor::FTaskPipe::Execute(FRHICommandListExecutor::FTaskPipe::FTask *, const TRefCountPtr<…> &) RHICommandList.cpp:624
[Inlined] UE::Core::Private::Function::TFunctionRefBase::operator()(Type, const TRefCountPtr<…> &) Function.h:470
[Inlined] TFunctionGraphTaskImpl::DoTaskImpl(TUniqueFunction<…> &, Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1722
[Inlined] TFunctionGraphTaskImpl::DoTask(Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1703
TGraphTask<TFunctionGraphTaskImpl<void __cdecl(ENamedThreads::Type,TRefCountPtr<FBaseGraphTask> const & __ptr64),0> >::ExecuteTask() TaskGraphInterfaces.h:634
UE::Tasks::Private::FTaskBase::TryExecuteTask() TaskPrivate.h:504
[Inlined] FBaseGraphTask::Execute(TArray<…> &, Type, bool) TaskGraphInterfaces.h:482
FNamedTaskThread::ProcessTasksNamedThread(int, bool) TaskGraph.cpp:779
FNamedTaskThread::ProcessTasksUntilQuit(int) TaskGraph.cpp:667
FRHIThread::Run() RenderingThread.cpp:269
FRunnableThreadWin::Run() WindowsRunnableThread.cpp:156
FRunnableThreadWin::GuardedRun() WindowsRunnableThread.cpp:71
<unknown> 0x00007ff9c762e8d7
<unknown> 0x00007ff9c845fbcc

Have Comments or More Details?

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

0
Login to Vote

Unresolved
ComponentUE - Rendering Architecture - RHI
Affects Versions5.45.05.15.25.35.5
CreatedDec 18, 2024
UpdatedDec 18, 2024
View Jira Issue