The SetRenderTargets function sets render target surfaces.


PFND3D10DDI_SETRENDERTARGETS Pfnd3d10ddiSetrendertargets;

void Pfnd3d10ddiSetrendertargets(
  UINT NumViews,
  UINT ClearSlots,



hDevice [in]

A handle to the display device (graphics context).


phRenderTargetView [in]

An array of handles to the render target view objects to set. Note that some handle values can be NULL.


[in] The number of elements in the array that phRenderTargetView specifies.


[in] The number of render target slots after the number of slots that RTargets specifies to be set to NULL. This number represents the difference between the previous number of render target view objects (that is, when the Microsoft Direct3D runtime previously called SetRenderTargets) and the new number of render target view objects.

Note that the number that ClearTargets specifies is only an optimization aid because the user-mode display driver could calculate this number.


Return Value


The driver can use the pfnSetErrorCb callback function to set an error code. For more information about setting error codes, see the following Remarks section.


The user-mode display driver must set all render target surfaces and the depth stencil buffer atomically as one operation.

Although the RTargets parameter specifies the number of handles in the array that the phRenderTargetView parameter specifies, some handle values in the array can be NULL.

The range of render target surfaces between the number that RTargets specifies and the maximum number of render target surfaces that are allowed is required to contain all NULL or unbound values. The number that the ClearTargets parameter specifies informs the driver about how many bind points the driver must clear out for the current atomic operation.

If the previous call to SetRenderTargets passed a value of 2 in the RTargets parameter and the current call to SetRenderTargets passes a value of 4 in RTargets, the current call to SetRenderTargets also passes a value of 0 in the ClearTargets parameter. If the next successive call to SetRenderTargets passes a value of 1 in RTargets, the successive call also passes a value of 3 (4 - 1) in ClearTargets.

When the value of clear targets is requested during user-mode query operations, the value is the difference between the maximum number of render target surfaces and the render targets value.

The driver should not encounter any error, except for D3DDDIERR_DEVICEREMOVED. Therefore, if the driver passes any error, except for D3DDDIERR_DEVICEREMOVED, in a call to the pfnSetErrorCb function, the Microsoft Direct3D runtime will determine that the error is critical. Even if the device was removed, the driver is not required to return D3DDDIERR_DEVICEREMOVED; however, if device removal interfered with the operation of SetRenderTargets (which typically should not happen), the driver can return D3DDDIERR_DEVICEREMOVED.


Minimum supported client Available in Windows Vista and later versions of the Windows operating systems.
Target Platform Desktop
Header d3d10umddi.h (include D3d10umddi.h)

See Also