Everything works correctly, but Pix shows the descriptor as invalid.
I'm getting not debug layer warnings.
auto& [res, srv, uav] = pingpongs[i];
{
auto desc = CD3DX12_RESOURCE_DESC::Buffer(PINGPONG_BYTES, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
device->CreateCommittedResource(
&heap_default, D3D12_HEAP_FLAG_NONE, &desc,
D3D12_RESOURCE_STATE_COMMON,
nullptr, IID_PPV_ARGS(res.put()));
res->SetName(std::format(L"ComputeEngine::m_fft_ping_pong{}", i).c_str());
}
{
auto [cpu, gpu] = allocator.Allocate();
D3D12_SHADER_RESOURCE_VIEW_DESC desc{};
#if 1
desc.Format = DXGI_FORMAT_R32G32_FLOAT;
desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
desc.Buffer.NumElements = PINGPONG_ELEMENTS;
#else
desc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
desc.Buffer.NumElements = PINGPONG_ELEMENTS;
desc.Buffer.StructureByteStride = 8U;
#endif
device->CreateShaderResourceView(res.get(), &desc, cpu );
srv = gpu;
}
{
auto [cpu, gpu] = allocator.Allocate();
D3D12_UNORDERED_ACCESS_VIEW_DESC desc{};
#if 1
desc.Format = DXGI_FORMAT_R32G32_FLOAT;
desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
desc.Buffer.NumElements = PINGPONG_ELEMENTS;
#else
desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
desc.Buffer.NumElements = PINGPONG_ELEMENTS;
desc.Buffer.StructureByteStride = 8U;
#endif
device->CreateUnorderedAccessView(res.get(), nullptr, &desc, cpu);
uav = gpu;
}
The structure binding was in the wrong order causing the uav/srv descriptors to be swapped
auto& [res, uav, srv] = pingpongs[i];