ID3D11DeviceContext::CopySubresourceRegion Method

Copy a region from a source resource to a destination resource.

Syntax

void CopySubresourceRegion(
  [in]  ID3D11Resource *pDstResource,
  [in]  UINT DstSubresource,
  [in]  UINT DstX,
  [in]  UINT DstY,
  [in]  UINT DstZ,
  [in]  ID3D11Resource *pSrcResource,
  [in]  UINT SrcSubresource,
  [in]  const D3D11_BOX *pSrcBox
);

Parameter

  • pDstResource [in]
    Typ: ID3D11Resource*

    A pointer to the destination resource (see ID3D11Resource).

  • DstSubresource [in]
    Typ: UINT

    Destination subresource index.

  • DstX [in]
    Typ: UINT

    The x-coordinate of the upper left corner of the destination region.

  • DstY [in]
    Typ: UINT

    The y-coordinate of the upper left corner of the destination region. For a 1D subresource, this must be zero.

  • DstZ [in]
    Typ: UINT

    The z-coordinate of the upper left corner of the destination region. For a 1D or 2D subresource, this must be zero.

  • pSrcResource [in]
    Typ: ID3D11Resource*

    A pointer to the source resource (see ID3D11Resource).

  • SrcSubresource [in]
    Typ: UINT

    Source subresource index.

  • pSrcBox [in]
    Typ: const D3D11_BOX*

    A pointer to a 3D box (see D3D11_BOX) that defines the source subresources that can be copied. If NULL, the entire source subresource is copied. The box must fit within the source resource.

Rückgabewert

Returns nothing

Hinweise

The source box must be within the size of the source resource. The destination offsets, (x, y, and z) allow the source box to be offset when writing into the destination resource; however, the dimensions of the source box and the offsets must be within the size of the resource.

If the resources are buffers, all coordinates are in bytes; if the resources are textures, all coordinates are in texels. D3D11CalcSubresource is a helper function for calculating subresource indexes.

CopySubresourceRegion performs the copy on the GPU (similar to a memcpy by the CPU). As a consequence, the source and destination resources:

  • Must be different subresources (although they can be from the same resource).
  • Must be the same type.
  • Must have compatible DXGI formats (identical or from the same type group). For example, a DXGI_FORMAT_R32G32B32_FLOAT texture can be copied to an DXGI_FORMAT_R32G32B32_UINT texture since both of these formats are in the DXGI_FORMAT_R32G32B32_TYPELESS group.
  • May not be currently mapped.

CopySubresourceRegion only supports copy; it does not support any stretch, color key, blend, or format conversions. An application that needs to copy an entire resource should use ID3D11DeviceContext::CopyResource instead.

CopySubresourceRegion is an asynchronous call, which may be added to the command-buffer queue, this attempts to remove pipeline stalls that may occur when copying data. For more information about pipeline stalls, see performance considerations.

Hinweis  If you use CopySubresourceRegion with a depth-stencil buffer or a multisampled resource, you must copy the whole subresource. In this situation, you must pass 0 to the DstX, DstY, and DstZ parameters and NULL to the pSrcBox parameter. In addition, source and destination resources, which are represented by the pSrcResource and pDstResource parameters, should have identical sample count values.

Example

The following code snippet copies a box (located at (120,100),(200,220)) from a source texture into a reqion (10,20),(90,140) in a destination texture.


D3D11_BOX sourceRegion;
sourceRegion.left = 120;
sourceRegion.right = 200;
sourceRegion.top = 100;
sourceRegion.bottom = 220;
sourceRegion.front = 0;
sourceRegion.back = 1;

pd3dDeviceContext->CopySubresourceRegion( pDestTexture, 0, 10, 20, 0, pSourceTexture, 0, &sourceRegion );

Notice, that for a 2D texture, front and back are set to 0 and 1 respectively.

Anforderungen

Header

D3D11.h

Bibliothek

D3D11.lib

Siehe auch

ID3D11DeviceContext

ID3D11Resource