D3D12.X: allocation info of several resources is padded to their alignment #1354

Manually merged
github merged 1 commit from gh-pr/1354/head into gh-pr/1354/base 2026-11-26 04:51:51 +00:00
Owner

@⁠emirduran707 on GitHub · 2026-11-24 15:08 UTC · original
emirduran707:d3d12x-allocation-info-alignment → main · +55 −21 · 1 files · 1 commits · merged 2026-11-24 15:57 UTC

GetResourceAllocationInfo (#25) and GetResourceAllocationInfo1 (#108) for several resources summed their sizes with each one aligned, but did not pad the total to the largest alignment. Microsoft's documentation says "the C++ algorithm for calculating a structure size and alignment are used". With a 4 MB-aligned resource between two 64 KB-aligned ones the total is 12 MB, and otherwise 8 MB. XCL answered 8 MB + 64 KB and 4 MB + 128 KB.

The arithmetic of both is now one function, allocation_of, which pads the total to the largest alignment when there is more than one resource. The per-resource offsets that #108 writes are unchanged. A single resource is unchanged too: XG's texture sizes are not always a multiple of their alignment, and padding them would change every single-texture answer.

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs: allocation_of, used by #25 and #108; test allocation_info_of_several_is_padded_to_the_largest_alignment. It covers [64K, 4M, 64K] → 12M, [4M, 64K, 64K] → 8M, [64K, 64K, 4M] → 8M, a single resource unchanged, and nothing placed after a failed resource.

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on 60e7603: 752 passed, 0 failed, 41 ignored; no SKIPPED GPU tests
  • the test against the old arithmetic: left: (8454144, 4194304), right: (12582912, 4194304); with the change it passes

Regression run

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1530 (PresentX 1530)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18961 MB

this PR:

xcl-smoke v1
commit: 60e7603543198157a4f9388cde30cecb8a17922d
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1506 (PresentX 1506)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 21738 MB

Not tested

  • A title that chains offsets by SizeInBytes and places a 4 MB-aligned resource after them; the smoke title's run is a regression check only.
  • NVIDIA and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above.

🤖 Generated with Claude Code

**@⁠emirduran707** on GitHub · 2026-11-24 15:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1354) `emirduran707:d3d12x-allocation-info-alignment` → `main` · +55 −21 · 1 files · 1 commits · merged 2026-11-24 15:57 UTC `GetResourceAllocationInfo` (#25) and `GetResourceAllocationInfo1` (#108) for several resources summed their sizes with each one aligned, but did not pad the total to the largest alignment. Microsoft's documentation says "the C++ algorithm for calculating a structure size and alignment are used". With a 4 MB-aligned resource between two 64 KB-aligned ones the total is 12 MB, and otherwise 8 MB. XCL answered 8 MB + 64 KB and 4 MB + 128 KB. The arithmetic of both is now one function, `allocation_of`, which pads the total to the largest alignment when there is more than one resource. The per-resource offsets that #108 writes are unchanged. A single resource is unchanged too: XG's texture sizes are not always a multiple of their alignment, and padding them would change every single-texture answer. **What is in it** - `crates/xcl/src/hle/d3d12x/device_x.rs`: `allocation_of`, used by #25 and #108; test `allocation_info_of_several_is_padded_to_the_largest_alignment`. It covers [64K, 4M, 64K] → 12M, [4M, 64K, 64K] → 8M, [64K, 64K, 4M] → 8M, a single resource unchanged, and nothing placed after a failed resource. **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on 60e7603: 752 passed, 0 failed, 41 ignored; no SKIPPED GPU tests - the test against the old arithmetic: `left: (8454144, 4194304)`, `right: (12582912, 4194304)`; with the change it passes **Regression run** main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1530 (PresentX 1530) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18961 MB ``` this PR: ``` xcl-smoke v1 commit: 60e7603543198157a4f9388cde30cecb8a17922d gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1506 (PresentX 1506) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 21738 MB ``` **Not tested** - A title that chains offsets by `SizeInBytes` and places a 4 MB-aligned resource after them; the smoke title's run is a regression check only. - NVIDIA and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: found the problem, wrote the change, the test and this description; I reviewed the diff and ran the tests and smoke runs above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
GetResourceAllocationInfo (#25) and GetResourceAllocationInfo2 (#108)
laid several resources out one after another, each at its own
alignment, but returned the end of the last one as the size. The PC's
docs for GetResourceAllocationInfo with several descriptions: "the C++
algorithm for calculating a structure size and alignment are used" - a
4 MiB-aligned resource between two 64 KiB-aligned ones takes 12 MiB,
first or last 8 MiB, the alignment 4 MiB. XCL answered 8 MiB + 64 KiB
and 4 MiB + 128 KiB: a title sizing one heap for the group from it got
a heap that does not end on the alignment its resources need.

The arithmetic of both is now one function, `allocation_of`, which pads
the total to the largest alignment when there is more than one
resource. One resource's info is still the driver's or XG's as it is
(#108 asks #25 for each one alone); the per-resource offsets #108
writes are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:51:48 +00:00
github manually merged commit 60e7603543 into gh-pr/1354/base 2026-11-26 04:51:51 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 15:16 UTC · original · edited 2026-11-24 15:21 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 60e7603 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: allocation_info_of_several_is_padded_to_the_largest_alignment.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 15:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1354#issuecomment-7135746551) · edited 2026-11-24 15:21 UTC Full-suite run, since this PR has no test report yet. Tested exact head `60e7603` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `allocation_info_of_several_is_padded_to_the_largest_alignment`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This discussion has been locked. Commenting is limited to contributors.
No description provided.