> ## 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](/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](/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](/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)


## Related topics

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