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

# CreateRenderTargetView

> 创建用于访问资源数据的渲染目标视图。(ID3D12Device.CreateRenderTargetView)

创建用于访问资源数据的渲染目标视图。

## 语法

```cpp theme={null}
void CreateRenderTargetView(
    ID3D12Resource  pResource,
    const D3D12_RENDER_TARGET_VIEW_DESC  pDesc,
    D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor
)
```

### 参数

*pResource \[in, optional]*\
类型：ID3D12Resource \*

指向表示渲染目标的 [ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs) 对象的指针。

必须提供 <i>pResource</i> 或 <i>pDesc</i> 中的至少一个。
使用空的 <i>pResource</i> 来初始化空描述符，这将保证类似 D3D11 的空绑定行为（读取 0，写入被丢弃），但必须具有有效的 <i>pDesc</i> 才能确定描述符类型。

*pDesc \[in, optional]*\
类型：const D3D12\_RENDER\_TARGET\_VIEW\_DESC \*

指向描述渲染目标视图的 [D3D12\_RENDER\_TARGET\_VIEW\_DESC](/reference/graphics/d3d12/structs/d3d12_render_target_view_desc_public) 结构体的指针。

如果可能，使用空的 <i>pDesc</i> 来初始化默认描述符。此行为与 D3D11 空描述符行为相同，其中会填入默认值。此行为继承资源格式和维度（如果不是无类型），并且 RTV 面向第一个 mip 和所有数组切片。并非所有资源都支持空描述符初始化。

*DestDescriptor \[in]*\
类型：D3D12\_CPU\_DESCRIPTOR\_HANDLE

描述表示新创建的渲染目标视图将驻留的目标位置的 CPU 描述符句柄。

### 返回值

类型：void

无。

## 要求

**头文件：** d3d12\_xs.h 或 d3d12\_x.h\
**库：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支持的平台**：XBOX Series 主机和 XBOX One 系列

## 另请参阅

[ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)


## Related topics

- [D3D12_RENDER_TARGET_VIEW_DESC](/zh-CN/reference/graphics/d3d12/structs/d3d12_render_target_view_desc_public.md)
- [D3D12_CPU_DESCRIPTOR_HANDLE](/zh-CN/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public.md)
- [D3D12_RTV_DIMENSION](/zh-CN/reference/graphics/d3d12/enums/d3d12_rtv_dimension_public.md)
- [OMSetRenderTargets](/zh-CN/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_omsetrendertargets_public.md)
- [D3D12_VIEW_INSTANCE_LOCATION](/zh-CN/reference/graphics/d3d12/structs/d3d12_view_instance_location_public.md)
