IDirect3DDevice9Ex::CreateDepthStencilSurfaceEx method (d3d9.h)

Creates a depth-stencil surface.

Syntax

HRESULT CreateDepthStencilSurfaceEx(
  [in]          UINT                Width,
  [in]          UINT                Height,
  [in]          D3DFORMAT           Format,
  [in]          D3DMULTISAMPLE_TYPE MultiSample,
  [in]          DWORD               MultisampleQuality,
  [in]          BOOL                Discard,
  [out, retval] IDirect3DSurface9   **ppSurface,
  [in]          HANDLE              *pSharedHandle,
  [in]          DWORD               Usage
);

Parameters

[in] Width

Type: UINT

Width of the depth-stencil surface, in pixels.

[in] Height

Type: UINT

Height of the depth-stencil surface, in pixels.

[in] Format

Type: D3DFORMAT

Member of the D3DFORMAT enumerated type, describing the format of the depth-stencil surface. This value must be one of the enumerated depth-stencil formats for this device.

[in] MultiSample

Type: D3DMULTISAMPLE_TYPE

Member of the D3DMULTISAMPLE_TYPE enumerated type, describing the multisampling buffer type. This value must be one of the allowed multisample types. When this surface is passed to IDirect3DDevice9::SetDepthStencilSurface, its multisample type must be the same as that of the render target set by IDirect3DDevice9::SetRenderTarget.

[in] MultisampleQuality

Type: DWORD

Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match.

[in] Discard

Type: BOOL

Set this flag to TRUE to enable z-buffer discarding, and FALSE otherwise. If this flag is set, the contents of the depth stencil buffer will be invalid after calling either IDirect3DDevice9::Present or IDirect3DDevice9::SetDepthStencilSurface with a different depth surface.

This flag has the same behavior as the constant, D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL, in D3DPRESENTFLAG.

[out, retval] ppSurface

Type: IDirect3DSurface9**

Address of a pointer to an IDirect3DSurface9 interface, representing the created depth-stencil surface resource.

[in] pSharedHandle

Type: HANDLE*

Reserved. Set this parameter to NULL. This parameter can be used in Direct3D 9 for Windows Vista to share resources.

[in] Usage

Type: DWORD

Combination of one or more D3DUSAGE constants which can be OR'd together. Value of 0 indicates no usage.

Return value

Type: HRESULT

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_NOTAVAILABLE, D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY.

Remarks

The memory class of the depth-stencil buffer is always D3DPOOL_DEFAULT.

Requirements

Requirement Value
Target Platform Windows
Header d3d9.h
Library D3D9.lib

See also

IDirect3DDevice9Ex