launcher: run DXC -O0 fallback through helper with simplifycfg and warm-cache fast paths #479

Merged
glovepost merged 1 commit from upstream-pr/479 into main 2026-11-29 14:36:44 +00:00
glovepost commented 2026-11-29 14:25:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-29T14:25:08Z.


Summary

Route the DXC -O0 fallback through the persistent dxc_worker helper and eliminate avoidable launcher/cache-prep I/O overhead so large shaders compile faster and warm launches skip redundant work:

  • Helper -O0 compilation + -simplifycfg: tools/dxc_worker.cpp now accepts -O0 and runs LLVM -simplifycfg on -O0 DXIL bitcode before attaching WaveSize metadata and assembling the container, reducing branch bloat on unoptimized fallbacks. In project_tuxbox/runtime_shaders.py, -O0 sources route through the persistent helper with -O0 -opt-disable debug-nops (plus -fdisable-loc-tracking when the source exceeds 1 MiB) and fall back cleanly through CLI tiers if flags are unsupported. On a 1.06 MiB cs_6_6 -O0 compilation, this reduced DXIL br label branches from 10023 (3.13 s) to 5029 (2.39 s) with dxv clean.
  • Warm-cache and DXC helper fast paths: project_tuxbox/dxil_store.py and project_tuxbox/runtime_shaders.py add copy-on-write reply cloning (fcntl.FICLONE for replies >= 64 KiB), single-pass DXC/DXV digesting, early release of loaded source/pixel byte buffers, removal of the duplicate portable_stage check in reuse_content, and os.scandir in ordered_requests.
  • Shader-prep and cache-merge speedups: project_tuxbox/scarlett_prep.py schedules largest requests first, caps prep_jobs against MemAvailable (~1.5 GiB per worker, ceiling 32), and writes a stat-keyed .prep-verified.json manifest so warm runs skip re-validating unchanged shaders (TUXBOX_SHADER_PREP_VERIFY=1 forces full verification, documented in docs/ENVIRONMENT.md and docs/PROJECTSCARLETT.md). project_tuxbox/vkd3d_cache.py merges .cache.write using read-only mmap spans instead of copying full byte arrays.
  • Tests: covered by new unit tests in tests/test_dxc_worker.py (exercising real dxc/dxv), tests/test_runtime_shader_links.py, tests/test_scarlett_prep.py, and tests/test_shader_pack.py, plus the five shader Lanes suites run on both NVIDIA and AMD.

Drafted with AI assistance and verified with the CPU suite and dual-GPU Lanes runs listed below.

Tested

Run the checks relevant to this change.

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both.

GPU, driver and backend:

  • NVIDIA GeForce RTX 2070 SUPER (10de:1e84), NVIDIA driver 620.73.04, GE-Proton11-14 + vkd3d-proton
  • AMD Ryzen 7 9800X3D integrated GPU (1002:13c0), Mesa 26.3.1-arch3.5 (RADV RAPHAEL_MENDOCINO), GE-Proton11-14 + vkd3d-proton

Commands run and their results:

DXC=<dxc> python3 tuxbox.py check --no-gpu
  7/7 checks passed:
  - Python unit suite: 639 tests passed (including test_dxc_worker with real dxc/dxv)
  - tools/shader-compiler: 592 passed
  - crates/tuxbox-dxbc: 96 passed
  - crates/tuxbox-xg: 17 passed, 1 ignored
  - crates/tuxbox-storage: 18 passed
  - runtime/d3d12 Windows typecheck: passed
  - repository hygiene: passed

python3 tuxbox.py verify --proton <proton> --prefix <prefix> --pci 10de:1e84 --suite lanes-shader-cache --suite lanes-raster-tables --suite lanes-compute-root --suite lanes-compute-root-recovery --suite lanes-bindless-compute --json-out <output>
  39/39 scenarios passed (NVIDIA)

python3 tuxbox.py verify --proton <proton> --prefix <prefix> --pci 1002:13c0 --suite lanes-shader-cache --suite lanes-raster-tables --suite lanes-compute-root --suite lanes-compute-root-recovery --suite lanes-bindless-compute --json-out <output>
  39/39 scenarios passed (AMD)

Checks

CI runs the Python unit tests, the shader compiler, DXBC, and XG layout tests, and a Windows typecheck of tuxbox-d3d12.

If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files:

python tuxbox.py status > docs/RESULTS.md
python tuxbox.py status --svg docs/progress.svg
<!-- greyfinch-sync:brcly/TuxBox:issue:5551643750 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/479). Originally posted by [glovepost](https://github.com/glovepost) on 2026-11-29T14:25:08Z. --- ## Summary Route the DXC `-O0` fallback through the persistent `dxc_worker` helper and eliminate avoidable launcher/cache-prep I/O overhead so large shaders compile faster and warm launches skip redundant work: - **Helper `-O0` compilation + `-simplifycfg`**: `tools/dxc_worker.cpp` now accepts `-O0` and runs LLVM `-simplifycfg` on `-O0` DXIL bitcode before attaching `WaveSize` metadata and assembling the container, reducing branch bloat on unoptimized fallbacks. In `project_tuxbox/runtime_shaders.py`, `-O0` sources route through the persistent helper with `-O0 -opt-disable debug-nops` (plus `-fdisable-loc-tracking` when the source exceeds 1 MiB) and fall back cleanly through CLI tiers if flags are unsupported. On a 1.06 MiB `cs_6_6` `-O0` compilation, this reduced DXIL `br label` branches from `10023` (`3.13 s`) to `5029` (`2.39 s`) with `dxv` clean. - **Warm-cache and DXC helper fast paths**: `project_tuxbox/dxil_store.py` and `project_tuxbox/runtime_shaders.py` add copy-on-write reply cloning (`fcntl.FICLONE` for replies >= 64 KiB), single-pass DXC/DXV digesting, early release of loaded source/pixel byte buffers, removal of the duplicate `portable_stage` check in `reuse_content`, and `os.scandir` in `ordered_requests`. - **Shader-prep and cache-merge speedups**: `project_tuxbox/scarlett_prep.py` schedules largest requests first, caps `prep_jobs` against `MemAvailable` (~1.5 GiB per worker, ceiling 32), and writes a stat-keyed `.prep-verified.json` manifest so warm runs skip re-validating unchanged shaders (`TUXBOX_SHADER_PREP_VERIFY=1` forces full verification, documented in `docs/ENVIRONMENT.md` and `docs/PROJECTSCARLETT.md`). `project_tuxbox/vkd3d_cache.py` merges `.cache.write` using read-only `mmap` spans instead of copying full byte arrays. - **Tests**: covered by new unit tests in `tests/test_dxc_worker.py` (exercising real `dxc`/`dxv`), `tests/test_runtime_shader_links.py`, `tests/test_scarlett_prep.py`, and `tests/test_shader_pack.py`, plus the five shader Lanes suites run on both NVIDIA and AMD. Drafted with AI assistance and verified with the CPU suite and dual-GPU Lanes runs listed below. ## Tested Run the [checks relevant to this change](../CONTRIBUTING.md#test-what-your-change-touches). - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [x] Where the table calls for AMD and NVIDIA, they passed on both. GPU, driver and backend: - NVIDIA GeForce RTX 2070 SUPER (`10de:1e84`), NVIDIA driver `620.73.04`, GE-Proton11-14 + vkd3d-proton - AMD Ryzen 7 9800X3D integrated GPU (`1002:13c0`), Mesa `26.3.1-arch3.5` (RADV RAPHAEL_MENDOCINO), GE-Proton11-14 + vkd3d-proton Commands run and their results: ```text DXC=<dxc> python3 tuxbox.py check --no-gpu 7/7 checks passed: - Python unit suite: 639 tests passed (including test_dxc_worker with real dxc/dxv) - tools/shader-compiler: 592 passed - crates/tuxbox-dxbc: 96 passed - crates/tuxbox-xg: 17 passed, 1 ignored - crates/tuxbox-storage: 18 passed - runtime/d3d12 Windows typecheck: passed - repository hygiene: passed python3 tuxbox.py verify --proton <proton> --prefix <prefix> --pci 10de:1e84 --suite lanes-shader-cache --suite lanes-raster-tables --suite lanes-compute-root --suite lanes-compute-root-recovery --suite lanes-bindless-compute --json-out <output> 39/39 scenarios passed (NVIDIA) python3 tuxbox.py verify --proton <proton> --prefix <prefix> --pci 1002:13c0 --suite lanes-shader-cache --suite lanes-raster-tables --suite lanes-compute-root --suite lanes-compute-root-recovery --suite lanes-bindless-compute --json-out <output> 39/39 scenarios passed (AMD) ``` ## Checks CI runs the Python unit tests, the shader compiler, DXBC, and XG layout tests, and a Windows typecheck of `tuxbox-d3d12`. If this pull request changes evidence JSON, regenerate the results table and the progress map and include both files: ```sh python tuxbox.py status > docs/RESULTS.md python tuxbox.py status --svg docs/progress.svg ```
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
brcly/TuxBox!479
No description provided.