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

Merged
emirduran707 merged 1 commit from upstream-pr/1354 into main 2026-11-24 15:57:26 +00:00
emirduran707 commented 2026-11-24 15:08:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-24T15:08:55Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6584911310 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1354). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-24T15:08:55Z. --- `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)
upstream-sync closed this pull request 2026-11-24 16:06:27 +00:00
futurepro62 commented 2026-11-24 16:07:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:16:23Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7135746551 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1354#issuecomment-7135746551). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:16:23Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1344
No description provided.