編輯

共用方式為


ID3D12Device::GetResourceAllocationInfo(UINT,UINT,constD3D12_RESOURCE_DESC*) method (d3d12.h)

Gets the size and alignment of memory required for a collection of resources on this adapter.

Syntax

D3D12_RESOURCE_ALLOCATION_INFO GetResourceAllocationInfo(
  [in] UINT                      visibleMask,
  [in] UINT                      numResourceDescs,
  [in] const D3D12_RESOURCE_DESC *pResourceDescs
);

Parameters

[in] visibleMask

Type: UINT

For single-GPU operation, set this to zero. If there are multiple GPU nodes, then set bits to identify the nodes (the device's physical adapters). Each bit in the mask corresponds to a single node. Also see Multi-adapter systems.

[in] numResourceDescs

Type: UINT

The number of resource descriptors in the pResourceDescs array.

[in] pResourceDescs

Type: const D3D12_RESOURCE_DESC*

An array of D3D12_RESOURCE_DESC structures that described the resources to get info about.

Return value

Type: D3D12_RESOURCE_ALLOCATION_INFO

A D3D12_RESOURCE_ALLOCATION_INFO structure that provides info about video memory allocated for the specified array of resources.

If an error occurs, then D3D12_RESOURCE_ALLOCATION_INFO::SizeInBytes equals UINT64_MAX.

Remarks

When you're using CreatePlacedResource, your application must use GetResourceAllocationInfo in order to understand the size and alignment characteristics of texture resources. The results of this method vary depending on the particular adapter, and must be treated as unique to this adapter and driver version.

Your application can't use the output of GetResourceAllocationInfo to understand packed mip properties of textures. To understand packed mip properties of textures, your application must use GetResourceTiling.

Texture resource sizes significantly differ from the information returned by GetResourceTiling, because some adapter architectures allocate extra memory for textures to reduce the effective bandwidth during common rendering scenarios. This even includes textures that have constraints on their texture layouts, or have standardized texture layouts. That extra memory can't be sparsely mapped nor remapped by an application using CreateReservedResource and UpdateTileMappings, so it isn't reported by GetResourceTiling.

Your application can forgo using GetResourceAllocationInfo for buffer resources (D3D12_RESOURCE_DIMENSION_BUFFER). Buffers have the same size on all adapters, which is merely the smallest multiple of 64KB that's greater or equal to D3D12_RESOURCE_DESC::Width.

When multiple resource descriptions are passed in, the C++ algorithm for calculating a structure size and alignment are used. For example, a three-element array with two tiny 64KB-aligned resources and a tiny 4MB-aligned resource, reports differing sizes based on the order of the array. If the 4MB aligned resource is in the middle, then the resulting Size is 12MB. Otherwise, the resulting Size is 8MB. The Alignment returned would always be 4MB, because it's the superset of all alignments in the resource array.

Requirements

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

See also

ID3D12Device