shaders: delegate directory input to shaders.rpf and guard against OOM #1338

Open
github-bot wants to merge 1 commit from github-bot/gh-1338 into main AGit
Owner

@⁠Ivankiosan on GitHub · 2026-11-24 14:58 UTC · original
Ivankiosan:shaders-cli-directory-and-oom-guard → main · +43 −1 · 1 files · 1 commits · open

When running xcl shaders <path> on a game installation directory (such as D:\aa\xbox), collect_files previously traversed the whole directory tree, queuing multi-gigabyte archives (levels.rpf 76 GB, anim.rpf 4.4 GB) into Input::Files. Input::get then attempted std::fs::read on those archives, causing an immediate panic (memory allocation of 4294967296 bytes failed) before any shader analysis could begin.

What is in it

  • In shaders::run: if path is a directory containing shaders.rpf, automatically delegates execution to shaders.rpf.
  • In collect_files: ignores non-shader extensions (exe, dll, xvd, xml, pri, png, bat) and skips files larger than 512 MiB.
  • In Input::get: checks file size with std::fs::metadata before calling std::fs::read, returning None if the file exceeds 512 MiB to guard against OOM.
  • Adds unit test collect_files_filters_non_shader_extensions verifying non-shader file filtering.

Tested

  • Hardware/OS: AMD Radeon RX 7600 (driver 32.0.12028.1005), Windows 11, rustc 1.99.1 (58cf8f9c3 2026-10-13) / MSVC 14.51.
  • Unit tests: cargo test -p xcl --lib shaders: all 6 passed, 0 failed.
  • Workspace test suite: all unit tests passed with 0 failures.
  • CLI verification: xcl shaders "D:\aa\xbox" --top 5 completes in 6.2 s on the full retail package (26,503 shaders, 44,422,713 RDNA2 instructions) without OOM.

Not tested

  • Running on Linux or non-Windows paths.
  • Game folder layouts lacking shaders.rpf.

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: AMD Radeon RX 7600
title: 419239bf
seconds: 10
exit: 0x0
frames shown: 26 (PresentX 26)
presents per 2 s (last 3): 0 0 23
device removals: 0
crashes: 0
peak commit: 8172 MB

PR head:

xcl-smoke v1
commit: 9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf
gpu: AMD Radeon RX 7600
title: 419239bf
seconds: 10
exit: 0x0
frames shown: 54 (PresentX 54)
presents per 2 s (last 3): 0 0 47
device removals: 0
crashes: 0
peak commit: 8836 MB

AI use

  • Google Antigravity (Gemini): diagnosed std::fs::read OOM panic on large game archives during xcl shaders <dir>, implemented shaders.rpf delegation and file size guards, authored unit test, and verified GPU smoke regression.
**@⁠Ivankiosan** on GitHub · 2026-11-24 14:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/1338) `Ivankiosan:shaders-cli-directory-and-oom-guard` → `main` · +43 −1 · 1 files · 1 commits · open When running `xcl shaders <path>` on a game installation directory (such as `D:\aa\xbox`), `collect_files` previously traversed the whole directory tree, queuing multi-gigabyte archives (`levels.rpf` 76 GB, `anim.rpf` 4.4 GB) into `Input::Files`. `Input::get` then attempted `std::fs::read` on those archives, causing an immediate panic (`memory allocation of 4294967296 bytes failed`) before any shader analysis could begin. **What is in it** - In `shaders::run`: if `path` is a directory containing `shaders.rpf`, automatically delegates execution to `shaders.rpf`. - In `collect_files`: ignores non-shader extensions (`exe`, `dll`, `xvd`, `xml`, `pri`, `png`, `bat`) and skips files larger than 512 MiB. - In `Input::get`: checks file size with `std::fs::metadata` before calling `std::fs::read`, returning `None` if the file exceeds 512 MiB to guard against OOM. - Adds unit test `collect_files_filters_non_shader_extensions` verifying non-shader file filtering. **Tested** - Hardware/OS: AMD Radeon RX 7600 (driver 32.0.12028.1005), Windows 11, `rustc 1.99.1 (58cf8f9c3 2026-10-13)` / MSVC 14.51. - Unit tests: `cargo test -p xcl --lib shaders`: all 6 passed, 0 failed. - Workspace test suite: all unit tests passed with 0 failures. - CLI verification: `xcl shaders "D:\aa\xbox" --top 5` completes in 6.2 s on the full retail package (26,503 shaders, 44,422,713 RDNA2 instructions) without OOM. **Not tested** - Running on Linux or non-Windows paths. - Game folder layouts lacking `shaders.rpf`. **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: AMD Radeon RX 7600 title: 419239bf seconds: 10 exit: 0x0 frames shown: 26 (PresentX 26) presents per 2 s (last 3): 0 0 23 device removals: 0 crashes: 0 peak commit: 8172 MB ``` PR head: ``` xcl-smoke v1 commit: 9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf gpu: AMD Radeon RX 7600 title: 419239bf seconds: 10 exit: 0x0 frames shown: 54 (PresentX 54) presents per 2 s (last 3): 0 0 47 device removals: 0 crashes: 0 peak commit: 8836 MB ``` **AI use** - Google Antigravity (Gemini): diagnosed `std::fs::read` OOM panic on large game archives during `xcl shaders <dir>`, implemented `shaders.rpf` delegation and file size guards, authored unit test, and verified GPU smoke regression.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:51:09 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 15:05 UTC · original

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

  • cargo test -p xcl --lib: 708 passed, 0 failed, 21 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 15:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1338#issuecomment-7135452578) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 708 passed, 0 failed, 21 ignored. Thanks!
Author
Owner

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

Full-suite run, since this PR has no test report yet. Tested exact head 9c9e2ca (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: collect_files_filters_non_shader_extensions.
  • 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:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1338#issuecomment-7135597638) Full-suite run, since this PR has no test report yet. Tested exact head `9c9e2ca` (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: `collect_files_filters_non_shader_extensions`. - 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 15:56 UTC · original

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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 15:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1338#issuecomment-7136856166) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠itsSio on GitHub · 2026-11-25 09:29 UTC · original

Tested

Independent check for #1607 on clean #1338 head 9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf (no local merge). Both systems: Windows 11 Pro 26200, x64 MSVC, unoptimized dev/test. cargo build --workspace --locked exited 0 on both; cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture produced:

GPU / driver CPU, RAM, toolchain Passed / failed / ignored Runtime SKIPPED
RTX 5080 / 32.0.16.1088 Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC 1.9.2609.5 752 / 0 / 41 2
RTX 2080 SUPER / 32.0.16.1088 Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC 1.8.2502.11 748 / 4 / 41 4

Both skipped native-wave64 cases gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. The RTX 2080 SUPER also skipped test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state (no D3D12 debug layer). collect_files_filters_non_shader_extensions passed in both full runs.

On both PCs, xcl shaders exited 0 on each of two synthetic directory fixtures: a directory with a 64-byte synthetic shaders.rpf selected that pack instead of the loose neighbor; a directory without a pack kept one small candidate and excluded a dummy .exe and a sparse file of logical size 512 MiB + 1 byte.

The RTX 2080 SUPER suite exited 101. The four failing tests and their logged errors were:

  • placed_title_textures_share_vram_and_preserve_pixels: cubemap extra_pages must be reused at same va
  • transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory: PoisonError
  • move_with_locked_overlay_source_preserves_destination: move should succeed after the source handle closes

I retested each in its own process on both GPUs at the clean head and its parent 930e8b49c1c2ec683d22c724a398b39111cd0e56 using cargo test -p xcl --lib --locked <fully-qualified-test> -- --exact --test-threads=1 --nocapture. Each of the 16 invocations had 1 passed / 0 failed / 0 ignored / 0 skipped. The failures did not reproduce in isolation; the parallel suite result above remains red, and this comparison does not establish whether the failures reproduce in the parent's parallel suite.

Not tested

Retail titles or archives, release mode, an intentional allocation failure on the parent, or a full parallel parent suite.

AI use

Ran via Samaritan:

  • OpenCode with OpenAI GPT-6.2 Sol (openai/gpt-6.2-sol): ran the recorded verification, recovered the saved logs, checked the results and drafted this report. The full model-selection history before the interrupted turn could not be verified.
**@⁠itsSio** on GitHub · 2026-11-25 09:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1338#issuecomment-7158411330) **Tested** Independent check for #1607 on clean #1338 head `9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf` (no local merge). Both systems: Windows 11 Pro 26200, x64 MSVC, unoptimized dev/test. `cargo build --workspace --locked` exited 0 on both; `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture` produced: | GPU / driver | CPU, RAM, toolchain | Passed / failed / ignored | Runtime SKIPPED | | --- | --- | ---: | ---: | | RTX 5080 / `32.0.16.1088` | Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC 1.9.2609.5 | **752 / 0 / 41** | 2 | | RTX 2080 SUPER / `32.0.16.1088` | Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC 1.8.2502.11 | **748 / 4 / 41** | 4 | Both skipped native-wave64 cases `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. The RTX 2080 SUPER also skipped `test_title_draws_with_a_root_signature_under_the_debug_layer` and `uploads_start_from_each_subresources_state` (no D3D12 debug layer). `collect_files_filters_non_shader_extensions` passed in both full runs. On both PCs, `xcl shaders` exited 0 on each of two synthetic directory fixtures: a directory with a 64-byte synthetic `shaders.rpf` selected that pack instead of the loose neighbor; a directory without a pack kept one small candidate and excluded a dummy `.exe` and a sparse file of logical size 512 MiB + 1 byte. The RTX 2080 SUPER suite exited 101. The four failing tests and their logged errors were: - `placed_title_textures_share_vram_and_preserve_pixels`: `cubemap extra_pages must be reused at same va` - `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory`: `PoisonError` - `move_with_locked_overlay_source_preserves_destination`: `move should succeed after the source handle closes` I retested each in its own process on both GPUs at the clean head and its parent `930e8b49c1c2ec683d22c724a398b39111cd0e56` using `cargo test -p xcl --lib --locked <fully-qualified-test> -- --exact --test-threads=1 --nocapture`. Each of the 16 invocations had **1 passed / 0 failed / 0 ignored / 0 skipped**. The failures did not reproduce in isolation; the parallel suite result above remains red, and this comparison does not establish whether the failures reproduce in the parent's parallel suite. **Not tested** Retail titles or archives, release mode, an intentional allocation failure on the parent, or a full parallel parent suite. **AI use** Ran via Samaritan: - OpenCode with OpenAI GPT-6.2 Sol (`openai/gpt-6.2-sol`): ran the recorded verification, recovered the saved logs, checked the results and drafted this report. The full model-selection history before the interrupted turn could not be verified.
Author
Owner

@⁠S1m0ne1997 on GitHub · 2026-11-25 14:50 UTC · original

Test report for 9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 752 passed, 0 failed, 41 ignored.
  • SKIPPED (2): gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64).

Regression run (retail title, scripts/smoke.ps1 -Seconds 60, release; main built from the commit in its block, this PR from its head with no changes to crates/, both run with the scripts/smoke.ps1 of main, which hashes the name of the game folder)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: 9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1658 (PresentX 1658)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16347 MB

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.

**@⁠S1m0ne1997** on GitHub · 2026-11-25 14:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1338#issuecomment-7165910503) Test report for `9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf` (this PR's head), for #1607. **Tested** - NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)` `x86_64-pc-windows-msvc`, debug. - `cargo build --workspace`, then `cargo test --workspace -- --test-threads=4` at the head: **752 passed, 0 failed, 41 ignored**. - SKIPPED (2): `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64). **Regression run** (retail title, `scripts/smoke.ps1 -Seconds 60`, release; `main` built from the commit in its block, this PR from its head with no changes to `crates/`, both run with the `scripts/smoke.ps1` of `main`, which hashes the name of the game folder) main: ``` xcl-smoke v1 commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324 gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1599 (PresentX 1599) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16384 MB ``` this PR: ``` xcl-smoke v1 commit: 9c9e2ca5251d23224e267f8b3f1a913e88ffdbdf gpu: NVIDIA GeForce RTX 4090 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1658 (PresentX 1658) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16347 MB ``` **Not tested** - AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only. *AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.*
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1338/head:github-bot/gh-1338'
git switch 'github-bot/gh-1338'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1338'
git switch 'github-bot/gh-1338'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1338'
git switch 'github-bot/gh-1338'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1338'
git switch 'main'
git merge --squash 'github-bot/gh-1338'
git switch 'main'
git merge --ff-only 'github-bot/gh-1338'
git switch 'main'
git merge 'github-bot/gh-1338'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.