Advertisement

Heap-allocating vs Stack-allocating UpdateSubresources

Started by September 18, 2018 05:29 AM
2 comments, last by ritzmax72 6 years, 4 months ago

What it the difference between Heap-allocating, stack-allocating UpdateSubresources API for uploading data from UPLOAD heap to DEFAULT heap? 
Is it just a wrapper around plain UpdateSubresource function?
Also, I assume copying happens in GPU timeline when CommandQueue is executed, but there are two copies at work; one from system memory to UPLOAD heap and other from UPLOAD heap to DEFAULT heap.
Do both of them happen at GPU timeline or system memory data can be re-used immediately after calling UpdateSubresource?

Those functions aren't part of D3D12, they're part of D3DX12, which is open source, so you can have a peek :)
Yes, D3DX functions are just wrappers around common D3D functions.

The "normal" version requires an array of D3D12_PLACED_SUBRESOURCE_FOOTPRINT structures.
The "Heap-allocating" version creates this array for you, using HeapAlloc/HeapFree.
The "Stack-allocating" version creates this array for you on the stack, and requires you to pass in a safe maximum size as a template argument.

The "normal" version calls Map/Unmap on the UPLOAD resource and memcpy's your data into it. It then adds a series of CopyBufferRegion / CopyTextureRegion commands to your command list.

Advertisement

Thank you Hodgman. I was wondering that if we already have Map, UnMap and CopyBuffer region then why are these UpdateSubresources function required. I knew d3dx12 had wrappers but didn't quite really hit me to check the definitions there.

This topic is closed to new replies.

Advertisement