Skip to content

Runtime: implement GetResourceAllocationInfo, GetResourceAllocationInfo1/2 (D3D-22) - #329

Closed
0xTehuti wants to merge 1 commit into
ItsNotRexed:mainfrom
0xTehuti:runtime/d3d12-resource-allocation-info
Closed

0xTehuti wants to merge 1 commit into
ItsNotRexed:mainfrom
0xTehuti:runtime/d3d12-resource-allocation-info

Conversation

@0xTehuti

Copy link
Copy Markdown
Contributor

Summary

Implements GetResourceAllocationInfo, GetResourceAllocationInfo1, and GetResourceAllocationInfo2 on the Vulkan device shim per docs/d3d12_vulkan.md §4.1 (item D3D-22 in #156).

  • Implements deterministic placement sizing and alignment logic on ID3D12Device::GetResourceAllocationInfo.
  • Implements ID3D12Device4::GetResourceAllocationInfo1 returning individual resource offsets, alignments, and sizes within an allocation alongside total allocation size.
  • Implements ID3D12Device8::GetResourceAllocationInfo2 supporting D3D12_RESOURCE_DESC1.
  • Fully supports:
    • Buffers (64 KB alignment).
    • Standard 1D, 2D, and 3D textures (64 KB default placement alignment).
    • 4 KB small alignment textures (D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT) with subresource 4KB tile alignment, validating that total resource footprint does not exceed 64 KB.
    • MSAA textures with 4 MB alignment (D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT) and opt-in 64 KB alignment.
    • Depth-stencil formats (DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_D32_FLOAT_S8X24_UINT) unified surface footprint calculation.
    • Multi-resource queries with proper sequential alignment offsets and invalid descriptor rejection (~0ull size with default 64 KB alignment).
    • Both MSVC value-return and MinGW pointer-return (RetVal) calling conventions.

Testing & Verification

AI-assisted. Tested against host PC Microsoft Direct3D 12 runtime (d3d12.dll) on Windows 11 with:

  • GPU: NVIDIA GeForce RTX 2070 SUPER (8203 MB VRAM)
  • Driver: NVIDIA 595.79 (Vulkan 1.4.321, WDDM 3.2)
  • Compiler: MSVC 2022 v14.44 (19.44.35225) with Ninja 1.13.0 (RelWithDebInfo)
  • Flags: /std:c++20 /W4 /permissive- /utf-8 (0 errors, 0 warnings)

Test Results:

  • d3d12_vulkan_device_test.exe: PASSED with 0 mismatches comparing single buffers, textures, array textures, mip chains, small 4KB alignment, 4MB MSAA textures, multi-resource queries, invalid descs, and ID3D12Device8::GetResourceAllocationInfo2 against host D3D12 hardware runtime.
  • CTest Suite (12 / 12): 100% pass rate (loader, pe_loader, device_proxy, command_list, descriptor_table, bink_decode, bink_audio, xmem, root_signature, root_signature_oracle, d3d12_gcl8, d3d12_state_map).
  • Python / dotnet validation: python -m compileall -q make_game.py tools tests, python -I make_game.py --help, and dotnet build tools/rpf9dump/rpf9dump.csproj -c Release all passed with 0 errors.

Resolves item D3D-22 in #156.

…fo1/2 (D3D-22)

Implements D3D12 resource allocation sizing and alignment rules on the Vulkan device
shim per docs/d3d12_vulkan.md §4.1:
- GetResourceAllocationInfo on ID3D12Device
- GetResourceAllocationInfo1 on ID3D12Device4
- GetResourceAllocationInfo2 on ID3D12Device8
- Handles buffers (64KB alignment), standard textures (64KB alignment), small textures
  (4KB alignment up to 64KB), MSAA textures (4MB / 64KB alignment), 1D/2D/3D textures,
  and sequential suballocation placement offsets for multi-resource queries.
- Tested and verified against host PC D3D12 runtime with 0 mismatches across buffers,
  textures, mip chains, small alignment, MSAA, and error cases.
@0xTehuti

Copy link
Copy Markdown
Contributor Author

Closed in favor of #327 (D3D-23), which landed on main today covering the same methods. Thanks!

@0xTehuti 0xTehuti closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant