> ## 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-TW/reference/graphics/d3d12/enums/d3d12_view_instancing_flags_public.md)
- [D3D12_VIEW_INSTANCING_TIER](/zh-TW/reference/graphics/d3d12/enums/d3d12_view_instancing_tier_public.md)
- [D3D12_SHADER_RESOURCE_VIEW_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_shader_resource_view_desc_public.md)
- [D3D12_DEPTH_STENCIL_VIEW_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_depth_stencil_view_desc_public.md)
- [D3D12_UNORDERED_ACCESS_VIEW_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_unordered_access_view_desc_public.md)
