question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked FayWang-MSFT answered

CD3DX12_DESCRIPTOR_RANGE usage in a UWP app.

 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://docs.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!

windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

FayWang-MSFT avatar image
1 Vote"
FayWang-MSFT answered

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.