Shaders: run DXIL IR optimization pass in direct translator #1537

Closed
Roroca-1 wants to merge 4 commits from upstream-pr/1547 into main
Roroca-1 commented 2026-11-24 17:29:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Roroca-1 on 2026-11-24T17:29:46Z.


Retired after #1426 merged. Compute and graphics shader finalization already call the optimizer, and main already advanced the translator cache version to 4. Enabling this second pass would run both optimizers. The original branch is preserved.

Turns on the DXIL IR optimization and compaction pass in kernel::translate_on_this_thread and bumps kernel::TRANSLATOR_VERSION to 3 so cached unoptimized containers are invalidated.

Part of #1269.
Stacked on #1546; only the top commit belongs here.

The merged #1426 already invokes Module::optimize during shader finalization and sets TRANSLATOR_VERSION to 4. This branch conflicts with main and its proposed version 3 predates that change.

What is in it

  • crates/xcl/src/gpu/dxil/kernel.rs: bump TRANSLATOR_VERSION from 2 to 3 and call lw.s.optimize(); after checking exchange_error in translate_on_this_thread.

Tested

  • AMD Radeon RX 9070 XT (RADV GFX1201, radv 26.3.1) under Wine + vkd3d-proton (proton-cachyos-slr) + DXVK, cross-built from Linux to x86_64-pc-windows-msvc via cargo-xwin, debug, commit f349ef0bbe60:
  • TARGET_CFLAGS="/FIstring.h" cargo xwin build --tests -p xcl --target x86_64-pc-windows-msvc: 0 errors, 0 warnings
  • wine xcl.exe gpu::dxil::opt --nocapture --test-threads=1: 9 passed, 0 failed, 0 ignored (809 filtered out; 0 SKIPPED)
  • wine xcl.exe gpu::dxil::module::tests --nocapture: 1 passed, 0 failed, 0 ignored
  • wine xcl.exe gpu::dxil::bitreader_tests --test-threads=4: 3 passed, 0 failed, 0 ignored
  • wine xcl.exe gpu::dxil::robustness_tests --test-threads=4: 7 passed, 1 failed (translation_is_byte_identical_across_runs_and_threads: dxcompiler.dll not found), 0 ignored
  • wine xcl.exe gpu::dxil --test-threads=4: 32 passed, 54 failed, 2 ignored (all 54 failures solely due to dxcompiler.dll not found in Wine; SKIPPED: direct_and_hlsl_graphics_stages_link: no DXC, double_unary_legality_matches_dxil_tables)

Regression run

Pending native Windows GPU workspace tests and paired scripts/smoke.ps1 runs on the same retail title and duration at clean main and PR head. Path coverage must be recorded with the results.

Not tested

  • Windows native MSVC build and full .\scripts\test.ps1 workspace test suite
  • dxcompiler.dll DXIL validation and disassembly (unavailable locally under Wine)
  • Direct-translator gpu::recomp tests with XCL_DIRECT_DXIL=1 in debug/test mode (requires dxcompiler.dll in kernel.rs)
  • scripts/smoke.ps1 regression run on retail game titles (marked draft until run on Windows)

AI use

  • T3 Code (Antigravity harness, gemini-pro-orchestrator-neon): wired lw.s.optimize() and TRANSLATOR_VERSION bump in kernel.rs, drafted this description, and ran the cargo-xwin / Wine + RX 9070 XT tests.
  • T3 Code (Codex, gpt-6.2-astra) checked upstream overlap and updated the review status.
<!-- greyfinch-sync:ivall/xcl:issue:6587638581 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1547). Originally posted by [Roroca-1](https://github.com/Roroca-1) on 2026-11-24T17:29:46Z. --- Retired after #1426 merged. Compute and graphics shader finalization already call the optimizer, and main already advanced the translator cache version to 4. Enabling this second pass would run both optimizers. The original branch is preserved. Turns on the DXIL IR optimization and compaction pass in `kernel::translate_on_this_thread` and bumps `kernel::TRANSLATOR_VERSION` to `3` so cached unoptimized containers are invalidated. Part of #1269. Stacked on #1546; only the top commit belongs here. The merged #1426 already invokes `Module::optimize` during shader finalization and sets `TRANSLATOR_VERSION` to 4. This branch conflicts with `main` and its proposed version 3 predates that change. **What is in it** - `crates/xcl/src/gpu/dxil/kernel.rs`: bump `TRANSLATOR_VERSION` from `2` to `3` and call `lw.s.optimize();` after checking `exchange_error` in `translate_on_this_thread`. **Tested** - AMD Radeon RX 9070 XT (RADV GFX1201, radv 26.3.1) under Wine + vkd3d-proton (`proton-cachyos-slr`) + DXVK, cross-built from Linux to `x86_64-pc-windows-msvc` via `cargo-xwin`, debug, commit `f349ef0bbe60`: - `TARGET_CFLAGS="/FIstring.h" cargo xwin build --tests -p xcl --target x86_64-pc-windows-msvc`: 0 errors, 0 warnings - `wine xcl.exe gpu::dxil::opt --nocapture --test-threads=1`: 9 passed, 0 failed, 0 ignored (`809 filtered out`; 0 `SKIPPED`) - `wine xcl.exe gpu::dxil::module::tests --nocapture`: 1 passed, 0 failed, 0 ignored - `wine xcl.exe gpu::dxil::bitreader_tests --test-threads=4`: 3 passed, 0 failed, 0 ignored - `wine xcl.exe gpu::dxil::robustness_tests --test-threads=4`: 7 passed, 1 failed (`translation_is_byte_identical_across_runs_and_threads`: `dxcompiler.dll not found`), 0 ignored - `wine xcl.exe gpu::dxil --test-threads=4`: 32 passed, 54 failed, 2 ignored (all 54 failures solely due to `dxcompiler.dll not found` in Wine; `SKIPPED`: `direct_and_hlsl_graphics_stages_link: no DXC`, `double_unary_legality_matches_dxil_tables`) **Regression run** Pending native Windows GPU workspace tests and paired `scripts/smoke.ps1` runs on the same retail title and duration at clean `main` and PR head. Path coverage must be recorded with the results. **Not tested** - Windows native MSVC build and full `.\scripts\test.ps1` workspace test suite - `dxcompiler.dll` DXIL validation and disassembly (unavailable locally under Wine) - Direct-translator `gpu::recomp` tests with `XCL_DIRECT_DXIL=1` in debug/test mode (requires `dxcompiler.dll` in `kernel.rs`) - `scripts/smoke.ps1` regression run on retail game titles (marked draft until run on Windows) **AI use** - T3 Code (Antigravity harness, gemini-pro-orchestrator-neon): wired `lw.s.optimize()` and `TRANSLATOR_VERSION` bump in `kernel.rs`, drafted this description, and ran the `cargo-xwin` / Wine + RX 9070 XT tests. - T3 Code (Codex, gpt-6.2-astra) checked upstream overlap and updated the review status.
upstream-sync closed this pull request 2026-11-24 21:06:34 +00:00
DavidM1911 commented 2026-11-24 21:08:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:19:13Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7141922596 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1547#issuecomment-7141922596). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T19:19:13Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.

Pull request closed

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!1537
No description provided.