directx - DX12 Descriptor Heaps management -


so after watching dx12 binding videos , reading through docs, i'm not 100% sure if understood correctly how manage heaps.

let me explain wan't achieve in application: during initialisation, i'll filling 2 heaps, 1 holding samplers , other 1 holding srv, cbv , uav. heaps contain resources application using during life time.

now starts interesting part. build root signatures, i'll using part root descriptor tables.

as know, table hold ranges, range being base shader slot, number of descriptors , other settings. let me show , example:

root parameters 0 - root_table  1 - root_table  0 root_table cbv b1 cbv b6 srv t0 srv t2  1 root_table sampler s1 sampler s4 

as shown in example, there can ranges non sequential (for example b0,b1,b2 , b3) but, during command list recording, can do:

id3d12descriptorheaps* heaps[2] = {mcbvsrvuavheap,msamplerheap}; mcmdlist->setdescriptorheaps(2,heaps);  mcmdlist->setgraphicsrootdescriptortable(0, mcbvsrvuavheapgpuhanlestart); mcmdlist->setgraphicsrootdescriptortable(1, msamplerhandlehanlestart); 

that means need have descriptors ordered in mcbvsrvuavheap , msamplerheap.

for example:

mcbvsrvuavheap  cbv cbv srv srv 

here problem me. said, i'll creating 2 big heaps resource application, but, cannot set heaps command list have other descriptors won't used!

how can handle this? need make new heap containing descriptors using?

hope explained well!

you understanding wrong. descriptor heap not immutable changing object. when bind descriptor table, in fact binding offset. swapping descriptor heaps costly operation want avoid @ cost.

the idea prepare descriptors in non gpu visible heaps ( many like, merely cpu allocated object ) , copy on demand gpu visible 1 in ring buffer fashion way copydescriptor or copydescriptorsimple.

let shader use table 2 cbvs , 2 srvs, have continuous in heap, allocate heap array of 4, heap offset, copy needed descriptors , bind setgraphicsrootdescriptortable.

one thing have careful life duration of descriptor in heap, cannot overwrite them until gpu done processing commands using them. , last, if many shader share common tables, similar root signature, can save on processing factorizing updates.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -