Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

How to create a "dynamic" buffer?

$
0
0
I have a vertex buffer on a default heap. I need a CPU pointer to that buffer in order to loop through the vertices and change one value in some vertices (the color value). In the past this was possible by creating the buffer with the flag D3DUSAGE_DYNAMIC/D3D11_USAGE_DYNAMIC and using IDirect3DVertexBuffer9::Lock or ID3D11DeviceContext::Map to get a pointer. What is the correct way to do the same in DX 12? As far as I understand, the method ID3D12Resource::Map cannot be used on a default heap because default heaps cannot be accessed directly from the CPU. The documentation says that upload heaps are intended for CPU-write-once, GPU-read-once usage, so I don't think these are equivalent to the "dynamic" buffers. Is the readback heap equivalent to what was called a dynamic buffer? Or should I create a custom heap? I am thinking to do the following: -Create a temporary readback heap. -Copy the data from the default heap to the readback heap using UpdateSubresources. -Get a CPU pointer to the readback heap using Map and edit the data. -Copy the data back to the default heap using UpdateSubresources. What do you think about this?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>