DirectX 12 - Descriptor heaps

孤街浪徒 提交于 2019-12-06 05:36:19

The idea with descriptor heaps is to have a big gpu visible one, and a bunch of cpu visible ones. it is because SetDescriptorHeaps is a costly operation, you do not want to call it more than once or twice a frame.

You need to use the big gpu visible heap as a ring buffer, allocating room for the current draw or dispatch you want to prepare and copy from the various cpu visible descriptors you have for it. You can have as many cpu visible descriptor heaps you want, it is more or less just a regular allocation wrap into a d3d object.

The copy does not have any life time protection and is perform instantly by the cpu, be careful to not roll over a descriptor that may still be in use on the GPU.

I am talking about SRV and samplers here. RTV are only CPU visible, and you are free to create as many descriptor heaps as you want, one per descriptor if you like and don't care much from the d3d object overhead, it will have no performance implication on the runtime.

One thing to keep in mind is that descriptor memory is nearly unlimited, most projects I know have descriptor heaps that are up to 1024 descriptors in size. Not to mention directx 11 would allocate up to 128 descriptors for each individual shader. So feel no worries to just allocate a bunch of descriptors up front. However if you really want to budget every aspect of the memory I would recommend structuring your engine in a way that can know the individual parameters of every mesh and shader that is going to be rendered in a scene.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!