How to pass AppendStructuredBuffer<> to my compute shader & read it back (or, after dispatch, convert to StructuredBuffer for another shader to pass directly without reading back in CPU)?
Here is what I’ve achieved so far:
class My_CS : FGlobalShader
...
SHADER_PARAMETER_UAV(AppendStructuredBuffer<float3>, appendParam)
...
Dispatching shader:
...
FRHIResourceCreateInfo Info(TEXT("appendParam"));
FBufferRHIRef Buffer = RHICreateStructuredBuffer(sizeof(float3), sizeof(float3) , BUF_UnorderedAccess | BUF_ShaderResource, ERHIAccess::UAVMask, Info);
...
My_CS::FParameters params;
params.appendBuffer = RHICreateUnorderedAccessView(Buffer, false, true);
FComputeShaderUtils::Dispatch( ....
compute shader for append:
...
AppendStructuredBuffer<float3> appendParam;
[numthreads(N, N, N)]
void MainFrustumCullShader(uint3 GroupId : SV_GroupID)
{
float3 data = ... read data from ...
appendParam.Append(data);
}
I can pass RWStructuredBuffer<> to compute shader & read back in CPU or pass to antoher compute shader directly. But AppendStructuredBuffer seems to have no data and no error/crash is thrown when executing
Thanks!