CD3DX12_DESCRIPTOR_RANGE usage in a UWP app.

Anonymous
2020-05-06T20:38:03.28+00:00
void Sample3DSceneRenderer::CreateDeviceDependentResources()  
{  
	auto d3dDevice = m_deviceResources->GetD3DDevice();  
  
	// Create a root signature with a single constant buffer slot.  
	{  
		CD3DX12_DESCRIPTOR_RANGE range;  
		CD3DX12_ROOT_PARAMETER parameter;  
  
		range.Init(D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, 0);  
		parameter.InitAsDescriptorTable(1, &range, D3D12_SHADER_VISIBILITY_VERTEX);  
  
		D3D12_ROOT_SIGNATURE_FLAGS rootSignatureFlags =  
			D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | // Only the input assembler stage needs access to the constant buffer.  
			D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS |  
			D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS |  
			D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS |  
			D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS;  
  
		CD3DX12_ROOT_SIGNATURE_DESC descRootSignature;  
		descRootSignature.Init(1, &parameter, 0, nullptr, rootSignatureFlags);  
  
		ComPtr<ID3DBlob> pSignature;  
		ComPtr<ID3DBlob> pError;  
		DX::ThrowIfFailed(D3D12SerializeRootSignature(&descRootSignature, D3D_ROOT_SIGNATURE_VERSION_1, pSignature.GetAddressOf(), pError.GetAddressOf()));  
		DX::ThrowIfFailed(d3dDevice->CreateRootSignature(0, pSignature->GetBufferPointer(), pSignature->GetBufferSize(), IID_PPV_ARGS(&m_rootSignature)));  
        NAME_D3D12_OBJECT(m_rootSignature);  
	}  

From a UWP DirectX12 skeleton application. The usage of "range.Init" has three parameters. I was looking for where the parameters are defined as to what they represent.

Here:
https://learn.microsoft.com/en-us/windows/win32/direct3d12/cd3dx12-descriptor-range1
Init contains more than three parameters in the above documentation. What do "0, 1" represent in the the range of D3D12_DESCRIPTOR_RANGE_TYPE_CBV being initialized?

Thank You!

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,196 Reputation points
    2020-05-07T03:08:00.057+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Based on the document, it mentions the init method has five parameters, but the last two already have default values, so you don't have to pass the value of the two. In this case, the '1' represents 'numDescriptors', '0' represents 'baseShaderRegister'. In addition, the CD3DX12_DESCRIPTOR_RANGE is a helper structure to enable easy initialization of a D3D12_DESCRIPTOR_RANGE1 structure, so for more information about the meaning of each parameter, you can refer to this document.

    0 comments No comments

0 additional answers

Sort by: Most helpful