> ## 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.

# OMSetRenderTargets

> 設定轉譯目標和深度樣板的 CPU 描述元控制代碼。

設定轉譯目標和深度樣板的 CPU 描述元控制代碼。

## 語法

```cpp theme={null}
void OMSetRenderTargets(
    UINT NumRenderTargetDescriptors,
    const D3D12_CPU_DESCRIPTOR_HANDLE  pRenderTargetDescriptors,
    BOOL RTsSingleHandleToDescriptorRange,
    const D3D12_CPU_DESCRIPTOR_HANDLE  pDepthStencilDescriptor
)
```

### 參數

*NumRenderTargetDescriptors \[in]*\
類型：UINT

<i>pRenderTargetDescriptors</i> 陣列中的項目數 (範圍介於 0 到 **D3D12\_SIMULTANEOUS\_RENDER\_TARGET\_COUNT** 之間)。若此參數不為零，pRenderTargetDescriptors 所指向之陣列中的項目數必須等於此參數中的數字。

*pRenderTargetDescriptors \[in, optional]*\
類型：const D3D12\_CPU\_DESCRIPTOR\_HANDLE \*

指定 [D3D12\_CPU\_DESCRIPTOR\_HANDLE](/zh-TW/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public) 結構的陣列，這些結構描述代表轉譯目標描述元堆積起點的 CPU 描述元控制代碼。若此參數為 NULL 且 NumRenderTargetDescriptors 為 0，則不會繫結任何轉譯目標。

*RTsSingleHandleToDescriptorRange \[in]*\
類型：BOOL

**True** 表示傳入的控制代碼是指向 <i>NumRenderTargetDescriptors</i> 個描述元之連續範圍的指標。如果要繫結的描述元集合在記憶體中剛好已是連續的 (因此只需要第一個描述元的控制代碼)，此情況便很有用。例如，若 <i>NumRenderTargetDescriptors</i> 為 3，則記憶體配置如下：

<img src="https://mintcdn.com/microsoft-4404708b/5IpvKlT-jmAaVkeY/images/nda/graphics/oms_true.png?fit=max&auto=format&n=5IpvKlT-jmAaVkeY&q=85&s=ca9a65f296f515512968ef8e99ddb20e" alt="參數設為 true 時的記憶體配置" width="221" height="147" data-path="images/nda/graphics/oms_true.png" />

在此情況下，驅動程式會取值控制代碼，然後遞增所指向的記憶體。

**False** 表示控制代碼是 <i>NumRenderTargetDescriptors</i> 個控制代碼陣列中的第一個。false 的情況可讓應用程式一次繫結來自不同位置的描述元集合。同樣假設 <i>NumRenderTargetDescriptors</i> 為 3，則記憶體配置如下：

<img src="https://mintcdn.com/microsoft-4404708b/5IpvKlT-jmAaVkeY/images/nda/graphics/oms_false.png?fit=max&auto=format&n=5IpvKlT-jmAaVkeY&q=85&s=c88e0ec402d2cb0c624ed18ccc174c42" alt="參數設為 false 時的記憶體配置" width="228" height="222" data-path="images/nda/graphics/oms_false.png" />

在此情況下，驅動程式會取值三個預期在記憶體中彼此相鄰的控制代碼。

*pDepthStencilDescriptor \[in, optional]*\
類型：const D3D12\_CPU\_DESCRIPTOR\_HANDLE \*

[D3D12\_CPU\_DESCRIPTOR\_HANDLE](/zh-TW/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public) 結構的指標，此結構描述代表保存深度樣板描述元之堆積起點的 CPU 描述元控制代碼。若此參數為 NULL，則不會繫結任何深度樣板描述元。

### 傳回值

類型：void

無。

## 需求

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

## 另請參閱

[ID3D12GraphicsCommandList](/zh-TW/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)


## Related topics

- [D3D12_CPU_DESCRIPTOR_HANDLE](/zh-TW/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public.md)
- [CreateRenderTargetView](/zh-TW/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createrendertargetview_public.md)
- [D3D12_RENDER_PASS_RENDER_TARGET_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_render_pass_render_target_desc_public.md)
- [PartyLocalChatControl::SetAudioRenderVolume](/zh-TW/services/playfab/multiplayer/networking/reference/classes/PartyLocalChatControl/methods/partylocalchatcontrol_setaudiorendervolume.md)
- [D3D12_RENDER_TARGET_BLEND_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_render_target_blend_desc_public.md)
