ID3D11DeviceContext1::ClearView method (d3d11_1.h)

Sets all the elements in a resource view to one value.

Syntax

void ClearView(
  [in]           ID3D11View       *pView,
  [in]           const FLOAT [4]  Color,
  [in, optional] const D3D11_RECT *pRect,
                 UINT             NumRects
);

Parameters

[in] pView

A pointer to the ID3D11View interface that represents the resource view to clear.

[in] Color

A 4-component array that represents the color to use to clear the resource view.

[in, optional] pRect

An array of D3D11_RECT structures for the rectangles in the resource view to clear. If NULL, ClearView clears the entire surface.

NumRects

Number of rectangles in the array that the pRect parameter specifies.

Return value

None

Remarks

ClearView works only on render-target views (RTVs), depth/stencil views (DSVs) on depth-only resources (resources with no stencil component), unordered-access views (UAVs), or any video view of a Texture2D surface. The runtime drops invalid calls. Empty rectangles in the pRect array are a no-op. A rectangle is empty if the top value equals the bottom value or the left value equals the right value.

ClearView doesn’t support 3D textures.

ClearView applies the same color value to all array slices in a view; all rectangles in the pRect array correspond to each array slice. The pRect array of rectangles is a set of areas to clear on a single surface. If the view is an array, ClearView clears all the rectangles on each array slice individually.

When you apply rectangles to buffers, set the top value to 0 and the bottom value to 1 and set the left value and right value to describe the extent within the buffer. When the top value equals the bottom value or the left value equals the right value, the rectangle is empty and a no-op is achieved.

The driver converts and clamps color values to the destination format as appropriate per Direct3D conversion rules. For example, if the format of the view is DXGI_FORMAT_R8G8B8A8_UNORM, the driver clamps inputs to 0.0f to 1.0f (+INF -> 1.0f (0XFF)/NaN -> 0.0f).

If the format is integer, such as DXGI_FORMAT_R8G8B8A8_UINT, the runtime interprets inputs as integral floats. Therefore, 235.0f maps to 235 (rounds to zero, out of range/INF values clamp to target range, and NaN to 0).

Here are the color mappings:

  • Color[0]: R (or Y for video)
  • Color[1]: G (or U/Cb for video)
  • Color[2]: B (or V/Cr for video)
  • Color[3]: A
For video views with YUV or YCbBr formats, ClearView doesn't convert color values. In situations where the format name doesn’t indicate _UNORM, _UINT, and so on, ClearView assumes _UINT. Therefore, 235.0f maps to 235 (rounds to zero, out of range/INF values clamp to target range, and NaN to 0).

Requirements

Requirement Value
Minimum supported client Windows 8 and Platform Update for Windows 7 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | UWP apps]
Target Platform Windows
Header d3d11_1.h
Library D3D11.lib

See also

ID3D11DeviceContext1