> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GetDescriptorHandleIncrementSize

> 取得指定描述元堆積類型的控制代碼遞增大小。此值通常用來將控制代碼遞增至描述元陣列中。

取得指定描述元堆積類型的控制代碼遞增大小。此值通常用來將控制代碼以正確的數量遞增至描述元陣列中。

## 語法

```cpp theme={null}
UINT GetDescriptorHandleIncrementSize(
    D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType
)
```

### 參數

*DescriptorHeapType \[in]*\
類型：D3D12\_DESCRIPTOR\_HEAP\_TYPE

[D3D12\_DESCRIPTOR\_HEAP\_TYPE](/zh-TW/reference/graphics/d3d12/enums/d3d12_descriptor_heap_type_public) 類型的值，指定要取得其控制代碼遞增大小的描述元堆積類型。

### 傳回值

類型：UINT

傳回指定描述元堆積類型的控制代碼遞增大小，包括任何必要的填補。

## 備註

此方法傳回的描述元大小會作為協助程式結構 [CD3DX12\_CPU\_DESCRIPTOR\_HANDLE](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/cd3dx12-cpu-descriptor-handle) 和 [CD3DX12\_GPU\_DESCRIPTOR\_HANDLE](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/cd3dx12-gpu-descriptor-handle) 的其中一個輸入。

#### 範例

[D3D12PredicationQueries](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) 範例使用 **ID3D12Device::GetDescriptorHandleIncrementSize** 的方式如下：

為資源建立描述元堆積。<code>m\_rtvDescriptorSize</code> 變數會儲存轉譯目標檢視描述元控制代碼遞增大小，並用於程式碼的 **Create frame resources** 區段中。

```cpp theme={null}
// Create descriptor heaps.
{
// Describe and create a render target view (RTV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {};
rtvHeapDesc.NumDescriptors = FrameCount;
rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_rtvHeap)));

// Describe and create a depth stencil view (DSV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC dsvHeapDesc = {};
dsvHeapDesc.NumDescriptors = 1;
dsvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
dsvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&dsvHeapDesc, IID_PPV_ARGS(&m_dsvHeap)));

// Describe and create a constant buffer view (CBV) descriptor heap.
D3D12_DESCRIPTOR_HEAP_DESC cbvHeapDesc = {};
cbvHeapDesc.NumDescriptors = CbvCountPerFrame * FrameCount;
cbvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
cbvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
ThrowIfFailed(m_device->CreateDescriptorHeap(&cbvHeapDesc, IID_PPV_ARGS(&m_cbvHeap)));

// Describe and create a heap for occlusion queries.
D3D12_QUERY_HEAP_DESC queryHeapDesc = {};
queryHeapDesc.Count = 1;
queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_OCCLUSION;
ThrowIfFailed(m_device->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&m_queryHeap)));

m_rtvDescriptorSize = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
m_cbvSrvDescriptorSize = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
}

// Create frame resources.
{
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart());

// Create a RTV and a command allocator for each frame.
for (UINT n = 0; n < FrameCount; n++)
{
ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_renderTargets[n])));
m_device->CreateRenderTargetView(m_renderTargets[n].Get(), nullptr, rtvHandle);
rtvHandle.Offset(1, m_rtvDescriptorSize);

ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocators[n])));
}
}

```

請參閱 [D3D12 參考中的範例程式碼](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code)。

<div class="code" />

## 需求

**標頭：** d3d12\_xs.h 或 d3d12\_x.h\
**程式庫：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支援的平台：** XBOX Series 主機和 XBOX One 系列主機

## 另請參閱

[ID3D12Device](/zh-TW/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)


## Related topics

- [GetDescriptorHandleIncrementSize](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getdescriptorhandleincrementsize_public.md)
- [D3D12_CPU_DESCRIPTOR_HANDLE](/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public.md)
- [D3D12_GPU_DESCRIPTOR_HANDLE](/reference/graphics/d3d12/structs/d3d12_gpu_descriptor_handle_public.md)
