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

Open
RaghavVijayanand wants to merge 1 commit from upstream-pr/1953 into main
RaghavVijayanand commented 2026-11-25 01:45:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RaghavVijayanand on 2026-11-25T01:45:07Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6595219988 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-25T01:45:07Z. --- 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`.
copilot-pull-request-reviewer[bot commented 2026-11-25 02:05:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T01:45:15Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050341301 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#pullrequestreview-6050341301). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-25T01:45:15Z. **Review:** COMMENTED --- 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.
upipibi commented 2026-11-25 02:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T01:51:46Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150044581 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7150044581). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T01:51:46Z. --- 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).
Headache3318 commented 2026-11-25 02:06:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T02:01:03Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150221182 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7150221182). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T02:01:03Z. --- 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.
upstream-sync changed title from [PR #1953] Shaders: 64-bit image atomics to [PR #1953] Shaders: heap handles are reused only for the same resource properties 2026-11-25 03:02:58 +00:00
Marvisak commented 2026-11-25 03:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:18:53Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150567154 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7150567154). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:18:53Z. --- <!-- 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)_
catminou4 commented 2026-11-25 04:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:14:09Z.

Review: APPROVED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051314208 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#pullrequestreview-6051314208). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:14:09Z. **Review:** APPROVED --- 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.
StExpeditus commented 2026-11-25 05:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T04:23:42Z.


Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at de72d84. cargo test --workspace --locked --no-fail-fast -> all green: 0 passed, 0 ignored, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152802653 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7152802653). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T04:23:42Z. --- **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `de72d84`. `cargo test --workspace --locked --no-fail-fast` -> **all green**: 0 passed, 0 ignored, 0 failed.
StExpeditus commented 2026-11-25 09:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:02:06Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157786195 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7157786195). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:02:06Z. --- **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.
sinan-cmyk commented 2026-11-25 11:05:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T11:05:25Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160572085 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7160572085). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T11:05:25Z. --- ### 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).
RaghavVijayanand commented 2026-11-26 11:04:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RaghavVijayanand on 2026-11-26T10:29:19Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189431926 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1953#issuecomment-7189431926). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-26T10:29:19Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1953:upstream-pr/1953'
git switch 'upstream-pr/1953'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1953'
git switch 'upstream-pr/1953'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1953'
git switch 'upstream-pr/1953'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1953'
git switch 'main'
git merge --squash 'upstream-pr/1953'
git switch 'main'
git merge --ff-only 'upstream-pr/1953'
git switch 'main'
git merge 'upstream-pr/1953'
git push origin 'main'
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
Marvisak/VIctory!1951
No description provided.