Advertisement Jump to content
Sign in to follow this  

DX12 GetCopyableFootprints question

This topic is 999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I was looking at ID3D12Device::GetCopyableFootprints and d3dx12.h, and I'm trying to figure out with does GetCopyableFootprints has separate output arguments for the number of rows and the size of each row in bytes since those values are apparently already available in the D3D12_PLACED_SUBRESOURCE_FOOTPRINT array also returned by the function.



Is there any case when D3D12_SUBRESOURCE_FOOTPRINT::Height might be different than pNumRows and D3D12_SUBRESOURCE_FOOTPRINT::RowPitch is different than pRowSizeInBytes for each subresource?


Also GetCopyableFootprints takes BaseOffset as argument and then D3D12_PLACED_SUBRESOURCE_FOOTPRINT has a member called Offset that seems to be a simple copy of the argument. Again are there cases when it might be different?



inline void MemcpySubresource(
    _In_ const D3D12_MEMCPY_DEST* pDest,
    _In_ const D3D12_SUBRESOURCE_DATA* pSrc,
    SIZE_T RowSizeInBytes,
    UINT NumRows,
    UINT NumSlices)
    for (UINT z = 0; z < NumSlices; ++z)
        BYTE* pDestSlice = reinterpret_cast<BYTE*>(pDest->pData) + pDest->SlicePitch * z;
        const BYTE* pSrcSlice = reinterpret_cast<const BYTE*>(pSrc->pData) + pSrc->SlicePitch * z;
        for (UINT y = 0; y < NumRows; ++y)
            memcpy(pDestSlice + pDest->RowPitch * y,
                   pSrcSlice + pSrc->RowPitch * y,

This function in some places multiplies by pDest->RowPitch but copies RowSizeInBytes bytes which makes it look like they might be different but I'm not sure why.


And if they're different why doesn't GetCopyableFootprints also return a value like SliceSizeInBytes? Can't it also be different than pDest->SlicePitch?


Thanks in advance.


P.S. Can a moderator move this to DirectX and XNA section? Sorry

Edited by CGEngine

Share this post

Link to post
Share on other sites

just wanted to say thanks for the explanation Jesse, i've been using GetCopyableFootprints but wasn't able to figure out why the result for a 150x150 image, 4 bytes per pixel was 115,032, rather than 115,200 which is what i had figured it would be. It's because the last row doesn't have to be 256 byte aligned like the other rows!


Kinda wish the MSDN documentation for methods would explain more often the process that is used to get the results. Most of the time only the input and output of a method are explained.

Edited by iedoc

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!