Shaders: heap handles are reused only for the same resource properties #1953

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

@⁠RaghavVijayanand on GitHub · 2026-11-25 01:45 UTC · original
RaghavVijayanand:shader/image-atomics-64 → main · +70 −6 · 2 files · 1 commits · open

Lowering caches one annotated heap handle per block, descriptor load, first dword and sampler flag, but keyed it on the first dword of the resource properties only (kind and UAV bit). Two uses of one descriptor in the same block that differ in the second dword, such as an image_load (four F32) and an image atomic (one U32) on the same texture UAV, shared whichever handle was annotated first. The later access then ran with the other's component type. The key now holds both dwords.

This PR was opened as "64-bit image atomics". Upstream landed its own in 0b35b7f in the meantime, so that part is dropped and only this fix remains, rebased on current main.

Test: valu_tests::a_load_and_an_atomic_of_one_texture_have_their_own_handles lowers an image_load and 32-bit image atomics of one texture in one block, in both orders. It then checks, in the module dxc -dumpbin prints, that both a {4098, 1033} and a {4098, 261} handle exist.

  • dxil.dll accepts the mistyped handle, so the check has to read the module.
  • The test fails with the old key ("no handle annotated { i32 4098, i32 261 }") and passes with the fix.
  • It skips when dxc.exe is absent.

On this machine, 5 tests fail on current main itself, with or without this change:

  • descriptor::host::tests::dynamic_slots_are_held_until_released
  • memory::tests::lists_share_a_table_and_copies_keep_their_views
  • stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride
  • stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros
  • synthetic_tests::gathers_at_a_level_match_the_hardware

Everything else passes, and clippy passes with -D warnings, with and without --all-features.

**@⁠RaghavVijayanand** on GitHub · 2026-11-25 01:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953) `RaghavVijayanand:shader/image-atomics-64` → `main` · +70 −6 · 2 files · 1 commits · open Lowering caches one annotated heap handle per block, descriptor load, first dword and sampler flag, but keyed it on the **first** dword of the resource properties only (kind and UAV bit). Two uses of one descriptor in the same block that differ in the second dword, such as an `image_load` (four F32) and an image atomic (one U32) on the same texture UAV, shared whichever handle was annotated first. The later access then ran with the other's component type. The key now holds both dwords. This PR was opened as "64-bit image atomics". Upstream landed its own in 0b35b7f in the meantime, so that part is dropped and only this fix remains, rebased on current main. **Test:** `valu_tests::a_load_and_an_atomic_of_one_texture_have_their_own_handles` lowers an `image_load` and 32-bit image atomics of one texture in one block, in both orders. It then checks, in the module `dxc -dumpbin` prints, that both a `{4098, 1033}` and a `{4098, 261}` handle exist. - dxil.dll accepts the mistyped handle, so the check has to read the module. - The test fails with the old key ("no handle annotated { i32 4098, i32 261 }") and passes with the fix. - It skips when dxc.exe is absent. **On this machine, 5 tests fail on current main itself, with or without this change:** - `descriptor::host::tests::dynamic_slots_are_held_until_released` - `memory::tests::lists_share_a_table_and_copies_keep_their_views` - `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` - `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` - `synthetic_tests::gathers_at_a_level_match_the_hardware` Everything else passes, and clippy passes with `-D warnings`, with and without `--all-features`.
Lowering caches one annotated heap handle per block, descriptor load,
first dword and sampler flag, keyed on the first dword of the resource
properties only (kind and UAV bit). Two uses of one descriptor that
differ in the second dword, such as a typed load (four F32) and an
atomic (one U32) on the same texture UAV in one block, shared whichever
handle was annotated first, so the later one ran with the other's
component type. The key now holds both dwords.

valu_tests::a_load_and_an_atomic_of_one_texture_have_their_own_handles
lowers an image_load and 32-bit image atomics of one texture in one
block, in both orders, and checks in the module dxc -dumpbin prints
that both handles are there. dxil.dll accepts the mistyped handle, so
the check reads the module. It fails with the old key.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:49:56 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 01:51 UTC · original

Overlap note, from reading, not a run: this branch is based on ffe310e, which predates 0b35b7f on main. That commit already lowers 64-bit image atomics: the R32G32_UINT view with the low dword in R, i64 data, flags::INT64 | ATOMIC64_TYPED | ATOMIC64_HEAP, and the image_atomics_of_64_bits test. GitHub reports this PR as conflicting. #1899 was the same case. If something here isn't in main yet, rebasing it down to that part would keep it reviewable.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7150044581) Overlap note, from reading, not a run: this branch is based on `ffe310e`, which predates 0b35b7f on `main`. That commit already lowers 64-bit image atomics: the `R32G32_UINT` view with the low dword in R, i64 data, `flags::INT64 | ATOMIC64_TYPED | ATOMIC64_HEAP`, and the `image_atomics_of_64_bits` test. GitHub reports this PR as conflicting. #1899 was the same case. If something here isn't in `main` yet, rebasing it down to that part would keep it reviewable. AI-assisted (Claude Code).
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 02:01 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 7d9a51b applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 96 passed, 0 failed, 1 ignored. All tests pass. The new 64-bit image atomic tests are GPU-specific (require dxil.dll/WARP) and are skipped on Linux.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 2 errors (vs 4 on main). The PR net-reduces clippy errors by fixing unused imports.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 02:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7150221182) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `7d9a51b` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 96 passed, 0 failed, 1 ignored. All tests pass. The new 64-bit image atomic tests are GPU-specific (require dxil.dll/WARP) and are skipped on Linux. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 2 errors (vs 4 on main). The PR net-reduces clippy errors by fixing unused imports. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:18 UTC · original · edited 2026-11-25 16:02 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge candidate) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7150567154) · edited 2026-11-25 16:02 UTC <!-- victory-triage v1 head=de72d84eac51c69f0dc364ac3adfb337261dbaee verdict=needs-rebase at=2026-11-25T16:13:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-shader/src/emit/lower.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:02 UTC · original

Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at de72d84. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7157786195) **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `de72d84`. `cargo test --workspace --locked --no-fail-fast` -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 11:05 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head de72d84e onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 11:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7160572085) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head de72d84e onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
github-bot force-pushed github-bot/gh-1953 from de72d84eac to d6a30c63bc 2026-11-26 11:10:45 +00:00 Compare
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 01:45 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 01:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#pullrequestreview-6050341301) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 03:14 UTC · original · approved these changes

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. 64-bit image atomics — overlaps with #1899 (64-bit atomics, mixed gpu+shader, staticked earlier); whichever lands second must reconcile the DXIL i64 path.

**@⁠catminou4** on GitHub · 2026-11-25 03:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#pullrequestreview-6051314208) · **approved these changes** Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. 64-bit image atomics — **overlaps with #1899** (64-bit atomics, mixed gpu+shader, staticked earlier); whichever lands second must reconcile the DXIL i64 path.
Author
Owner

@⁠RaghavVijayanand on GitHub · 2026-11-26 10:29 UTC · original

Rebased onto main 63bcca4. The handle key now holds both property dwords in the entry-block and join-block handle caches main added since, too: the same mixup could happen there. On the overlap note: this PR is no longer about 64-bit image atomics (main has those). It only fixes the cache key. valu_tests::a_load_and_an_atomic_of_one_texture_have_their_own_handles and all lower/valu tests pass on an RTX 5060 Laptop; clippy clean.

**@⁠RaghavVijayanand** on GitHub · 2026-11-26 10:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7189431926) Rebased onto `main` 63bcca4. The handle key now holds both property dwords in the entry-block and join-block handle caches `main` added since, too: the same mixup could happen there. On the overlap note: this PR is no longer about 64-bit image atomics (`main` has those). It only fixes the cache key. `valu_tests::a_load_and_an_atomic_of_one_texture_have_their_own_handles` and all lower/valu tests pass on an RTX 5060 Laptop; clippy clean.
This pull request can be merged automatically.
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/1953/head:github-bot/gh-1953'
git switch 'github-bot/gh-1953'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1953'
git switch 'github-bot/gh-1953'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1953'
git switch 'github-bot/gh-1953'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1953'
git switch 'main'
git merge --squash 'github-bot/gh-1953'
git switch 'main'
git merge --ff-only 'github-bot/gh-1953'
git switch 'main'
git merge 'github-bot/gh-1953'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1953
No description provided.