티스토리 뷰
Dx11 Ring Buffer implementation
Constant buffer related costs are show below
https://developer.nvidia.com/content/constant-buffers-without-constant-pain-0
It is hard to find PSSetConstantBuffer1 example
In pulic, Angle and CryEngine is the only one opened in public
libANGLE/renderer/d3d/d3d11/Buffer11.cpp libANGLE/renderer/d3d/d3d11/Renderer11.cpp
In case of linear allocator, possibility and idea has shown in pulic tree years ago.
Don't Throw it all Away: Efficient Buffer Management, GDC
And comment,
https://www.gamedev.net/topic/661878-vertex-buffer-efficiency/
I don't see why transient buffers should be implemented as a heap like in that presentation's "CTransientBuffer" -- it's much simpler to implement it as a ring buffer (what they call a "Discard-Free Temp Buffer").
https://github.com/Microsoft/DirectX-Graphics-Samples/issues/202
Write-no-overwrite based ring buffers have been standard practice since D3D9 for storing transient / per-frame geometry. You map with the no-overwrite flag, the driver gives you a pointer to the actual GPU memory (uncached, write-combined pages) and lets the CPU stream geometry directly into the buffer with the contract that you won't touch any data that the GPU is yet to consume.
The Direct3D 11.1 runtime, which is available starting with Windows 8, enables mapping dynamic constant buffers and shader resource views (SRVs) of dynamic buffers with D3D11_MAP_WRITE_NO_OVERWRITE. The Direct3D 11 and earlier runtimes limited mapping to vertex or index buffers.
Basic steps in deferred context:
- Map at initial frame
- Simply memcpy at that address and append it (256 byte align is needed)
- set Partial buffer using PSSetConstantBuffers1
- Before commend list execute, unmap that buffer
https://gist.github.com/newpolaris/df4ad02ff593008fac88c7c46458c340
Note that FirstConstant and NumConstannts are divided by 16 (because default unit is 16 byte)
You can see details in DX12 mini engine - LinearAllocator (also 256 byte align, page manager, etc )
- Total
- Today
- Yesterday