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

# GetResourceAllocationInfo1 (XBOX Series 主机)

> 获取有关此适配器上一组资源所需的内存大小和对齐方式的详细信息。(ID3D12Device4::GetResourceAllocationInfo1)

获取有关此适配器上一组资源所需的内存大小和对齐方式的详细信息。另请参阅 [ID3D12Device::GetResourceAllocationInfo](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getresourceallocationinfo_public.md)。

除了该方法返回的 [D3D12\_RESOURCE\_ALLOCATION\_INFO](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_allocation_info_public.md) 之外，此版本还返回一个 [D3D12\_RESOURCE\_ALLOCATION\_INFO1](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_allocation_info1_public.md) 结构数组，为作为输入传递的每个资源描述提供其他详细信息。请参阅 *pResourceAllocationInfo1* 参数。

## 语法

```cpp theme={null}
D3D12_RESOURCE_ALLOCATION_INFO GetResourceAllocationInfo1(
    UINT visibleMask,
    UINT numResourceDescs,
    const D3D12_RESOURCE_DESC  pResourceDescs,
    D3D12_RESOURCE_ALLOCATION_INFO1  pResourceAllocationInfo1
)
```

### 参数

*visibleMask \[in]*\
类型：UINT

对于单 GPU 操作，请将其设置为零。如果存在多个 GPU 节点，则设置位以标识节点（设备的物理适配器）。掩码中的每个位对应一个节点。另请参阅[多适配器系统](https://learn.microsoft.com/en-us/windows/win32/direct3d12/multi-engine)。

*numResourceDescs \[in]*\
类型：UINT

*pResourceDescs* 数组中的资源描述符数量。这也是 *pResourceAllocationInfo1* 的大小（元素数量）。

*pResourceDescs \[in]*\
类型：const D3D12\_RESOURCE\_DESC \*

一个 **D3D12\_RESOURCE\_DESC** 结构数组，描述要获取信息的资源。

*pResourceAllocationInfo1 \[out]*\
类型：D3D12\_RESOURCE\_ALLOCATION\_INFO1 \*

一个 [D3D12\_RESOURCE\_ALLOCATION\_INFO1](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_allocation_info1_public.md) 结构数组，包含作为输入传递的每个资源描述的其他详细信息。这使您的应用程序更容易为多个资源分配堆，而无需手动计算每个资源应放置位置的偏移量。

### 返回值

类型：D3D12\_RESOURCE\_ALLOCATION\_INFO

一个 [D3D12\_RESOURCE\_ALLOCATION\_INFO](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_allocation_info_public.md) 结构，提供关于为指定资源数组分配的视频内存的信息。

## 备注

当您使用 [CreatePlacedResource](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createplacedresource_public.md) 时，您的应用程序必须使用 **GetResourceAllocationInfo** 来了解纹理资源的大小和对齐特性。此方法的结果因具体适配器而异，必须视为此适配器和驱动程序版本所独有。

您的应用程序不能使用 **GetResourceAllocationInfo** 的输出来了解纹理的打包 mip 属性。要了解纹理的打包 mip 属性，您的应用程序必须使用 [GetResourceTiling](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getresourcetiling_public.md)。

纹理资源大小与 **GetResourceTiling** 返回的信息有显著差异，因为某些适配器架构为纹理分配额外内存以减少常见渲染场景中的有效带宽。这甚至包括对其纹理布局有约束的纹理，或具有标准化纹理布局的纹理。使用 [CreateReservedResource](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createreservedresource_public.md) 和 [UpdateTileMappings](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12commandqueue/methods/id3d12commandqueue_updatetilemappings_public.md) 的应用程序无法稀疏映射或重新映射额外内存，因此 **GetResourceTiling** 不会报告它。

您的应用程序可以对缓冲区资源 ([D3D12\_RESOURCE\_DIMENSION\_BUFFER](https://docs.xbox.com/zh-CN/reference/graphics/d3d12_x/enums/d3d12_resource_dimension.md)) 放弃使用 **GetResourceAllocationInfo**。缓冲区在所有适配器上具有相同的大小，仅仅是大于或等于 [D3D12\_RESOURCE\_DESC::Width](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_desc_public.md) 的最小 64KB 倍数。

传入多个资源描述时，使用 C++ 算法计算结构大小和对齐方式。例如，一个包含两个微小 64KB 对齐资源和一个微小 4MB 对齐资源的三元素数组，会根据数组顺序报告不同的大小。如果 4MB 对齐资源位于中间，则结果 **Size** 为 12MB。否则，结果 **Size** 为 8MB。返回的 **Alignment** 始终为 4MB，因为它是资源数组中所有对齐方式的超集。

## 要求

**头文件：** d3d12\_xs.h\
**库：** d3d12\_xs.lib\
**支持的平台**：XBOX Series 主机

## 另请参阅

[ID3D12Device4](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device4/id3d12device4_public.md)


## Related topics

- [D3D12_RESOURCE_ALLOCATION_INFO1](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_allocation_info1_public.md)
- [D3D12_RESOURCE_ALLOCATION_INFO](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/structs/d3d12_resource_allocation_info_public.md)
- [GetResourceAllocationInfo](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_getresourceallocationinfo_public.md)
- [DSTORAGE_QUEUE_INFO1](https://docs.xbox.com/zh-CN/reference/system/dstorage/structs/dstorage_queue_info1.md)
- [XMEM_ALLOCATION_HOOKS](https://docs.xbox.com/zh-CN/reference/system/xmem/structs/xmem_allocation_hooks.md)
