Graphics Reference
In-Depth Information
Copy Subresource Region
The next technique for copying resources is the device context's CopySubresourceRegion()
method. This method allows a portion of a resource to be copied, as opposed to always
copying the complete resource, as is required in the CopyResource() method described
above. Listing 2.53 shows the prototype of the method.
void CopySubresourceRegion(
ID3D11Resource *pDstResource,
UINT DstSubresource,
UINT DstX,
UINT DstY,
UINT DstZ,
ID3DllResource *pSrcResource,
UINT SrcSubresource,
const D3D11_B0X *pSrcBox
);
Listing 253. The copy subresource region method prototype.
Since this method allows copying a subset of one resource to another, the resources
do not need to have the same size. However, the two resources must have the same type,
and compatible formats. As with the source, the destination can be a subresource. This is
specified by using a zero-based subresource index in the DstSubresource parameter. In
addition, a destination offset can be specified in each of the three coordinates, to position-
ing the copied data. The source resource data is also determined with a subresource index,
and the region to be copied is determined with a D3D11_BOX selection.
The ability to selectively copy portions of a resource to another resource can be used
to create dynamic texture atlases, which combine several textures into a single larger tex-
ture. This can reduce the number of individual draw calls needed to render a scene (topics
such as these are discussed in more detail in Chapter 3).
Copy Structure Count
One final method allows copying a portion of one resource into another resource, although
this is a less direct copying technique. The device context's CopyStructureCount()
method allows copying a buffer resource's hidden counter into another resource. The
method prototype is shown in Listing 2.54.
void CopyStructureCount(
ID3DllBuffer *pDstBuffer,
UINT DstAlignedByteOffset,
ID3D11UnorderedAccessView *pSreView
);
Listing 2.54. The copy structure count method prototype.
Search WWH ::




Custom Search