# DX12 Root parameter decriptor table with a mix of range types

## Recommended Posts

Hello!

Is it possible to mix ranges of samplers and ranges of SRVs and ranges of UAVs in one root parameter descriptor table? Like so:

D3D12_DESCRIPTOR_RANGE ranges[3];
D3D12_ROOT_PARAMETER param;
param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
param.DescriptorTable.NumDescriptorRanges = 3;
param.DescriptorTable.pDescriptorRanges = ranges;

range[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
..
range[1].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV;
..
range[2].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER;
..

I wonder especially about CopyDescriptors, that will need to copy a range of D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER and a range of D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV.

Thanks if anyone knows (while I try it :))

.P

##### Share on other sites

Aaaaaand I think I have my answer:

Quote

The D3D12_ROOT_DESCRIPTOR_TABLE structure declares the layout of a descriptor table as a collection of descriptor ranges that appear one after the other in a descriptor heap. Samplers are not allowed in the same descriptor table as CBV/UAV/SRVs.

##### Share on other sites

IIRC samplers are on there own heap thats why you can't do it.

##### Share on other sites

While I'm here, I'm wondering about what exactly is CopyDesciptors doing (CopyDescriptorsSimple is... simple).

Can the number of destination and source ranges be different? E.g. is it good for gathering scattered descriptors before the draw? Like copy 10 scattered SRVs into 1 contiguous range and 5 scattered UAVs into another contiguous range? The documentation doesn't say anything.

Also, are we allowed to copy/write descriptors into a GPU visible descriptor heap from CPU (or GPU) directly, i.e. without CopyDescriptors? The descriptor heap has a CPU virtual address (pointer), the size of the descriptor is known...

Edited by pcmaster

##### Share on other sites

Yes, CopyDescriptors can do arbitrary scatter/gather. The only requirement is that the total number of descriptors specified in the source ranges and dest ranges must be equal. How they're divided among the ranges is unimportant.

You can write into GPU-visible descriptor heaps at will, either via creates or copies, but cannot copy out of them.

##### Share on other sites

Awesome, that's what I hoped

##### Share on other sites

Do not perform the copy in the back of D3D tho, some hardware may need extra processing. An example is the sampler state, the border colors are not inline but indexed in a shared table on AMD.

## Create an account

Register a new account

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631724
• Total Posts
3001903
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!