> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GetCopyableFootprints

> Gets a resource layout that can be copied. Helps the app fill-in D3D12_PLACED_SUBRESOURCE_FOOTPRINT and D3D12_SUBRESOURCE_FOOTPRINT when suballocating space.

Gets a resource layout that can be copied.
Helps the app fill-in
[D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public) and
[D3D12\_SUBRESOURCE\_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_subresource_footprint_public) when suballocating space in upload heaps.

## Syntax

```cpp theme={null}
void GetCopyableFootprints(
    const D3D12_RESOURCE_DESC  pResourceDesc,
    UINT FirstSubresource,
    UINT NumSubresources,
    UINT64 BaseOffset,
    D3D12_PLACED_SUBRESOURCE_FOOTPRINT  pLayouts,
    UINT  pNumRows,
    UINT64  pRowSizeInBytes,
    UINT64  pTotalBytes
)
```

### Parameters

*pResourceDesc \[in]*\
Type: const D3D12\_RESOURCE\_DESC \*

A description of the resource, as a pointer to a [D3D12\_RESOURCE\_DESC](/reference/graphics/d3d12/structs/d3d12_resource_desc_public) structure.

*FirstSubresource \[in]*\
Type: UINT

Index of the first subresource in the resource.
The range of valid values is 0 to D3D12\_REQ\_SUBRESOURCES.

*NumSubresources \[in]*\
Type: UINT

The number of subresources in the resource.  The range of valid values is 0 to (D3D12\_REQ\_SUBRESOURCES - <i>FirstSubresource</i>).

*BaseOffset*\
Type: UINT64

The offset, in bytes, to the resource.

*pLayouts \[out, optional]*\
Type: D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT \*

A pointer to an array (of length <i>NumSubresources</i>) of
[D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public) structures, to be filled with the description and placement of each subresource.

*pNumRows \[out, optional]*\
Type: UINT \*

A pointer to an array (of length <i>NumSubresources</i>) of integer  variables, to be filled with the number of rows for each subresource.

*pRowSizeInBytes \[out, optional]*\
Type: UINT64 \*

A pointer to an array (of length <i>NumSubresources</i>) of integer variables, each entry to be filled with the unpadded size in bytes of a row, of each subresource.

For example, if a Texture2D resource has a width of 32 and bytes per pixel of 4,

then <i>pRowSizeInBytes</i> returns 128.

<i>pRowSizeInBytes</i> should not be confused with **row pitch**, as examining <i>pLayouts</i> and getting the row pitch from that will give you 256 as it is aligned to D3D12\_TEXTURE\_DATA\_PITCH\_ALIGNMENT.

*pTotalBytes \[out, optional]*\
Type: UINT64 \*

A pointer to an integer variable, to be filled with the total size, in bytes.

### Return value

Type: void

None.

## Remarks

This routine assists the application in filling out
[D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public) and
[D3D12\_SUBRESOURCE\_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_subresource_footprint_public) structures, when suballocating space in upload heaps.
The resulting structures are GPU adapter-agnostic, meaning that the values will not vary from one GPU adapter to the next.
**GetCopyableFootprints** uses specified details about resource formats, texture layouts, and alignment requirements (from the [D3D12\_RESOURCE\_DESC](/reference/graphics/d3d12/structs/d3d12_resource_desc_public) structure)  to fill out the subresource structures.
Applications have access to all these details, so this method, or a variation of it, could be  written as part of the app.

#### Examples

The [D3D12Multithreading](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) sample uses **ID3D12Device::GetCopyableFootprints** as follows:

```cpp theme={null}
// Returns required size of a buffer to be used for data upload
inline UINT64 GetRequiredIntermediateSize(
_In_ ID3D12Resource* pDestinationResource,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources)
{
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
UINT64 RequiredSize = 0;

ID3D12Device* pDevice;
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize);
pDevice->Release();

return RequiredSize;
}

```

Refer to the [Example Code in the D3D12 Reference](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code).

<div class="code" />

## Requirements

**Header:** d3d12\_xs.h or d3d12\_x.h\
**Library:** d3d12\_xs.lib or d3d12\_x.lib\
**Supported Platforms**: XBOX Series consoles and XBOX One family

## See Also

[CD3DX12\_RESOURCE\_DESC](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/cd3dx12-resource-desc)

[CD3DX12\_SUBRESOURCE\_FOOTPRINT](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/cd3dx12-subresource-footprint)

[ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)


## Related topics

- [D3D12_PLACED_SUBRESOURCE_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public.md)
- [D3D12_SUBRESOURCE_FOOTPRINT](/reference/graphics/d3d12/structs/d3d12_subresource_footprint_public.md)
- [D3D12_TEXTURE_COPY_TYPE](/reference/graphics/d3d12/enums/d3d12_texture_copy_type_public.md)
- [XblSocialManagerUserGroupGetUsers](/reference/live/xsapi-c/social_manager_c/functions/xblsocialmanagerusergroupgetusers.md)
- [D3D12_TEXTURE_COPY_LOCATION](/reference/graphics/d3d12/structs/d3d12_texture_copy_location_public.md)
