ID3D10Buffer::Map method (d3d10.h)

Get a pointer to the data contained in the resource and deny GPU access to the resource.

Syntax

HRESULT Map(
  [in]  D3D10_MAP MapType,
  [in]  UINT      MapFlags,
  [out] void      **ppData
);

Parameters

[in] MapType

Type: D3D10_MAP

Flag that specifies the CPU's permissions for the reading and writing of a resource. For possible values, see D3D10_MAP.

[in] MapFlags

Type: UINT

Flag that specifies what the CPU should do when the GPU is busy (see D3D10_MAP_FLAG). This flag is optional.

[out] ppData

Type: void**

Pointer to the buffer resource data.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. The following list contains some of the reasons that Map can fail:

  • If MapFlags specifies D3D10_MAP_FLAG_DO_NOT_WAIT and the GPU is not yet finished with the resource, ID3D10Buffer::Map returns DXGI_ERROR_WAS_STILL_DRAWING.
  • ID3D10Buffer::Map returns DXGI_ERROR_DEVICE_REMOVED if MapType includes any flags that permit reading and the hardware device (that is, the video card) has been removed.
For more information about the preceding return values, see DXGI_ERROR.

Remarks

For the CPU to write the contents of a resource, the resource must be created with the dynamic usage flag, D3D10_USAGE_DYNAMIC. To both read and write those contents, the resource must be created with the staging usage flag, D3D10_USAGE_STAGING. (For more information about these flags, see D3D10_USAGE.) ID3D10Buffer::Map will retrieve a pointer to the resource data. For a discussion on how to access resources efficiently, see Copying and Accessing Resource Data (Direct3D 10).

Call ID3D10Buffer::Unmap to signify that the application has finished accessing the resource.

ID3D10Buffer::Map has a few other restrictions. For example:

  • The same buffer cannot be mapped multiple times; in other words, do not call ID3D10Buffer::Map on a buffer that is already mapped.
  • Any buffer that is bound to the pipeline must be unmapped before any rendering operation (that is, ID3D10Device::Draw) can be executed.
Differences between Direct3D 9 and Direct3D 10:

ID3D10Buffer::Map in Direct3D 10 is analogous to resource Lock in Direct3D 9.

Requirements

Requirement Value
Target Platform Windows
Header d3d10.h
Library D3D10.lib

See also

ID3D10Buffer Interface