Specialize typed buffers for direct compute dispatches #239

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

@⁠NemesisDawn on GitHub · 2026-11-23 06:40 UTC · original
NemesisDawn:issue105-compute-review → main · +1111 −52 · 14 files · 1 commits · draft

Adds opt-in typed buffer format selection for direct compute dispatches.
The runtime selects the matching integer pipeline, caches it for reuse,
and restores the original pipeline after dispatch.

Validation: Three targeted WARP shader tests passed. The RTX 5080 test
verified unsigned and signed writes, cache reuse, and pipeline restoration.

Disabled by default. Graphics and indirect dispatch remain outside this change.

Refs #105.

**@⁠NemesisDawn** on GitHub · 2026-11-23 06:40 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/239) `NemesisDawn:issue105-compute-review` → `main` · +1111 −52 · 14 files · 1 commits · draft Adds opt-in typed buffer format selection for direct compute dispatches. The runtime selects the matching integer pipeline, caches it for reuse, and restores the original pipeline after dispatch. Validation: Three targeted WARP shader tests passed. The RTX 5080 test verified unsigned and signed writes, cache reuse, and pipeline restoration. Disabled by default. Graphics and indirect dispatch remain outside this change. Refs #105.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:15:18 +00:00
Author
Owner

@⁠kiwe147 on GitHub · 2026-11-23 19:15 UTC · original

Tested head 8bb728c922, applied with git apply (whitespace ignored, the line endings of my checkout differ) on main f89e410, this PR alone. It applied without conflicts and built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1.

run result
tombox-xshader fast set and the tests this PR adds in exec (WARP and TOMBOX_EXEC_HW=1) 205 passed, 3 + 3 passed, 0 failed
d3d12_xs --lib -- --test-threads=1 670 passed, 1 failed (the same 1 fails on main: the console-dump fixture test needs console DLLs)
new hw_issue105_compute_switches_and_restores_pipeline, plain hw_ -- --ignored fails: it asserts TOMBOX_TBUF_COMPUTE=1 and then TOMBOX_PSO_ASYNC=0
the same test with TOMBOX_TBUF_COMPUTE=1 TOMBOX_PSO_ASYNC=0 passes (1 passed)

One crash with the switches on. With both variables set, the full hw_ run ends with STATUS_ACCESS_VIOLATION at hw_tests::device_place_hw::hw_structured_uav_on_a_sub_page_uav_buffer_keeps_the_device. On main with the same variables that test passes. It also passes with this PR alone. The pair reproduces it, 3 of 3 runs:

TOMBOX_TBUF_COMPUTE=1 TOMBOX_PSO_ASYNC=0 cargo test --locked -p d3d12_xs --lib -- --ignored --test-threads=1 hw_issue105 hw_structured_uav_on_a_sub_page_uav_buffer_keeps_the_device

The new test passes and the next test in the same process crashes, so I think the new test leaves state behind (for example in tbuf_compute). I did not trace it further. Without the switches no hw_ test crashes (53 passed; 10 failed: the 9 upload_ww_hw tests, which need the built xg_xs/xg_x dll and fail the same on main, plus the new test above).

AI-assisted: yes (Claude Code)

**@⁠kiwe147** on GitHub · 2026-11-23 19:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/239#issuecomment-7111321034) Tested head `8bb728c922`, applied with `git apply` (whitespace ignored, the line endings of my checkout differ) on `main` `f89e410`, this PR alone. It applied without conflicts and built. Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1. | run | result | |---|---| | `tombox-xshader` fast set and the tests this PR adds in `exec` (WARP and `TOMBOX_EXEC_HW=1`) | 205 passed, 3 + 3 passed, 0 failed | | `d3d12_xs --lib -- --test-threads=1` | 670 passed, 1 failed (the same 1 fails on `main`: the console-dump fixture test needs console DLLs) | | new `hw_issue105_compute_switches_and_restores_pipeline`, plain `hw_ -- --ignored` | fails: it asserts `TOMBOX_TBUF_COMPUTE=1` and then `TOMBOX_PSO_ASYNC=0` | | the same test with `TOMBOX_TBUF_COMPUTE=1 TOMBOX_PSO_ASYNC=0` | passes (1 passed) | **One crash with the switches on.** With both variables set, the full `hw_` run ends with `STATUS_ACCESS_VIOLATION` at `hw_tests::device_place_hw::hw_structured_uav_on_a_sub_page_uav_buffer_keeps_the_device`. On `main` with the same variables that test passes. It also passes with this PR alone. The pair reproduces it, 3 of 3 runs: ``` TOMBOX_TBUF_COMPUTE=1 TOMBOX_PSO_ASYNC=0 cargo test --locked -p d3d12_xs --lib -- --ignored --test-threads=1 hw_issue105 hw_structured_uav_on_a_sub_page_uav_buffer_keeps_the_device ``` The new test passes and the next test in the same process crashes, so I think the new test leaves state behind (for example in `tbuf_compute`). I did not trace it further. Without the switches no `hw_` test crashes (53 passed; 10 failed: the 9 `upload_ww_hw` tests, which need the built xg_xs/xg_x dll and fail the same on `main`, plus the new test above). AI-assisted: yes (Claude Code)
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:51 UTC · original

Thanks. Before this can be applied: kiwe147's repro (TOMBOX_TBUF_COMPUTE=1 TOMBOX_PSO_ASYNC=0 cargo test -p d3d12_xs --lib -- --ignored --test-threads=1 hw_issue105 hw_structured_uav_on_a_sub_page_uav_buffer_keeps_the_device) crashes the test after yours 3 of 3 times, so some state outlives the test. Two things to check: install() overwrites NEXT[idx] with whatever is in the slot, so a second install chains the hook to itself; and Plan keeps the device pointer without AddRef. Please also make the hw test skip (not fail) when the variables are not set, and mark the PR ready when done.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:51 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/239#issuecomment-7164387883) Thanks. Before this can be applied: kiwe147's repro (TOMBOX_TBUF_COMPUTE=1 TOMBOX_PSO_ASYNC=0 cargo test -p d3d12_xs --lib -- --ignored --test-threads=1 hw_issue105 hw_structured_uav_on_a_sub_page_uav_buffer_keeps_the_device) crashes the test after yours 3 of 3 times, so some state outlives the test. Two things to check: install() overwrites NEXT[idx] with whatever is in the slot, so a second install chains the hook to itself; and Plan keeps the device pointer without AddRef. Please also make the hw test skip (not fail) when the variables are not set, and mark the PR ready when done.
This pull request has changes conflicting with the target branch.
  • crates/tombox-xshader/src/hlsl.rs
  • crates/tombox-xshader/tests/exec.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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