> ## 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

> 取得可複製的資源配置。在子配置空間時，協助應用程式填入 D3D12_PLACED_SUBRESOURCE_FOOTPRINT 和 D3D12_SUBRESOURCE_FOOTPRINT。

取得可複製的資源配置。
在上傳堆積中子配置空間時，協助應用程式填入
[D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public) 和
[D3D12\_SUBRESOURCE\_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_subresource_footprint_public)。

## 語法

```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
)
```

### 參數

*pResourceDesc \[in]*\
類型：const D3D12\_RESOURCE\_DESC \*

資源的描述，以 [D3D12\_RESOURCE\_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_resource_desc_public) 結構的指標表示。

*FirstSubresource \[in]*\
類型：UINT

資源中第一個子資源的索引。
有效值的範圍是 0 到 D3D12\_REQ\_SUBRESOURCES。

*NumSubresources \[in]*\
類型：UINT

資源中的子資源數目。有效值的範圍是 0 到 (D3D12\_REQ\_SUBRESOURCES - <i>FirstSubresource</i>)。

*BaseOffset*\
類型：UINT64

資源的位移 (以位元組為單位)。

*pLayouts \[out, optional]*\
類型：D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT \*

指向
[D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public) 結構陣列 (長度為 <i>NumSubresources</i>) 的指標，會以每個子資源的描述和放置位置填入。

*pNumRows \[out, optional]*\
類型：UINT \*

指向整數變數陣列 (長度為 <i>NumSubresources</i>) 的指標，會以每個子資源的資料列數目填入。

*pRowSizeInBytes \[out, optional]*\
類型：UINT64 \*

指向整數變數陣列 (長度為 <i>NumSubresources</i>) 的指標，每個項目都會以每個子資源一個資料列的未填補大小 (以位元組為單位) 填入。

例如，如果 Texture2D 資源的寬度為 32，且每像素位元組數為 4，

則 <i>pRowSizeInBytes</i> 會傳回 128。

<i>pRowSizeInBytes</i> 不應與**資料列間距**混淆，因為檢查 <i>pLayouts</i> 並從中取得資料列間距會得到 256，因為它會對齊 D3D12\_TEXTURE\_DATA\_PITCH\_ALIGNMENT。

*pTotalBytes \[out, optional]*\
類型：UINT64 \*

指向整數變數的指標，會以總大小 (以位元組為單位) 填入。

### 傳回值

類型：void

無。

## 備註

在上傳堆積中子配置空間時，此常式可協助應用程式填寫
[D3D12\_PLACED\_SUBRESOURCE\_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public) 和
[D3D12\_SUBRESOURCE\_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_subresource_footprint_public) 結構。
產生的結構與 GPU 介面卡無關，表示這些值不會因 GPU 介面卡不同而改變。
**GetCopyableFootprints** 會使用 (來自 [D3D12\_RESOURCE\_DESC](/zh-TW/reference/graphics/d3d12/structs/d3d12_resource_desc_public) 結構的) 資源格式、紋理配置和對齊需求的指定詳細資料來填寫子資源結構。
應用程式可以存取所有這些詳細資料，因此此方法或其變化可以撰寫為應用程式的一部分。

#### 範例

[D3D12Multithreading](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) 範例使用 **ID3D12Device::GetCopyableFootprints** 的方式如下：

```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;
}

```

請參閱 [D3D12 參考中的範例程式碼](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code)。

<div class="code" />

## 需求

**標頭：** d3d12\_xs.h 或 d3d12\_x.h\
**程式庫：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支援的平台：** XBOX Series 主機和 XBOX One 系列主機

## 另請參閱

[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](/zh-TW/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)


## Related topics

- [D3D12_PLACED_SUBRESOURCE_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_placed_subresource_footprint_public.md)
- [D3D12_SUBRESOURCE_FOOTPRINT](/zh-TW/reference/graphics/d3d12/structs/d3d12_subresource_footprint_public.md)
- [D3D12_TEXTURE_COPY_TYPE](/zh-TW/reference/graphics/d3d12/enums/d3d12_texture_copy_type_public.md)
- [D3D12_TEXTURE_COPY_LOCATION](/zh-TW/reference/graphics/d3d12/structs/d3d12_texture_copy_location_public.md)
- [Get Segments](/api-reference/segments/get-segments.md)
