Поделиться через


Метод ID3D12Device::GetCopyableFootprints (d3d12.h)

Возвращает макет ресурса, который можно скопировать. Helps the app fill-in D3D12_PLACED_SUBRESOURCE_FOOTPRINT and D3D12_SUBRESOURCE_FOOTPRINT when suballocating space in upload heaps.

Syntax

void GetCopyableFootprints(
  [in]            const D3D12_RESOURCE_DESC          *pResourceDesc,
  [in]            UINT                               FirstSubresource,
  [in]            UINT                               NumSubresources,
                  UINT64                             BaseOffset,
  [out, optional] D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts,
  [out, optional] UINT                               *pNumRows,
  [out, optional] UINT64                             *pRowSizeInBytes,
  [out, optional] UINT64                             *pTotalBytes
);

Parameters

[in] pResourceDesc

Тип: const D3D12_RESOURCE_DESC*

A description of the resource, as a pointer to a D3D12_RESOURCE_DESC structure.

[in] FirstSubresource

Type: UINT

Индекс первого подресурса в ресурсе. Диапазон допустимых значений составляет от 0 до D3D12_REQ_SUBRESOURCES.

[in] NumSubresources

Type: UINT

Количество подресурсов в ресурсе. The range of valid values is 0 to (D3D12_REQ_SUBRESOURCES - FirstSubresource).

BaseOffset

Type: UINT64

Смещение в байтах к ресурсу.

[out, optional] pLayouts

Type: D3D12_PLACED_SUBRESOURCE_FOOTPRINT*

A pointer to an array (of length NumSubresources) of D3D12_PLACED_SUBRESOURCE_FOOTPRINT structures, to be filled with the description and placement of each subresource.

[out, optional] pNumRows

Type: UINT*

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

[out, optional] pRowSizeInBytes

Type: UINT64*

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

Например, если ресурс Texture2D имеет ширину 32 и байт на пиксель 4,

then pRowSizeInBytes returns 128.

pRowSizeInBytes should not be confused with row pitch, as examining pLayouts and getting the row pitch from that will give you 256 as it is aligned to D3D12_TEXTURE_DATA_PITCH_ALIGNMENT.

[out, optional] pTotalBytes

Type: UINT64*

Указатель на целочисленную переменную, заполненную общим размером в байтах. If pResourceDesc is invalid, then the value of pTotalBytes is set to UINT64_MAX.

Return value

None

Remarks

This routine assists the application in filling out D3D12_PLACED_SUBRESOURCE_FOOTPRINT and D3D12_SUBRESOURCE_FOOTPRINT structures, when suballocating space in upload heaps. Результирующая структура — это адаптер GPU, не зависящий от того, что значения не будут отличаться от одного адаптера GPU к следующему. GetCopyableFootprints uses specified details about resource formats, texture layouts, and alignment requirements (from the D3D12_RESOURCE_DESC structure) to fill out the subresource structures. Приложения имеют доступ ко всем этим сведениям, поэтому этот метод или вариант его можно записать как часть приложения.

Examples

The D3D12Multithreading sample uses ID3D12Device::GetCopyableFootprints as follows:

// 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.

Requirements

Requirement Value
Target Platform Windows
Header d3d12.h
Library D3d12.lib
DLL D3d12.dll

See also

CD3DX12_RESOURCE_DESC

CD3DX12_SUBRESOURCE_FOOTPRINT

ID3D12Device