DirectStorage: handle BCPack output allocation failure #1371

Open
hajduzsolt wants to merge 2 commits from upstream-pr/1381 into main
hajduzsolt commented 2026-11-24 15:25:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T15:25:12Z.


Runtime fix verified with unit tests and RX 9070 XT smoke run.

What is in it

  • Return a distinct allocation error for the output buffer, with a synthetic regression for every supported mode.

Tested

  • Windows 11 Pro x64 build 26300, Ryzen 7 9800X3D, Radeon RX 9070 XT, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug.
  • cargo build --workspace
  • cargo test -p xcl --lib oversized_output_returns_allocation_error: 1 passed.
  • cargo test --workspace -- --test-threads=4 --nocapture: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early.
  • SKIPPED: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state, because the D3D12 debug layer is unavailable.

Regression run

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: AMD Radeon RX 9070 XT
title: b0ea61d5
seconds: 60
exit: 0x0
frames shown: 1676 (PresentX 1676)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14579 MB

PR:

xcl-smoke v1
commit: 17bcfe63eb5925b6bc69e71e584b6c44556033a3
gpu: AMD Radeon RX 9070 XT
title: b0ea61d5
seconds: 60
exit: 0x0
frames shown: 1683 (PresentX 1684)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14712 MB

Not tested

  • Retail title, debug layer, and adapters other than the one above. This change handles output reservation failure; it does not bound all intermediate allocations or prevent operating-system overcommit.

AI use

  • Codex (GPT 6.1 Terra Medium): investigation, implementation, synthetic test, and validation.
<!-- greyfinch-sync:ivall/xcl:issue:5475099276 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T15:25:12Z. --- Runtime fix verified with unit tests and RX 9070 XT smoke run. **What is in it** - Return a distinct allocation error for the output buffer, with a synthetic regression for every supported mode. **Tested** - Windows 11 Pro x64 build 26300, Ryzen 7 9800X3D, Radeon RX 9070 XT, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug. - `cargo build --workspace` - `cargo test -p xcl --lib oversized_output_returns_allocation_error`: 1 passed. - `cargo test --workspace -- --test-threads=4 --nocapture`: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early. - SKIPPED: `test_title_draws_with_a_root_signature_under_the_debug_layer` and `uploads_start_from_each_subresources_state`, because the D3D12 debug layer is unavailable. **Regression run** main: ``` xcl-smoke v1 commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324 gpu: AMD Radeon RX 9070 XT title: b0ea61d5 seconds: 60 exit: 0x0 frames shown: 1676 (PresentX 1676) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14579 MB ``` PR: ``` xcl-smoke v1 commit: 17bcfe63eb5925b6bc69e71e584b6c44556033a3 gpu: AMD Radeon RX 9070 XT title: b0ea61d5 seconds: 60 exit: 0x0 frames shown: 1683 (PresentX 1684) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14712 MB ``` **Not tested** - Retail title, debug layer, and adapters other than the one above. This change handles output reservation failure; it does not bound all intermediate allocations or prevent operating-system overcommit. **AI use** - Codex (GPT 6.1 Terra Medium): investigation, implementation, synthetic test, and validation.
futurepro62 commented 2026-11-24 16:07:10 +00:00 (Migrated from github.com)

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


Full-suite run, since this PR has no test report yet. Tested exact head a714559 (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: oversized_output_returns_allocation_error.
  • 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:7136218863 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1381#issuecomment-7136218863). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:33:08Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `a714559` (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: `oversized_output_returns_allocation_error`. - 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.
DavidM1911 commented 2026-11-24 17:06:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:49:46Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138270179 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1381#issuecomment-7138270179). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:49:46Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
throny commented 2026-11-25 01:10:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T00:26:58Z.


Two contributors checked independently and found that #1438 #1785 solves the same problem (for #1392) in a different way: #1607, group D54. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7148521230 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381#issuecomment-7148521230). Originally posted by [throny](https://github.com/throny) on 2026-11-25T00:26:58Z. --- <!-- xcl-1607-hint:D54 --> Two contributors checked independently and found that #1438 #1785 solves the same problem (for #1392) in a different way: #1607, group D54. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
anes66 commented 2026-11-25 06:06:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by anes66 on 2026-11-25T06:02:38Z.


CPU-only allocator-refusal verification on exact head a71455945d0373b19b67f845251a4e1991509374 passed. Optional test companion 98886cb adds one test only, directly on that head.

The existing usize::MAX regression covers a capacity overflow. This additional case uses a representable, block-aligned 128 MiB output size and a 64 MiB Windows Job Object process-commit cap applied only to an isolated test child, so it exercises a real allocator refusal without exhausting the machine's memory.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. No GPU, DXC, title or proprietary input.
  • All six supported modes (1, 3, 4, 5, 6, 7) returned Error::Allocation; the child completed normally. Creating/configuring/assigning the job must succeed or the test fails.
  • cargo test --locked -p xcl --lib hle::bcpack::tests:: -j 2 -- --nocapture --test-threads=1: 8 passed / 0 failed / 0 ignored / 0 skips. This includes the original oversized-output test, synthetic fixtures, malformed-input checks and the new child test. The nested child summary is the same test invocation and is not counted again.
  • Temporary negative control restored the original vec![0u8; out_len]: the child aborted and stderr contained memory allocation of 134217728 bytes failed; the parent test failed as expected. Restored before the final passing suite and commit.

Not tested
Whole-system exhaustion, intermediate decoder allocations, downstream DirectStorage error mapping, release, full workspace/GPU suite, retail smoke or newer-main integration. This verifies graceful refusal of the output allocation, not that every allocation in a title run becomes recoverable or that #1381 fixes a particular retail crash.

AI use: Codex (GPT-6; exact variant unavailable) wrote the test and temporary negative control, ran CPU verification and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7154383271 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381#issuecomment-7154383271). Originally posted by [anes66](https://github.com/anes66) on 2026-11-25T06:02:38Z. --- CPU-only allocator-refusal verification on exact head `a71455945d0373b19b67f845251a4e1991509374` passed. Optional test companion [98886cb](https://github.com/anes66/xcl/commit/98886cbe42a74cc79420475a8dc7f8ae47c5a47e) adds one test only, directly on that head. The existing `usize::MAX` regression covers a capacity overflow. This additional case uses a representable, block-aligned **128 MiB** output size and a **64 MiB Windows Job Object process-commit cap applied only to an isolated test child**, so it exercises a real allocator refusal without exhausting the machine's memory. **Tested** - Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. No GPU, DXC, title or proprietary input. - All six supported modes (1, 3, 4, 5, 6, 7) returned `Error::Allocation`; the child completed normally. Creating/configuring/assigning the job must succeed or the test fails. - `cargo test --locked -p xcl --lib hle::bcpack::tests:: -j 2 -- --nocapture --test-threads=1`: **8 passed / 0 failed / 0 ignored / 0 skips**. This includes the original oversized-output test, synthetic fixtures, malformed-input checks and the new child test. The nested child summary is the same test invocation and is not counted again. - Temporary negative control restored the original `vec![0u8; out_len]`: the child aborted and stderr contained `memory allocation of 134217728 bytes failed`; the parent test failed as expected. Restored before the final passing suite and commit. **Not tested** Whole-system exhaustion, intermediate decoder allocations, downstream DirectStorage error mapping, release, full workspace/GPU suite, retail smoke or newer-main integration. This verifies graceful refusal of the output allocation, not that every allocation in a title run becomes recoverable or that #1381 fixes a particular retail crash. AI use: Codex (GPT-6; exact variant unavailable) wrote the test and temporary negative control, ran CPU verification and prepared this report.
hajduzsolt commented 2026-11-25 15:07:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-25T14:46:28Z.


Thanks @anes66 for the additional regression test. Commit 17bcfe6 includes your isolated child-process test, which checks that each supported BCPack mode reports allocation refusal under a 64 MiB process commit limit rather than aborting.

  • cargo test -p xcl --lib output_allocation_refused_by_windows_returns_an_error -- --test-threads=2: 1 passed, 0 failed, 0 ignored.
  • cargo test --workspace -- --test-threads=2: passed, 0 failures; the xcl unit suite reported 709 passed and 21 ignored, with additional workspace and documentation tests passing.

The updated head is queued for automated RX 9070 XT smoke verification.

<!-- greyfinch-sync:ivall/xcl:comment:7165793435 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381#issuecomment-7165793435). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-25T14:46:28Z. --- Thanks @anes66 for the additional regression test. Commit `17bcfe6` includes your isolated child-process test, which checks that each supported BCPack mode reports allocation refusal under a 64 MiB process commit limit rather than aborting. - `cargo test -p xcl --lib output_allocation_refused_by_windows_returns_an_error -- --test-threads=2`: 1 passed, 0 failed, 0 ignored. - `cargo test --workspace -- --test-threads=2`: passed, 0 failures; the xcl unit suite reported 709 passed and 21 ignored, with additional workspace and documentation tests passing. The updated head is queued for automated RX 9070 XT smoke verification.
DavidM1911 commented 2026-11-26 05:05:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:03:20Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7183139450 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381#issuecomment-7183139450). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T05:03:20Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
github-actions[bot] commented 2026-12-01 02:31:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:31:59Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298717861 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381#issuecomment-7298717861). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:31:59Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:35:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:35:26Z.


Triage (#1607) – head 17bcfe6

#1785 makes the same change to bcpack::decode (try_reserve_exact for the output buffer, a new error variant) and more (the victory record buffer, request size limits in dstorage.rs), but it is later, has no tests and no test run, and conflicts with main. #1438 changes only dstorage::execute (bounds and fallible source buffers), not the decoder.
No problems found in the diff; the change still applies to main's bcpack::decode.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301928761 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1381#issuecomment-7301928761). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:35:26Z. --- **Triage (#1607)** – head 17bcfe6 #1785 makes the same change to `bcpack::decode` (`try_reserve_exact` for the output buffer, a new error variant) and more (the `victory` record buffer, request size limits in `dstorage.rs`), but it is later, has no tests and no test run, and conflicts with main. #1438 changes only `dstorage::execute` (bounds and fallible source buffers), not the decoder. No problems found in the diff; the change still applies to main's `bcpack::decode`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1381:upstream-pr/1381'
git switch 'upstream-pr/1381'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1381'
git switch 'upstream-pr/1381'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1381'
git switch 'upstream-pr/1381'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1381'
git switch 'main'
git merge --squash 'upstream-pr/1381'
git switch 'main'
git merge --ff-only 'upstream-pr/1381'
git switch 'main'
git merge 'upstream-pr/1381'
git push origin 'main'
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!1371
No description provided.