• Advertisement
Sign in to follow this  

Map a UAV Buffer?

This topic is 890 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I create a UAV Buffer, I do so by calling CreateCommittedResource with D3D12_HEAP_TYPE_DEFAULT and D3D12_RESOURCE_STATE_UNORDERED_ACCESS.  In order to load this buffer from the CPU side first, I had to create it with D3D12_HEAP_TYPE_UPLOAD and D3D12_RESOURCE_STATE_GENERIC_READ.

 

This makes sense, but it seems strange to me that there's a flag specifically for unordered access that I'm not using.  I mean, I also set D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS when creating the buffer, but I'm still concerned that I'm doing something wrong.

Does this jive with the proper way of making a UAV buffer that I can load from the CPU side and then read/write in a compute shader?

Share this post


Link to post
Share on other sites
Advertisement

You should be creating two buffers. The first is in the UPLOAD heap and marked as GENERIC_READ, this is the one you fill with data from the CPU. The second buffer lives in the DEFAULT heap type and starts life in the COPY_DEST resource state. You then get the GPU to copy from the "upload buffer" into the "default buffer" and transition the default buffer to the UNORDERED_ACCESS resource state afterwards. Once the GPU has been known to have finished the copy operation you can reclaim/delete the upload buffer or use it again for another upload.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement