# 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

• 10
• 11
• 9
• 16
• 18
• ### Similar Content

• I wanted to see how others are currently handling descriptor heap updates and management.
I've read a few articles and there tends to be three major strategies :
1 ) You split up descriptor heaps per shader stage ( i.e one for vertex shader , pixel , hull, etc)
2) You have one descriptor heap for an entire pipeline
3) You split up descriptor heaps for update each update frequency (i.e EResourceSet_PerInstance , EResourceSet_PerPass , EResourceSet_PerMaterial, etc)
The benefits of the first two approaches is that it makes it easier to port current code, and descriptor / resource descriptor management and updating tends to be easier to manage, but it seems to be not as efficient.
The benefits of the third approach seems to be that it's the most efficient because you only manage and update objects when they change.
• By VietNN
Hi all,
I want to copy  just 1 mipmap level of a texture and I am doing like this:
void CopyTextureRegion( &CD3DX12_TEXTURE_COPY_LOCATION(pDstData, mipmapIndex), 0, 0, 0, &CD3DX12_TEXTURE_COPY_LOCATION(pSrcData, pLayout), nullptr ); - pDstData : is DEFAULT_HEAP, pSrcData is UPLOAD_HEAP(buffer size was get by GetCopyableFootprints from pDstData with highest miplevel), pLayout is D3D12_PLACED_SUBRESOURCE_FOOTPRINT
- I think the mipmapIndex will point the exact location data of Dest texture, but does it know where to get data location from Src texture because pLayout just contain info of this mipmap(Offset and Footprint).  (???)
- pLayout has a member name Offset, and I try to modify it but it(Offset) need 512 Alignment but real offset in Src texture does not.
So what I need to do to match the location of mip texture in Src Texture ?
@SoldierOfLight @galop1n
• By _void_
Hello!
I am wondering if there is a way to find out how many resources you could bind to the command list directly without putting them in a descriptor table.
Specifically, I am referring to these guys:
- SetGraphicsRoot32BitConstant
- SetGraphicsRoot32BitConstants
- SetGraphicsRootConstantBufferView
- SetGraphicsRootUnorderedAccessView
I remember from early presentations on D3D12 that the count of allowed resources is hardware dependent and quite small. But I would like to learn some more concrete figures.
• By lubbe75
I am trying to set up my sampler correctly so that textures are filtered the way I want. I want to use linear filtering for both min and mag, and I don't want to use any mipmap at all.
To make sure that mipmap is turned off I set the MipLevels to 1 for my textures.
For the sampler filter I have tried all kind of combinations, but somehow the mag filter works fine while the min filter doesn't seem to work at all. As I zoom out there seems to be a nearest point filter.
Is there a catch in Dx12 that makes my min filter not working?
Do I need to filter manually in my shader? I don't think so since the mag filter works correctly.
My pixel shader is just a simple texture lookup:
textureMap.Sample(g_sampler, input.uv); My sampler setup looks like this (SharpDX):