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

# ID3D12GraphicsCommandList::ClearRenderTargetView

> ID3D12GraphicsCommandList::ClearRenderTargetView (XBOX Series 主機) — 將轉譯目標中的所有元素設定為一個值。

## 語法

```cpp theme={null}
void ClearRenderTargetView(
    _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView,
    _In_ const FLOAT ColorRGBA[4],
    _In_ UINT NumRects,
    _In_reads_(NumRects) const D3D12_RECT* pRects
)
```

將轉譯目標中的所有元素設定為一個值。

### 參數

*RenderTargetView \[in]*\
類型：**D3D12\_CPU\_DESCRIPTOR\_HANDLE**

指定 D3D12\_CPU\_DESCRIPTOR\_HANDLE 結構，描述代表要清除之轉譯目標堆積起點的 CPU 描述元控制代碼。

*ColorRGBA \[in]*\
類型：**const FLOAT\[4]**

4 個元件的陣列，代表要填入轉譯目標的色彩。

*NumRects \[in]*\
類型：**UINT**

<i>pRects</i> 參數所指定陣列中的矩形數目。

*pRects \[in]*\
類型：**const D3D12\_RECT**\*

資源檢視中要清除之矩形的 **D3D12\_RECT** 結構陣列。如果為 **NULL**，**ClearRenderTargetView** 會清除整個資源檢視。

### 傳回值

類型：void

無。

## 備註

**ClearRenderTargetView** 可用來初始化別名為相同堆積記憶體的資源。如需詳細資料，請參閱 CreatePlacedResource。

### XBOX 專屬注意事項

為 RectCount 傳遞 -1 值並為 pRects 參數傳遞 nullptr，將會針對特定 MSAA 轉譯目標設定啟用特殊用途的清除作業。
此特殊清除只會清除使用 DCC 但未使用片段遮罩 (FMask) 之 4x 或 8x MSAA 轉譯目標的 DCC 中繼資料表面。
此特殊清除的效果是只清除樣本 0-1，而樣本 2 及更高的樣本則保持未初始化。

### 執行階段驗證

對於浮點輸入，執行階段會將反正規化值設定為 0 (同時保留 NAN)。

驗證失敗會導致 Close 呼叫傳回 **E\_INVALIDARG**。

### 偵錯層

如果輸入色彩是反正規化值，偵錯層會發出錯誤。

如果檢視所參考的子資源不處於適當的狀態，偵錯層會發出錯誤。
對於 **ClearRenderTargetView**，狀態必須是 D3D12\_RESOURCE\_STATE\_RENDER\_TARGET。

## 需求

**標頭：** d3d12\_xs.h\
**程式庫：** d3d12\_xs.lib\
**支援的平台：** XBOX Series 主機

## 另請參閱

[ID3D12GraphicsCommandList](/zh-TW/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)


## Related topics

- [D3D12_CPU_DESCRIPTOR_HANDLE](/reference/graphics/d3d12/structs/d3d12_cpu_descriptor_handle_public.md)
- [D3D12_CLEAR_VALUE](/reference/graphics/d3d12/structs/d3d12_clear_value_public.md)
- [ClearUnorderedAccessViewFloat](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_clearunorderedaccessviewfloat_public.md)
