ID3D10Texture1D::Map method (d3d10.h)
Get a pointer to the data contained in a subresource, and deny the GPU access to that subresource.
Syntax
HRESULT Map(
[in] UINT Subresource,
[in] D3D10_MAP MapType,
[in] UINT MapFlags,
[out] void **ppData
);
Parameters
[in] Subresource
Type: UINT
Index number of the subresource. See D3D10CalcSubresource for more details.
[in] MapType
Type: D3D10_MAP
Specifies the CPU's read and write permissions for 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. This flag is optional.
[out] ppData
Type: void**
Pointer to the texture resource data.
Return value
Type: HRESULT
If this function succeeds, it returns S_OK. For other restrictions, and a listing of error values that can be returned by any of the Map methods, see Remarks.
Remarks
Mapping a texture enables the CPU to directly access the underlying data in the subresource of a texture. For the method to succeed, the texture being mapped must be created with the appropriate flags (see D3D10_CPU_ACCESS_FLAG), and its specified usage (see D3D10_USAGE) must be either D3D10_USAGE_DYNAMIC or D3D10_USAGE_STAGING.
Common failures of Map methods are indicated by the following return values:
For more information about the preceding return values, see DXGI_ERROR.
Map has the following restrictions:
- A single subresource cannot be mapped multiple times; in other words, do not call Map on a subresource that is already mapped.
- Any subresource that is bound to the pipeline must be unmapped before any render operation (that is, before ID3D10Device::Draw) can be executed.
FLOAT* pTexels = (FLOAT*)pData;
for( UINT col = 0; col < width; col++ )
{
pTexels[col*4 + 0]; // Alpha
pTexels[col*4 + 1]; // Blue
pTexels[col*4 + 2]; // Green
pTexels[col*4 + 3]; // Red
}
Differences between Direct3D 9 and Direct3D 10:
Map in Direct3D 10 is analogous to resource Lock in Direct3D 9. |
Requirements
Requirement | Value |
---|---|
Target Platform | Windows |
Header | d3d10.h |
Library | D3D10.lib |