microsoft / DirectX-Graphics-Samples

This repo contains the DirectX Graphics samples that demonstrate how to build graphics intensive applications on Windows.
MIT License
5.88k stars 2k forks source link

D3D12ExecuteIndirect: "Each triangle gets its own constant buffer per frame" #869

Open ohmaya opened 2 months ago

ohmaya commented 2 months ago

https://github.com/microsoft/DirectX-Graphics-Samples/blob/51d0c1c5e225186a279bcdf15b7dbf68745301db/Samples/Desktop/D3D12ExecuteIndirect/src/D3D12ExecuteIndirect.h#L106C8-L106C60 "// Each triangle gets its own constant buffer per frame."

https://github.com/microsoft/DirectX-Graphics-Samples/blob/51d0c1c5e225186a279bcdf15b7dbf68745301db/Samples/Desktop/D3D12ExecuteIndirect/src/D3D12ExecuteIndirect.cpp#L415

        for (UINT frame = 0; frame < FrameCount; frame++)
        {
            srvDesc.Buffer.FirstElement = frame * TriangleCount;
            m_device->CreateShaderResourceView(m_constantBuffer.Get(), &srvDesc, cbvSrvHandle);
            cbvSrvHandle.Offset(CbvSrvUavDescriptorCountPerFrame, m_cbvSrvUavDescriptorSize);
        }

Actually, it is a single m_constantBuffer, all triangles per frame get 1 SRV.

Thanks.