• Advertisement
Sign in to follow this  

[D3D12] Create anything anywhere?

This topic is 965 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

D3D12

 

Forgetting performance, it seems (at least to me) to be possible to create anything anywhere.  A index buffer in system memory rather than graphic local memory or to use D3D12 terminology, an index buffer in POOL_L0 rather than POOL_L1.  Am I reading things wrong or can you create anything anywhere?  Or is this GPU/driver dependent?  So if I wanted to create a default heap in POOL_L0 create a placed resource (lets say index buffer) in said heap and render from it there would be no problem right?

Share this post


Link to post
Share on other sites
Advertisement

A Default heap can only read and write on the GPU side. The CPU cannot see that memory. This is the faster because the memory is right then and there on the Graphics card.

A Upload heap the CPU can write to it but not read, and the GPU can read from it but not write to it. This is slow because the GPU will have to marshalled over everytime it needs that data.

A ReadBack heap allows the CPU to read the Data. This is even slower because the CPU needs to request the data from GPU which in terms will write the data to some piece of memory which the CPU can safely read from. This can be used for when you are dealing with Video Capture for example.

 

So at the end of the day, yes you can create things anywhere you want depeneding on what you are trying to achieve and how do you want to access that data.

Share this post


Link to post
Share on other sites


A Default heap can only read and write on the GPU side. The CPU cannot see that memory. This is the faster because the memory is right then and there on the Graphics card.

If you look at the D3D12_HEAP_PROPERTIES structure used to create heaps you can specify a type and a memory pool preference at the same time.  This leads me to believe that you can have a default heap in non-gpu local memory.  This is what I'm asking about.

Share this post


Link to post
Share on other sites

Forgetting performance, it seems (at least to me) to be possible to create anything anywhere.

Yes. Performance is the big main concern.
However if you request too much memory of the wrong type (i.e. CPU and GPU visible) you may find yourself running out of it very quickly due to hardware limitations.

would be no problem right?

Don't push it. Follow recommendations.
D3D12 will allow you to do anything, it doesn't mean it will work on all GPUs. You will get no warning whatsoever.
D3D12's documentation itself states heaps of type D3D12_HEAP_TYPE_READBACK must stay in D3D12_RESOURCE_STATE_COPY_DEST; which in plain english it means not all GPUs may be able to use it as a direct source for, say, vertex buffers (since it should be in STATE_VERTEX_AND_CONSTANT_BUFFER)

Share this post


Link to post
Share on other sites


However if you request too much memory of the wrong type (i.e. CPU and GPU visible) you may find yourself running out of it very quickly due to hardware limitations.

Could you elaborate on this?  I thought as long as you stay in the "budget" of a particular memory pool you'd be alright.  I.E. IDXGIAdapter3::QueryVideoMemoryInfo method with DXGI_MEMORY_SEGMENT_GROUP set to DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL.

 


Don't push it. Follow recommendations.

I didn't see any recommendations in this case, that's why I asked here.  The only thing to go on is common sense in regards to memory bandwidth, but I've been thinking about streaming content, and acceptable perfomance for subsections of rendering which is why I wanted to know if it is possible and if there are limitations based on video card/drivers.

Share this post


Link to post
Share on other sites
Yes you can specify the location but if you try to use an upload heap or read back in L1 it will fail.

Share this post


Link to post
Share on other sites

However if you request too much memory of the wrong type (i.e. CPU and GPU visible) you may find yourself running out of it very quickly due to hardware limitations.

Could you elaborate on this?  I thought as long as you stay in the "budget" of a particular memory pool you'd be alright.  I.E. IDXGIAdapter3::QueryVideoMemoryInfo method with DXGI_MEMORY_SEGMENT_GROUP set to DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL.

Pools aren't the end of it. Visibility flags are important. CPUPageProperty can be write back, write combined, or none.
Memory in L0 with write back CPU flags can be a limited resource in NUMA systems.
Write combined L0 memory is normally fine, but unreasonable large quantities of it can decrease performance, saturate the PCIe, or trigger HW flaws in the motherboard (basically it's the same as if you extremely abuse DYNAMIC buffers in D3D11).
 

Don't push it. Follow recommendations.

I didn't see any recommendations in this case, that's why I asked here.

Well... you put "performance aside". Just start considering performance. Keep most of your data (i.e. static) in Default, data that changes every frame on Upload, data that changes infrequently stash it in Upload then immediately transfer to a Default heap, use Readback to read from GPU.
You know... what the name implies biggrin.png

Note the difference between reading directly from the Upload heap instead of trying to copy from Upload to Default then using the data, is that in the latter, if you submit the copy operation as soon as possible, on certain dedicated GPUs a DMA engine will begin the transfer asynchronously. While on integrated GPUs the fastest option will (almost?) always be to read directly from Upload.
 

The only thing to go on is common sense in regards to memory bandwidth, but I've been thinking about streaming content, and acceptable perfomance for subsections of rendering which is why I wanted to know if it is possible and if there are limitations based on video card/drivers.

Oh sure, you can read directly from an Upload heap, or place it in a heap in and copy to a Default heap.
Note that Upload heaps must stay as D3D12_RESOURCE_STATE_GENERIC_READ, so for example, you can't use that heap for say... destination for resolving an MSAA RTT (see the that generic_read is just a bitmask with the flags you're allowed to use).

My reaction was because some people just go and try to do crazy stuff because they're just allowed to. Edited by Matias Goldberg

Share this post


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

  • Advertisement