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

# D3D12_VIEW_INSTANCING_DESC

> 指定在视图实例化配置期间使用的参数。

指定在视图实例化配置期间使用的参数。

## 语法

```cpp theme={null}
typedef struct D3D12_VIEW_INSTANCING_DESC
{
    UINT ViewInstanceCount;
    const D3D12_VIEW_INSTANCE_LOCATION  pViewInstanceLocations;
    D3D12_VIEW_INSTANCING_FLAGS Flags;
} D3D12_VIEW_INSTANCING_DESC
```

### 成员

*ViewInstanceCount*\
类型：UINT

指定要使用的视图数量，最多为 D3D12\_MAX\_VIEW\_INSTANCE\_COUNT。

*pViewInstanceLocations*\
类型：const D3D12\_VIEW\_INSTANCE\_LOCATION \*

包含 **ViewInstanceCount** 个视图实例位置结构的内存位置的地址，用于指定每个视图实例的视口/裁剪矩形和渲染目标详细信息。

*Flags*\
类型：D3D12\_VIEW\_INSTANCING\_FLAGS

使用其他选项配置视图实例化。

## 备注

使用此结构在 PSO 中声明视图实例化。视图实例数量在 PSO 中设置，以便根据视图数量对整个管线进行优化。

当未在 PSO 中声明视图实例化或将 ViewInstanceCount 设置为 0 时，视图实例化处于禁用状态。禁用后，渲染的行为就像启用了视图实例化并将 ViewInstanceCount 设为 1；着色器只在 SV\_ViewID 中看到值 0，并只产生一个视图实例。这样，识别视图实例化的着色器仍可在禁用该功能的 PSO 中使用。有些适配器可能支持着色器模型 6.1（该模型公开了 SV\_ViewID），但不支持视图实例化；这些适配器必须仍能在声明 ViewInstanceCount 为 0 或 1 的 PSO 中支持将 SV\_ViewID 作为输入的着色器。

在光栅化之前的着色器可以输出无需依赖 SV\_ViewID 的 SV\_RenderTargetArrayIndex 和 SV\_ViewportArrayIndex 值。要计算用于发送图元的视口和渲染目标的最终有效索引，这些值（如果存在）将添加到 PSO 中声明的视图实例位置的 ViewportArrayIndex 和 RenderTargetArrayIndex 值上。如果计算得到的索引超出范围（即索引大于对应数组中视口或渲染目标元素的数量），则有效索引变为 0。

对于动态选择视口或渲染目标索引的着色器，应用程序可以将 PSO 中声明的所有视图实例位置设置为单个值（例如 0），以作为动态选择的 SV\_RenderTargetArrayIndex 和 SV\_ViewportArrayIndex 值所加到的统一基准索引。

## 要求

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

## 另请参阅

[核心结构](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/direct3d-12-structures)


## Related topics

- [D3D12_VIEW_INSTANCING_FLAGS](/zh-CN/reference/graphics/d3d12/enums/d3d12_view_instancing_flags_public.md)
- [D3D12_VIEW_INSTANCING_TIER](/zh-CN/reference/graphics/d3d12/enums/d3d12_view_instancing_tier_public.md)
- [D3D12_SHADER_RESOURCE_VIEW_DESC](/zh-CN/reference/graphics/d3d12/structs/d3d12_shader_resource_view_desc_public.md)
- [D3D12_UNORDERED_ACCESS_VIEW_DESC](/zh-CN/reference/graphics/d3d12/structs/d3d12_unordered_access_view_desc_public.md)
- [D3D12_CONSTANT_BUFFER_VIEW_DESC](/zh-CN/reference/graphics/d3d12/structs/d3d12_constant_buffer_view_desc_public.md)
