I am getting this error:
D3D12 ERROR: ID3D12Device::CreateUnorderedAccessView: A UnorderedAccessView cannot be created of a Resource that did not specify the D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS Flag. [ STATE_CREATION ERROR #340: CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE]
Question: What is going wrong here? I am clearly ATTEMPTING to create it with unordered access flag, right?
AeroComponent.h
TRefCountPtr<FRDGPooledBuffer> OutBuf_Shared;
AeroComponent.cpp
uint32 element_size = sizeof(FAeroForceData);
uint32 array_size = sizeof(OutData);
uint32 element_count = array_size / element_size;
EBufferUsageFlags usage =
EBufferUsageFlags::Volatile |
EBufferUsageFlags::KeepCPUAccessible |
EBufferUsageFlags::UnorderedAccess;
ERHIAccess access =
ERHIAccess::CPURead |
ERHIAccess::UAVCompute;
FRHIResourceCreateInfo CreateInfo(TEXT("Aero_OutData_Buffer"));
OutDataRHI = RHICmdList.CreateStructuredBuffer(
element_size,
array_size,
usage,
access,
CreateInfo);
FRDGBufferDesc outbuf_desc = FRDGBufferDesc::CreateStructuredDesc(element_size, element_count);
outbuf_desc.Usage = usage;
OutBuf_Shared = new FRDGPooledBuffer(OutDataRHI, outbuf_desc, OutDataRHI->GetSize() / OutDataRHI->GetStride(), OutDataRHI->GetDebugName());
Elsewhere…
FRDGBufferRef outbuf_rdg = GraphBuilder.RegisterExternalBuffer(comp->OutBuf_Shared, ERDGBufferFlags::None);
[...]
sum_target_pass = GraphBuilder.AddPass(
RDG_EVENT_NAME("Aero_SumTarget(%s)", *name),
SumParams,
ERDGPassFlags::Compute,
[SumShader, SumParams](FRHIComputeCommandList& Cmds)
{
FComputeShaderUtils::Dispatch(Cmds, SumShader, *SumParams, FIntVector3(1,1,1));
});
Again, the error i get is:
D3D12 ERROR: ID3D12Device::CreateUnorderedAccessView: A UnorderedAccessView cannot be created of a Resource that did not specify the D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS Flag. [ STATE_CREATION ERROR #340: CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE]
Which doesn’t make much sense to me since im definitely assigning that usage flag in all occasions i saw to do so.
It’s rather disconcerting though, that the FRDGPooledBuffer constructor taking an RHI buffer also needs any of the other parameters, since all of the data needed to ‘describe’ it is already in there.
Also you know, its actually NOT pooled. Its a permanent resource. But my understanding is that, this is actually still what you have to do to use GraphBuilder.
Heeeelp.