D3D11_SUBRESOURCE_DATA structure
Specifies data for initializing a subresource.
Syntax
typedef struct D3D11_SUBRESOURCE_DATA { const void *pSysMem; UINT SysMemPitch; UINT SysMemSlicePitch; } D3D11_SUBRESOURCE_DATA;
Members
- pSysMem
-
Type: const void*
-
Pointer to the initialization data.
- SysMemPitch
-
Type: UINT
-
The distance (in bytes) from the beginning of one line of a texture to the next line. System-memory pitch is used only for 2D and 3D texture data as it is has no meaning for the other resource types. Specify the distance from the first pixel of one 2D slice of a 3D texture to the first pixel of the next 2D slice in that texture in the SysMemSlicePitch member.
- SysMemSlicePitch
-
Type: UINT
-
The distance (in bytes) from the beginning of one depth level to the next. System-memory-slice pitch is only used for 3D texture data as it has no meaning for the other resource types.
Remarks
This structure is used in calls to create buffers (ID3D11Device::CreateBuffer) and textures (ID3D11Device::CreateTexture1D, ID3D11Device::CreateTexture2D, and ID3D11Device::CreateTexture3D). If the resource you create does not require a system-memory pitch or a system-memory-slice pitch, you can use those members to pass size information, which might help you when you debug a problem with creating a resource.
A subresource is a single mipmap-level surface. You can pass an array of subresources to one of the preceding methods to create the resource. A subresource can be 1D, 2D, or 3D. How you set the members of D3D11_SUBRESOURCE_DATA depend on whether the subresource is 1D, 2D, or 3D.
- 1D
-
You set SysMemPitch to the length of the 1D surface in bytes. pSysMem points to the start of the 1D surface. You don't need to set SysMemSlicePitch. To access a specific pixel, you use:
(const char*)pSysMem + (x * BytesPerPixel)
- 2D
-
You set SysMemPitch to the distance between any two adjacent pixels on different lines. You set SysMemSlicePitch to the size of the entire 2D surface in bytes. To access a specific pixel, you use:
(const char*)pSysMem + SysMemPitch*y + (x * BytesPerPixel)
- 3D
-
You set SysMemPitch to the distance between any two adjacent pixels on different lines. You set SysMemSlicePitch to the distance between any two adjacent 2D slices of the 3D surface. To access a specific pixel, you use:
(const char*)pSysMem + SysMemSlicePitch*d + SysMemPitch*y + (x * BytesPerPixel)
The x, y, and d values are 0-based indices and BytesPerPixel depends on the pixel format. For mipmapped 3D surfaces, the number of depth slices in each level is half the number of the previous level (minimum 1) and rounded down if dividing by two results in a non-whole number.
Requirements
|
Header |
|
|---|
See also