In “3D Game programming with DirectX 12”(the dragon book) chapter 13 Geometry Shader.It describes an example about using AppendStructuredBuffer and ConsumeStructuredBuffer, but there's no detailed code about this.I tried to use these kind of buffers but failed.So I wonder if it's allowed to use AppendStructuredBuffer or ConsumeStructuredBuffer in DirectX12?How to use it, how should I set rootSignature?
ConsumeStructuredBuffer<int3> gInput : register(u0);
AppendStructuredBuffer<float> gOutput : register(u1);
[numthreads(64, 1, 1)]
void CS(int3 dispatchThreadID : SV_DispatchThreadID)
{
// gOutput[dispatchThreadID.x] = length(gInput[dispatchThreadID.x]);
int3 p = gInput.Consume();
gOutput.Append(length(float3(p)));
}
I find some tips about using AppendStructuredBuffer in the official document of directx12.
It says:
The UAV format bound to this resource needs to be created with the DXGI_FORMAT_UNKNOWN format.
The UAV bound to this resource must have been created with D3D11_BUFFER_UAV_FLAG_APPEND.
So I tried to build UAV,its heap and use descriptor table.When I filling in the members of D3D12_UNORDERED_ACCESS_VIEW_DESC, I got stuck.
D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc;
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
uavDesc.Buffer.FirstElement = 0;
uavDesc.Buffer.NumElements = 64;
uavDesc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_APPEND; // ????
There's no such member of enumeration in DirectX 12.