> ## Documentation Index
> Fetch the complete documentation index at: https://docs.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

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

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

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

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

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

![參數設為 true 時的記憶體配置](https://mintcdn.com/microsoft-4404708b/5IpvKlT-jmAaVkeY/images/nda/graphics/oms_true.png?fit=max\&auto=format\&n=5IpvKlT-jmAaVkeY\&q=85\&s=ca9a65f296f515512968ef8e99ddb20e)

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

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

![參數設為 false 時的記憶體配置](https://mintcdn.com/microsoft-4404708b/5IpvKlT-jmAaVkeY/images/nda/graphics/oms_false.png?fit=max\&auto=format\&n=5IpvKlT-jmAaVkeY\&q=85\&s=c88e0ec402d2cb0c624ed18ccc174c42)

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

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

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

### 傳回值

類型：void

無。

## 需求

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

## 另請參閱

[ID3D12GraphicsCommandList](https://docs.xbox.com/zh-TW/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs.md)


## Related topics

- [D3D12_CPU_DESCRIPTOR_HANDLE](https://docs.xbox.com/zh-TW/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public.md)
- [set_audio_render_volume](https://docs.xbox.com/zh-TW/reference/chat/gamechat2/classes/chat_user/chat_user_local/methods/chat_user_local_set_audio_render_volume.md)
- [CreateRenderTargetView](https://docs.xbox.com/zh-TW/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createrendertargetview_public.md)
- [D3D12_RENDER_PASS_RENDER_TARGET_DESC](https://docs.xbox.com/zh-TW/reference/graphics/d3d12/structs/d3d12_render_pass_render_target_desc_public.md)
- [PartyLocalChatControl::SetAudioRenderVolume](https://docs.xbox.com/zh-TW/services/playfab/multiplayer/networking/reference/classes/PartyLocalChatControl/methods/partylocalchatcontrol_setaudiorendervolume.md)
