Function copySubresourceRegion

Synopsis

#include <Source/Falcor/Core/API/CopyContext.h>

void copySubresourceRegion(const Texture *pDst, uint32_t dstSubresource, const Texture *pSrc, uint32_t srcSubresource, const uint3 &dstOffset=uint3(0), const uint3 &srcOffset=uint3(0), const uint3 &size=uint3(-1))

Description

Copy a region of a subresource from one texture to another srcOffset, dstOffset and size describe the source and destination regions. For any channel of extent that is -1, the source texture dimension will be used

Source

Lines 315-342 in Source/Falcor/Core/API/D3D12/D3D12CopyContext.cpp. Line 108 in Source/Falcor/Core/API/CopyContext.h.

void CopyContext::copySubresourceRegion(const Texture* pDst, uint32_t dstSubresource, const Texture* pSrc, uint32_t srcSubresource, const uint3& dstOffset, const uint3& srcOffset, const uint3& size)
{
    resourceBarrier(pDst, Resource::State::CopyDest);
    resourceBarrier(pSrc, Resource::State::CopySource);
    D3D12_TEXTURE_COPY_LOCATION dstLoc = {};
    dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
    dstLoc.SubresourceIndex = dstSubresource;
    dstLoc.pResource = pDst->getApiHandle();
    D3D12_TEXTURE_COPY_LOCATION srcLoc = {};
    srcLoc.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
    srcLoc.SubresourceIndex = srcSubresource;
    srcLoc.pResource = pSrc->getApiHandle();
    D3D12_BOX box;
    box.left = srcOffset.x;
    box.top = srcOffset.y;
    box.front = srcOffset.z;
    uint32_t mipLevel = pSrc->getSubresourceMipLevel(dstSubresource);
    box.right = (size.x == -1) ? pSrc->getWidth(mipLevel) - box.left : size.x;
    box.bottom = (size.y == -1) ? pSrc->getHeight(mipLevel) - box.top : size.y;
    box.back = (size.z == -1) ? pSrc->getDepth(mipLevel) - box.front : size.z;
    mpLowLevelData->getCommandList()->CopyTextureRegion(&dstLoc, dstOffset.x, dstOffset.y, dstOffset.z, &srcLoc, &box);
    mCommandsPending = true;
}





Add Discussion as Guest

Log in to DocsForge