rate up
1
rate down
What's the reason for the D3D12_ROOT_PARAMETER's DescriptorTable.NumDescriptorRanges
Per iedoc's request, re-posting the question here from tutorial .[/viewtutorial/q16390-directx-12-constant-buffers-root-descriptor-tables][#08]. What I don't get is why can we specify: D3D12_DESCRIPTOR_RANGE ranges[2]; rootParamater[0].DescriptorTable.NumDescriptorRanges = 2; rootParamater[0].DescriptorTable.pDescriptorRanges = ranges; .. when commandList->SetGraphicsRootDescriptorTable( 1, ...) throws an error because it works based on PARAMETER index, not RANGE index. It seems there is no way to bind the handle for "range[1]" to a command list unless you go: D3D12_DESCRIPTOR_RANGE ranges[2]; rootParamater[0].DescriptorTable.NumDescriptorRanges = 1; rootParamater[0].DescriptorTable.pDescriptorRanges = &ranges[0]; rootParamater[1].DescriptorTable.NumDescriptorRanges = 1; rootParamater[1].DescriptorTable.pDescriptorRanges = &ranges[1]; .. i.e. 1x range MUST be in its own discrete parameter. This seems retarded? Why have ranges at all? Why not just put the range data at the root parameter scope? Every example I've seen always specifies 1x range entry in the params, so I don't understand what NumDescriptorRanges was for. What am I missing. Any ideas?
rate up
0
rate down
I'll assume you have a good understanding of the resource binding model and the root signature for DX12 other than why you might put multiple ranges in a descriptor table. This has to do with the way graphics API's are trying to closer match what the hardware is actually doing. Part of this is binding resources in batches rather than individual resources. So since binding resource lists rather than individual resources is a goal in the design, descriptor tables allow you to specify multiple ranges so that you can update resource "lists" of the same frequency together, in a single call. On top of that, root signature space is limited, so being able to bind more in one parameter keeps the root signature space open for more frequently changed resources. binding a single range per root parameter (descriptor table only has one range) is a perfectly fine way to go, but being able to create a descriptor table with multiple ranges is just added flexibility for when the data the ranges point to change at the same frequency, which would allow you to save cpu cycles and root parameter space. You might have one range for CBV's and another for SRV's, where each CBV describes a light, and the SRV's have some kind of data that the shaders use, maybe you are projecting an image from a spot light and the srv is the image the spot light is projecting. This way you can bind all this data at one time rather than individually, and save a root parameter slot. That was just an example. Hope that helps clarify why ranges is an array in a descriptor table~
Sign in to answer!