Fix BinkMediaTextureResource command list crash on UE 5.6

Bink will create textures without a required UAV access flag. Upon finding the crash and logging the command list resource barriers, we’ll see something like this:

BARRIER (CmdList: 0000021089DEF230, Queue: 3D) 3/3: Bink:BK_IntroPlayer_Tex 00000210A1DA4AB0 (Sub: 4294967295), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE -> D3D12_RESOURCE_STATE_RENDER_TARGET

LogRHI: Error: Incompatible Transition State for Resource Bink:BK_IntroPlayer_Tex - D3D12_RESOURCE_STATE_UNORDERED_ACCESS requires D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.

One way to fix this is to modify FBinkMediaTextureResource::InitRHI to include UAV.

const FRHITextureCreateDesc Desc = FRHITextureCreateDesc::Create2D(DebugName) .SetExtent(w, h) .SetFormat(PixelFormat) // FIX Add UAV access flag .SetFlags(TexCreateFlags | ETextureCreateFlags::RenderTargetable | ETextureCreateFlags::ShaderResource | ETextureCreateFlags::UAV) // FIX .SetInitialState(ERHIAccess::SRVMask);

Steps to Reproduce
Import a Bink-encoded movie and play it through a FBinkMediaTextureResource. As soon as the texture resource is refreshed on load and the next FlushRenderingCommands happens, FD3D12CommandList::Close will crash with ID3D12GraphicsCommandList::Close returning E_INVALIDARG

Observed callstack in this crash:

[Inlined] UE::Logging::Private::BasicFatalLogV(const FLogCategoryBase &, const UE::Logging::Private::FStaticBasicLogRecord *, void *, char *) StructuredLog.cpp:1600

UE::Logging::Private::BasicFatalLog(const FLogCategoryBase &,const UE::Logging::Private::FStaticBasicLogRecord *,…) StructuredLog.cpp:1609

[Inlined] FD3D12DynamicRHI::HandleFailedD3D12Result::__l2::<lambda_1>::operator()(bool) D3D12Util.cpp:1014

FD3D12DynamicRHI::HandleFailedD3D12Result(HRESULT, ID3D12Device *, bool, const wchar_t *) D3D12Util.cpp:1076

D3D12RHI::VerifyD3D12Result(HRESULT, const char *, const char *, unsigned int, ID3D12Device *, FString) D3D12Util.cpp:1088

FD3D12CommandList::Close() D3D12CommandList.cpp:278

[Inlined] FD3D12ContextCommon::CloseCommandList() D3D12CommandContext.cpp:435

FD3D12CommandContext::CloseCommandList() D3D12CommandContext.cpp:446

[Inlined] FD3D12BindlessResourceManager::FinalizeContext(FD3D12CommandContext &) D3D12BindlessDescriptors.cpp:555

[Inlined] FD3D12BindlessDescriptorManager::FinalizeContext(FD3D12CommandContext &) D3D12BindlessDescriptors.cpp:839

FD3D12CommandContext::Finalize(TArray<…> &) D3D12CommandContext.cpp:512

[Inlined] FD3D12DynamicRHI::RHIFinalizeContext::__l2::<lambda_1>::operator()(FD3D12CommandContext *, FD3D12FinalizedCommands &) D3D12Submission.cpp:225

FD3D12DynamicRHI::RHIFinalizeContext(FDynamicRHI::FRHIFinalizeContextArgs &&, TRHIPipelineArray<…> &) D3D12Submission.cpp:253

`FRHICommandListExecutor::FTranslateState::Finalize’::`2’::<lambda_1>::operator()() RHICommandList.cpp:1148

[Inlined] UE::Core::Private::Function::TFunctionRefBase::operator()() Function.h:471

FRHICommandListExecutor::FTaskPipe::Execute(FRHICommandListExecutor::FTaskPipe::FTask *, const TRefCountPtr<…> &) RHICommandList.cpp:722

[Inlined] UE::Core::Private::Function::TFunctionRefBase::operator()(Type, const TRefCountPtr<…> &) Function.h:471

[Inlined] TFunctionGraphTaskImpl::DoTaskImpl(TUniqueFunction<…> &, Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1123

[Inlined] TFunctionGraphTaskImpl::DoTask(Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1104

TGraphTask::ExecuteTask() TaskGraphInterfaces.h:706

UE::Tasks::Private::FTaskBase::TryExecuteTask() TaskPrivate.h:527

[Inlined] FBaseGraphTask::Execute(TArray<…> &, Type, bool) TaskGraphInterfaces.h:505

FNamedTaskThread::ProcessTasksNamedThread(int, bool) TaskGraph.cpp:779

FNamedTaskThread::ProcessTasksUntilQuit(int) TaskGraph.cpp:667

FRHIThread::Run() RenderingThread.cpp:270

FRunnableThreadWin::Run() WindowsRunnableThread.cpp:156

FRunnableThreadWin::GuardedRun() WindowsRunnableThread.cpp:71

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into this crash for you.

Can you please send us a minimal test project that demonstrates the crash?

The guide for test projects: [Content removed]

Hi, Stephen!

Thanks for the response! Reproducing the crash is very simple: Create a Bink Media Player asset and open it. After saving and compiling the asset, the editor should crash with a stack like the one above.

I’ve included a fix in this ticket (see changes to FBinkMediaTextureResource), but let me know if there is a different way you’d prefer this to be patched.

Thanks!

D’

Hello,

Thank you for the extra information and for reporting this.

I can confirm this issue can be reproduced as described in the latest CL, and have opened a bug report:

The tracker will be visible after it is approved internally at Epic Games and is publicly accessible.

If you have any further questions, please let us know.