How to set barriers for external texture?

Hello Unreal Engine Support Team!

While investigating possible reasons for GPU crash in FSR4 Upscaling, which I cannot reproduce locally, I have noticed that barriers synchronization between UE rendering code and external FSR dispatch is missing.

Below is snippet with the code I am trying to fix. As I understand RGD should insert barriers to transit all textures in PassParameters to state declared in shader parameter struct then we use ApiAccess->GetNativeResource to let FSR know current state of of the resources.

Unfortunately RDG doesn’t introduce such barriers (I have verified this via -d3ddebug -gpuvalidation and renderdoc).

I have also tried to add GraphBuilder.UseExternalAccessMode(MotionVectorTexture, ERHIAccess::SRVMask); before FidelityFX-FSR4 AddPass or RHICmdList.Transition(FRHITransitionInfo(PassParameters->VelocityTexture->GetRHI(), ERHIAccess::UAVCompute, ERHIAccess::SRVCompute)); inside AddPass, but still barriers were not added by RDG.

I was able to workaround this by setting different expected value to FSR API, but this solution is not reliable as I have to guess what passes would run before FSR.

My question is how do I add state transition for RDG textures, so they would match the states external API expects?

My environment is Windows 11 DX12.

// PassParameters decalaration with ERHIAccess
struct FFXFSR4Pass
{
	BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
		RDG_TEXTURE_ACCESS(ColorTexture, ERHIAccess::SRVMask)
		RDG_TEXTURE_ACCESS(DepthTexture, ERHIAccess::SRVMask)
		RDG_TEXTURE_ACCESS(VelocityTexture, ERHIAccess::SRVMask)
		RDG_TEXTURE_ACCESS(ExposureTexture, ERHIAccess::SRVMask)
		RDG_TEXTURE_ACCESS(ReactiveMaskTexture, ERHIAccess::SRVMask)
		RDG_TEXTURE_ACCESS(CompositeMaskTexture, ERHIAccess::SRVMask)
		RDG_TEXTURE_ACCESS(OutputTexture, ERHIAccess::UAVMask)
	END_SHADER_PARAMETER_STRUCT()
};
 
 
// In FSR Uplscaler
	GraphBuilder.AddPass(RDG_EVENT_NAME("FidelityFX-FSR4"), PassParameters, ERDGPassFlags::Compute | ERDGPassFlags::Raster | ERDGPassFlags::SkipRenderPass, [&View, &PassInputs, CurrentApi, ApiAccess, PassParameters, PrevCustomHistory, Fsr4DispatchParamsPtr, FSR4State, ConfigureUpscalerKeyValues](FRHICommandListImmediate& RHICmdList)
	{
 
		DispatchParams.color = ApiAccess->GetNativeResource(PassParameters->VelocityTexture->GetRHI(), FFX_API_RESOURCE_STATE_COMPUTE_READ);
		//...
		//External rendering code dispatch              
		ApiAccess->ffxDispatch(&FSR4State->Fsr4, &DispatchParams.header);

[Attachment Removed]

Steps to Reproduce
Start game build with UE5.5.4 with command line arguments -d3ddebug -gpuvalidation and FSR4 upscaling active.

Environment: Windows 11 DX12.

[Attachment Removed]

Hey, I think D3D12 in 5.5 was still using implicit barriers, so it just ignores RDG entirely. RDG is definitely issuing the barrier (that code is quite battle tested at this point). D3D12 transitions resources on demand internally. Look for FD3D12CommandContext::TransitionResource. You’ll need to issue it inside of a RHICmdList.ExecuteLambda(…) call. Alternatively, you’ll need to barrier inside of ffxDispatch.

[Attachment Removed]