Shaders: query a buffer's size through a handle of its own #2120

Open
imjustprism wants to merge 1 commit from upstream-pr/2122 into main
imjustprism commented 2026-11-25 05:31:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by imjustprism on 2026-11-25T05:31:44Z.


amd's driver 32.0.32029.2010 on an rx 9070 xt faults in its shader compiler
when one buffer handle feeds both a size query whose result is used and a
load. a buffer's size query now always takes a handle of its own, from caches
of its own, so no load shares it. a query nothing reads is dropped by the
writer together with its handle.

rewritten on 13f91ca: with 850b66f's entry-block handle cache the old branch
no longer compiled against main, and the size query was back on the loads'
handle. the uses analysis is gone, the writer's liveness does that job now.

rebased again onto 63bcca4 (bf526d7). the lowering change is the one from
6ff2361, line for line. the five unit tests moved to
emit/lower/tests/size_handles.rs, unchanged: with them in lower.rs the file
was 528,047 bytes on the new main, over the 524,288 of cargo xtask policy.
it is 522,494 now.

the new gpu test runs on hardware and warp. with the size query forced back
onto the loads' handle it kills the test process on the 9070 xt at pipeline
creation. translate --cache --pipelines and the title were not run on this
head.

the extra handle is emitted on every host, so this is how far it reaches:

emitted dxil main this branch change
programs translated 26,177 26,177
programs emitted 25,752 25,752
dump files that differ 666 of 25,734 2.6% of them
bytes of those 666 files 85,965,845 86,015,013 +49,168, about 74 each

translate --list with VICTORY_EMIT_DUMP, release builds of 13f91ca and
6ff2361, one run each, dumps compared file by file. 25,752 programs make
25,734 files because some share a dump file name. the other 25,068 files are
byte for byte the same, and refusals are the same on both, reason by reason.
the shader cache is keyed by the translator's source, so every program is
translated again once, as after any translator change.

fixes #1783
fixes #1785
refs #2124
refs #2517

<!-- greyfinch-sync:Marvisak/VIctory:issue:5485766531 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122). Originally posted by [imjustprism](https://github.com/imjustprism) on 2026-11-25T05:31:44Z. --- amd's driver 32.0.32029.2010 on an rx 9070 xt faults in its shader compiler when one buffer handle feeds both a size query whose result is used and a load. a buffer's size query now always takes a handle of its own, from caches of its own, so no load shares it. a query nothing reads is dropped by the writer together with its handle. rewritten on 13f91ca: with 850b66f's entry-block handle cache the old branch no longer compiled against main, and the size query was back on the loads' handle. the uses analysis is gone, the writer's liveness does that job now. rebased again onto 63bcca4 (bf526d7). the lowering change is the one from 6ff2361, line for line. the five unit tests moved to emit/lower/tests/size_handles.rs, unchanged: with them in lower.rs the file was 528,047 bytes on the new main, over the 524,288 of cargo xtask policy. it is 522,494 now. the new gpu test runs on hardware and warp. with the size query forced back onto the loads' handle it kills the test process on the 9070 xt at pipeline creation. translate --cache --pipelines and the title were not run on this head. the extra handle is emitted on every host, so this is how far it reaches: | emitted dxil | main | this branch | change | |---|---|---|---| | programs translated | 26,177 | 26,177 | | | programs emitted | 25,752 | 25,752 | | | dump files that differ | | 666 of 25,734 | 2.6% of them | | bytes of those 666 files | 85,965,845 | 86,015,013 | +49,168, about 74 each | translate --list with VICTORY_EMIT_DUMP, release builds of 13f91ca and 6ff2361, one run each, dumps compared file by file. 25,752 programs make 25,734 files because some share a dump file name. the other 25,068 files are byte for byte the same, and refusals are the same on both, reason by reason. the shader cache is keyed by the translator's source, so every program is translated again once, as after any translator change. fixes #1783 fixes #1785 refs #2124 refs #2517
upipibi commented 2026-11-25 06:02:48 +00:00 (Migrated from github.com)

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


Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at e14ee3d. victory-shader: 250 passed, 3 failed, 3 ignored. The 6 new stride_tests pass (a_buffers_size_query_does_not_share_its_handle_with_the_loads, a_buffers_unread_size_shares_the_handle_of_the_loads, a_buffers_size_read_as_its_loads_offset_has_a_handle_of_its_own, an_images_size_read_as_data_shares_the_handle_of_its_sample, a_buffers_base_in_a_scalar_load_is_not_a_read_of_its_size, a_raw_buffer_is_sized_and_read_through_one_descriptor_load). The 3 failures are #1744's NVIDIA failures on main. Two of them are in the same file, a_heap_buffer_read_by_element_takes_the_views_stride and a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, and they still fail here, so this PR doesn't change them. Same as main on this hardware.


Added 21:33Z: re-run at the current head 6ff2361 (base 13f91ca), same RTX 3070, driver 616.56, debug, cargo test --locked -p victory-shader with heap_direct_texture_reads_mark_their_heap_index skipped (it crashes the test process on this card on main, #2571): 272 passed, 3 failed, no SKIPPED lines. The PR's six new tests all pass: a_buffers_size_query_does_not_share_its_handle_with_the_loads, a_buffer_at_a_computed_table_offset_is_sized_through_its_own_handle, a_buffer_sized_at_each_of_its_reloads_has_one_size_handle, a_buffers_unread_size_query_writes_no_handle, an_images_size_read_as_data_shares_the_handle_of_its_sample (lower::tests) and stride_tests::a_raw_buffers_size_beside_its_loads_reads_its_byte_count. The 3 failures are the #1744 NVIDIA ones that fail on main on this card too (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).

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153958562 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7153958562). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T05:36:46Z. --- Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `e14ee3d`. `victory-shader`: 250 passed, 3 failed, 3 ignored. The 6 new `stride_tests` pass (`a_buffers_size_query_does_not_share_its_handle_with_the_loads`, `a_buffers_unread_size_shares_the_handle_of_the_loads`, `a_buffers_size_read_as_its_loads_offset_has_a_handle_of_its_own`, `an_images_size_read_as_data_shares_the_handle_of_its_sample`, `a_buffers_base_in_a_scalar_load_is_not_a_read_of_its_size`, `a_raw_buffer_is_sized_and_read_through_one_descriptor_load`). The 3 failures are #1744's NVIDIA failures on `main`. Two of them are in the same file, `a_heap_buffer_read_by_element_takes_the_views_stride` and `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, and they still fail here, so this PR doesn't change them. Same as `main` on this hardware. --- **Added 21:33Z: re-run at the current head `6ff2361`** (base `13f91ca`), same RTX 3070, driver 616.56, debug, `cargo test --locked -p victory-shader` with `heap_direct_texture_reads_mark_their_heap_index` skipped (it crashes the test process on this card on `main`, #2571): 272 passed, 3 failed, no SKIPPED lines. The PR's six new tests all pass: `a_buffers_size_query_does_not_share_its_handle_with_the_loads`, `a_buffer_at_a_computed_table_offset_is_sized_through_its_own_handle`, `a_buffer_sized_at_each_of_its_reloads_has_one_size_handle`, `a_buffers_unread_size_query_writes_no_handle`, `an_images_size_read_as_data_shares_the_handle_of_its_sample` (`lower::tests`) and `stride_tests::a_raw_buffers_size_beside_its_loads_reads_its_byte_count`. The 3 failures are the #1744 NVIDIA ones that fail on `main` on this card too (`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`). AI-assisted (Claude Code, Claude Opus 5.5).
catminou4 commented 2026-11-25 06:40:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T06:40:56Z.

Review: APPROVED


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

149 passed / 0 failed / 2 ignored. Buffer size queried through its own handle (+5 tests) — descriptor-handle-based sizing; biggest test addition of this wave.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052991725 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#pullrequestreview-6052991725). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T06:40:56Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 149 passed / 0 failed / 2 ignored. Buffer size queried through its own handle (+5 tests) — descriptor-handle-based sizing; biggest test addition of this wave.
DenRakEiw commented 2026-11-25 06:46:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T06:46:08Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib a_buffers_ — 4 passed, 0 failed (a_buffers_size_query_does_not_share_its_handle_with_the_loads, a_buffers_unread_size_shares_the_handle_of_the_loads, etc.)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean separation of buffer size-query handles when the buffer size is read as data. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6053038646 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#pullrequestreview-6053038646). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T06:46:08Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib a_buffers_` — **4 passed, 0 failed** (`a_buffers_size_query_does_not_share_its_handle_with_the_loads`, `a_buffers_unread_size_shares_the_handle_of_the_loads`, etc.) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean separation of buffer size-query handles when the buffer size is read as data. Looks good. AI-assisted (Gemini 4 Neon).
fiestorra commented 2026-11-25 07:03:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-25T06:16:31Z.


Verified the "census is unchanged" claim here, and two things I would add before it lands

Measured on this machine (RTX 4090, 32.0.16.2124, release build, local 1.0.2.1 archive, 26,503 containers, validator SDK 10.0.26100 dxil.dll 1.9):

validated 23,918   (main 940d32f: 23,918)

So the claim holds, and it is the right claim for this change — the fix is about what the driver's compiler is handed, not about whether modules validate.

First, the workaround should carry the reason in the code. The description names it precisely — AMD's 32.0.32029.2010 on an RX 9070 XT faults when one buffer heap handle feeds both a size query whose result is used and a load — but a reader of lower.rs in six months will see an extra handle and no way to know it is not redundant. A comment naming the driver version, the card and the crash is what stops it being removed by someone tidying up, and this repository has already lost time this week to a missing line of explanation.

Second, the number I would want in the description: how many programs' emitted DXIL changes. The extra handle is emitted wherever the pattern occurs, on every host, not only on the one with the faulty compiler — so:

  • the shader cache invalidates for those programs once (expected, worth saying);
  • any before/after of translation time or module size that someone measures next week has to know the baseline moved;
  • and if the pattern turns out to be common, the "one extra createHandleFromHeap per program" is worth a sentence on cost, because this is the path that runs for every buffer size query in the title.

Your heap_handles counter under #[cfg(test)] suggests you already have that number — it just is not in the description, and "census unchanged" does not cover it, because a module can validate identically while its code differs.

Two smaller things I checked and like:

  • the pattern is detected from what an instruction reads as data, with the descriptor-naming registers excluded and the soffset case handled — that is the part that would have been easy to get subtly wrong, and the helper is written so it can be tested on its own;
  • heap_handles is test-only, so nothing in a release build pays for the instrumentation.

What I could not check: the crash itself, since this machine has neither the card nor that driver. The evidence for the fix's purpose is yours, and I am reviewing the shape of it rather than re-running your failure.

No game data is involved: counts, a driver version and code.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154622373 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7154622373). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-25T06:16:31Z. --- **Verified the "census is unchanged" claim here, and two things I would add before it lands** Measured on this machine (RTX 4090, `32.0.16.2124`, release build, local 1.0.2.1 archive, 26,503 containers, validator SDK 10.0.26100 `dxil.dll` 1.9): ``` validated 23,918 (main 940d32f: 23,918) ``` So the claim holds, and it is the right claim for this change — the fix is about what the driver's compiler is handed, not about whether modules validate. **First, the workaround should carry the reason in the code.** The description names it precisely — AMD's `32.0.32029.2010` on an RX 9070 XT faults when one buffer heap handle feeds both a size query whose result is used and a load — but a reader of `lower.rs` in six months will see an extra handle and no way to know it is not redundant. A comment naming the driver version, the card and the crash is what stops it being removed by someone tidying up, and this repository has already lost time this week to a missing line of explanation. **Second, the number I would want in the description: how many programs' emitted DXIL changes.** The extra handle is emitted wherever the pattern occurs, on **every** host, not only on the one with the faulty compiler — so: - the shader cache invalidates for those programs once (expected, worth saying); - any before/after of translation time or module size that someone measures next week has to know the baseline moved; - and if the pattern turns out to be common, the "one extra `createHandleFromHeap` per program" is worth a sentence on cost, because this is the path that runs for every buffer size query in the title. Your `heap_handles` counter under `#[cfg(test)]` suggests you already have that number — it just is not in the description, and "census unchanged" does not cover it, because a module can validate identically while its code differs. Two smaller things I checked and like: - **the pattern is detected from what an instruction reads as data**, with the descriptor-naming registers excluded and the `soffset` case handled — that is the part that would have been easy to get subtly wrong, and the helper is written so it can be tested on its own; - **`heap_handles` is test-only**, so nothing in a release build pays for the instrumentation. What I could not check: the crash itself, since this machine has neither the card nor that driver. The evidence for the fix's purpose is yours, and I am reviewing the shape of it rather than re-running your failure. No game data is involved: counts, a driver version and code. Written with an AI assistant.
imjustprism commented 2026-11-25 08:06:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by imjustprism on 2026-11-25T07:30:09Z.


thanks for running the census on the 4090. the reason is already in the code: the rustdoc on the size query in lower.rs names the driver, the card and the fault, and what does and does not trip it. the count was missing, it is in the description now: 333 of 25,678 emitted programs change, about 100 bytes each. the cache is keyed by the translator's source, so it retranslates once like after any translator change.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155930070 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7155930070). Originally posted by [imjustprism](https://github.com/imjustprism) on 2026-11-25T07:30:09Z. --- thanks for running the census on the 4090. the reason is already in the code: the rustdoc on the size query in lower.rs names the driver, the card and the fault, and what does and does not trip it. the count was missing, it is in the description now: 333 of 25,678 emitted programs change, about 100 bytes each. the cache is keyed by the translator's source, so it retranslates once like after any translator change.
sinan-cmyk commented 2026-11-25 09:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T08:31:09Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head e14ee3d8 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:7157123894 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7157123894). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T08:31:09Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head e14ee3d8 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).
Marvisak commented 2026-11-25 11:05:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:46:39Z.


Automated triage for the maintainers.

Merge candidate. Thanks for answering the request. Head bf526d7 is rebased onto 63bcca4 with the same lowering as 6ff2361. Lower::descriptor_data (crates/victory-shader/src/emit/lower.rs) makes a buffer's size handle through swap_size_caches, so no load shares it, and image handles stay shared. The five unit tests moved unchanged into emit/lower/tests/size_handles.rs, which the mod size_handles; inside lower.rs's test module points to. That keeps lower.rs at 522,494 bytes, under the 524,288-byte policy limit.

The RX 9070 XT check I asked for is covered twice. MeMako's independent run at 6ff2361 created 25,665 of 25,665 pipelines with no amdxc64.dll fault, and your run on this head passed. Linking #2124 and #2517 as refs rather than fixes is the right call. A structured-buffer case in the GPU test would still be a useful follow-up, but it shouldn't block this.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160158778 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7160158778). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:46:39Z. --- <!-- victory-triage v1 head=bf526d765fc16ac3ae190deee355fb83acdafd77 verdict=merge-candidate at=2026-11-26T07:21:50Z --> Automated triage for the maintainers. **Merge candidate.** Thanks for answering the request. Head `bf526d7` is rebased onto `63bcca4` with the same lowering as `6ff2361`. `Lower::descriptor_data` (`crates/victory-shader/src/emit/lower.rs`) makes a buffer's size handle through `swap_size_caches`, so no load shares it, and image handles stay shared. The five unit tests moved unchanged into `emit/lower/tests/size_handles.rs`, which the `mod size_handles;` inside `lower.rs`'s test module points to. That keeps `lower.rs` at 522,494 bytes, under the 524,288-byte policy limit. The RX 9070 XT check I asked for is covered twice. MeMako's independent run at `6ff2361` created 25,665 of 25,665 pipelines with no `amdxc64.dll` fault, and your run on this head passed. Linking #2124 and #2517 as refs rather than fixes is the right call. A structured-buffer case in the GPU test would still be a useful follow-up, but it shouldn't block this. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync changed title from [PR #2122] query a buffer's size through its own handle when the size is read to [PR #2122] query a buffer's size through a handle of its own 2026-11-25 21:02:16 +00:00
MeMako commented 2026-11-26 01:04:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MeMako on 2026-11-26T00:21:42Z.


Independent RX 9070 XT verification at current head 6ff2361 (AMD Radeon RX 9070 XT adapter 0, driver 32.0.32029.2010, Windows 11 10.0.26200 x64, SDK 10.0.26100.0 dxil.dll).

Tests & CI checks on 6ff2361:

  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass
  • cargo test --workspace --locked: pass (victory-shader: 276 passed, 0 failed, 3 ignored — all 6 new tests pass on RX 9070 XT, WARP, and dxil.dll)

Offline pipeline stress test on 6ff2361 (release build, translate --validate --pipelines --jobs 8 on the 1.0.2.1 shader pack, 26,503 containers, 1,134 s):

  • Vertex & pixel: 14,242 / 14,242 pipelines created (14,242 validated)
  • Compute: 2,658 / 2,658 pipelines created (1,910 validated)
  • Mesh: 8,765 / 8,765 pipelines created (8,694 validated)
  • Total: 25,665 / 25,665 emitted shaders compiled into host D3D12 pipelines across 8 concurrent threads with 0 amdxc64.dll+0x861b9f crashes.

Not run on 6ff2361: translate --cache --pipelines library pre-build or a live title run.

Notes before landing on current main (63bcca4):

  • 512 KiB policy limit on lower.rs: A dry-run merge of 6ff2361 with main (63bcca4) auto-merges cleanly, but grows crates/victory-shader/src/emit/lower.rs from 520,563 B to 528,047 B, exceeding xtask/src/policy.rs's 524,288 B limit (repository_passes_policy will fail once rebased/merged). Moving the 5 new unit tests out of lower.rs into a test submodule (leaving the 6th test in stride_tests.rs) would keep it under 512 KiB.
  • Optional test coverage: stride_tests.rs currently tests a raw buffer (Stride::Raw); adding a structured-buffer size+load case (e.g., stride 60) would also cover structured buffers, which hit the same amdxc64.dll+0x861b9f fault on this driver.
  • Related issues: #2124 and #2517 both report the same amdxc64.dll+0x861b9f crash on RX 9070 XT (32.0.32029.2010) and look like candidates to link alongside #1783 and #1785.

No game data, shader names, or screenshots are included, per docs/asset-policy.md. Hardware runs and dry-run merge were performed by me on my RX 9070 XT; comment drafted with Antigravity.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178674027 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7178674027). Originally posted by [MeMako](https://github.com/MeMako) on 2026-11-26T00:21:42Z. --- Independent RX 9070 XT verification at current head `6ff2361` (AMD Radeon RX 9070 XT adapter 0, driver `32.0.32029.2010`, Windows 11 `10.0.26200` x64, SDK `10.0.26100.0` `dxil.dll`). **Tests & CI checks on `6ff2361`:** - `cargo clippy --workspace --all-targets --locked -- -D warnings`: pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: pass - `cargo test --workspace --locked`: pass (`victory-shader`: 276 passed, 0 failed, 3 ignored — all 6 new tests pass on RX 9070 XT, WARP, and `dxil.dll`) **Offline pipeline stress test on `6ff2361`** (release build, `translate --validate --pipelines --jobs 8` on the 1.0.2.1 shader pack, 26,503 containers, 1,134 s): - Vertex & pixel: 14,242 / 14,242 pipelines created (14,242 validated) - Compute: 2,658 / 2,658 pipelines created (1,910 validated) - Mesh: 8,765 / 8,765 pipelines created (8,694 validated) - Total: **25,665 / 25,665** emitted shaders compiled into host D3D12 pipelines across 8 concurrent threads with **0 `amdxc64.dll+0x861b9f` crashes**. Not run on `6ff2361`: `translate --cache --pipelines` library pre-build or a live title run. **Notes before landing on current `main` (`63bcca4`):** - **512 KiB policy limit on `lower.rs`:** A dry-run merge of `6ff2361` with `main` (`63bcca4`) auto-merges cleanly, but grows `crates/victory-shader/src/emit/lower.rs` from `520,563` B to **`528,047` B**, exceeding `xtask/src/policy.rs`'s `524,288` B limit (`repository_passes_policy` will fail once rebased/merged). Moving the 5 new unit tests out of `lower.rs` into a test submodule (leaving the 6th test in `stride_tests.rs`) would keep it under 512 KiB. - **Optional test coverage:** `stride_tests.rs` currently tests a raw buffer (`Stride::Raw`); adding a structured-buffer size+load case (e.g., stride 60) would also cover structured buffers, which hit the same `amdxc64.dll+0x861b9f` fault on this driver. - **Related issues:** #2124 and #2517 both report the same `amdxc64.dll+0x861b9f` crash on RX 9070 XT (`32.0.32029.2010`) and look like candidates to link alongside #1783 and #1785. No game data, shader names, or screenshots are included, per `docs/asset-policy.md`. Hardware runs and dry-run merge were performed by me on my RX 9070 XT; comment drafted with Antigravity.
imjustprism commented 2026-11-26 08:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by imjustprism on 2026-11-26T07:09:55Z.


rebased onto 63bcca4, the head is bf526d7 now. the five unit tests moved
unchanged to emit/lower/tests/size_handles.rs, so lower.rs is 522,494 bytes
and cargo xtask policy passes. the lowering change is the one from 6ff2361,
line for line. both clippy runs, cargo test --workspace and the policy check
are green on the new head on an rx 9070 xt.

@MeMako thanks for the pipeline run and for catching the size limit. #2124
and #2517 show the same fault address on the same driver, so the description
names them now, as refs and not fixes: i have not checked that they are this
cause. the gpu test still covers a raw buffer only, no structured one.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7185163767 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7185163767). Originally posted by [imjustprism](https://github.com/imjustprism) on 2026-11-26T07:09:55Z. --- rebased onto 63bcca4, the head is bf526d7 now. the five unit tests moved unchanged to emit/lower/tests/size_handles.rs, so lower.rs is 522,494 bytes and cargo xtask policy passes. the lowering change is the one from 6ff2361, line for line. both clippy runs, cargo test --workspace and the policy check are green on the new head on an rx 9070 xt. @MeMako thanks for the pipeline run and for catching the size limit. #2124 and #2517 show the same fault address on the same driver, so the description names them now, as refs and not fixes: i have not checked that they are this cause. the gpu test still covers a raw buffer only, no structured one.
upstream-sync changed title from [PR #2122] query a buffer's size through a handle of its own to [PR #2122] Shaders: query a buffer's size through a handle of its own 2026-11-26 09:05:13 +00:00
fuzeofficlal commented 2026-11-26 12:40:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:40:41Z.

Review: APPROVED


Reviewed and verified bf526d76:

  • swap_size_caches (crates/victory-shader/src/emit/lower.rs:4256-4262, 4404-4426) cleanly separates size_handles and size_entry_handles for buffer size queries and restores both caches before propagating errors, while keeping image queries on the access handle. Because descriptor_data constructs Source::Loaded, queries stay within those two caches rather than join_handles.
  • emit/lower.rs is 522,494 bytes (1,794 bytes under the 524,288-byte limit).

Local verification: xtask policy (192 files ok), cargo clippy -p victory-shader --all-targets -- -D warnings (default & --all-features), emit::lower::tests (38 passed, including all 5 size_handles tests), and emit::stride_tests (9 passed on VICTORY_WARP=1; 7 passed, 2 failed on RTX 5090 with a_raw_buffers_size_beside_its_loads_reads_its_byte_count passing and the two pre-existing NVIDIA 1M view-heap-cap failures). Adding a structured-buffer GPU readback later would cover element-count queries too. Approve.

<!-- greyfinch-sync:Marvisak/VIctory:review:6074283233 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#pullrequestreview-6074283233). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T12:40:41Z. **Review:** APPROVED --- Reviewed and verified `bf526d76`: - `swap_size_caches` (`crates/victory-shader/src/emit/lower.rs:4256-4262, 4404-4426`) cleanly separates `size_handles` and `size_entry_handles` for buffer size queries and restores both caches before propagating errors, while keeping image queries on the access handle. Because `descriptor_data` constructs `Source::Loaded`, queries stay within those two caches rather than `join_handles`. - `emit/lower.rs` is 522,494 bytes (1,794 bytes under the 524,288-byte limit). Local verification: `xtask policy` (`192 files ok`), `cargo clippy -p victory-shader --all-targets -- -D warnings` (default & `--all-features`), `emit::lower::tests` (`38 passed`, including all 5 `size_handles` tests), and `emit::stride_tests` (`9 passed` on `VICTORY_WARP=1`; `7 passed, 2 failed` on RTX 5090 with `a_raw_buffers_size_beside_its_loads_reads_its_byte_count` passing and the two pre-existing NVIDIA 1M view-heap-cap failures). Adding a structured-buffer GPU readback later would cover element-count queries too. Approve.
JAEdotUK commented 2026-11-27 21:21:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by JAEdotUK on 2026-11-27T21:21:36Z.


Tested on RDNA 4 with an older driver: Radeon RX 9070 XT, driver 32.0.32015.7029, Windows 11 25H2 (build 26200.9974), Rust 1.98.1 (from rust-toolchain.toml), debug build. PR head bf526d7 (bf526d765f) on main 63bcca4 (63bcca43c6). No game data in this comment.

The RX 9070 XT results in this thread name driver 32.0.32029.2010. As far as I can tell from the thread, this is the first result for this PR on 32015. (In #1785, Luislariosss saw the same fault on 32015 with an RX 9060 XT, on 70564ae.)

New GPU test, emit::stride_tests::a_raw_buffers_size_beside_its_loads_reads_its_byte_count. I built it with cargo test -p victory-shader --lib --locked --no-run. Each run is one process running the test binary with --exact <test> --test-threads=1. WARP runs set VICTORY_WARP=1.

  • PR as written: hardware 5 of 5 pass, WARP 5 of 5 pass.
  • PR with crates/victory-shader/src/emit/lower.rs replaced by main's copy from 63bcca4 (no other change), so the size query is back on the loads' handle:
    • hardware: 4 of 4 runs crash, exit 0xC0000005. The Windows crash record names amdxc64.dll 32.0.32015.7029 at offset 0x85fd0f. This is the offset on this driver; 32029 reports 0x861b9f.
    • WARP: 3 of 3 pass.

This matches the description's note that the test kills the process when the size query shares the loads' handle, on a second driver version.

Shader suite, cargo test -p victory-shader --lib --locked on bf526d7: 308 passed, 0 failed, 3 ignored.

Not tested:

  • The title's own shaders on current main with this driver, with or without this PR. I can't say whether any of them still hit the pattern after 850b66f on 32015. The bisect in #1785 covers 32029.
  • translate --pipelines or a game run on this head.
  • A structured-buffer case. The test covers a raw buffer only.

This testing and comment were produced with Claude Code (Claude Opus 5.5). The hardware runs were on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7228373145 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7228373145). Originally posted by [JAEdotUK](https://github.com/JAEdotUK) on 2026-11-27T21:21:36Z. --- Tested on RDNA 4 with an older driver: Radeon RX 9070 XT, driver **32.0.32015.7029**, Windows 11 25H2 (build 26200.9974), Rust 1.98.1 (from `rust-toolchain.toml`), debug build. PR head `bf526d7` (bf526d765fc16ac3ae190deee355fb83acdafd77) on main `63bcca4` (63bcca43c6a00a758510398fa43096ce7e4f7df0). No game data in this comment. The RX 9070 XT results in this thread name driver 32.0.32029.2010. As far as I can tell from the thread, this is the first result for this PR on 32015. (In #1785, Luislariosss saw the same fault on 32015 with an RX 9060 XT, on `70564ae`.) **New GPU test**, `emit::stride_tests::a_raw_buffers_size_beside_its_loads_reads_its_byte_count`. I built it with `cargo test -p victory-shader --lib --locked --no-run`. Each run is one process running the test binary with `--exact <test> --test-threads=1`. WARP runs set `VICTORY_WARP=1`. - PR as written: hardware 5 of 5 pass, WARP 5 of 5 pass. - PR with `crates/victory-shader/src/emit/lower.rs` replaced by main's copy from `63bcca4` (no other change), so the size query is back on the loads' handle: - hardware: 4 of 4 runs crash, exit `0xC0000005`. The Windows crash record names `amdxc64.dll` 32.0.32015.7029 at offset `0x85fd0f`. This is the offset on this driver; 32029 reports `0x861b9f`. - WARP: 3 of 3 pass. This matches the description's note that the test kills the process when the size query shares the loads' handle, on a second driver version. **Shader suite**, `cargo test -p victory-shader --lib --locked` on `bf526d7`: 308 passed, 0 failed, 3 ignored. **Not tested:** - The title's own shaders on current main with this driver, with or without this PR. I can't say whether any of them still hit the pattern after `850b66f` on 32015. The bisect in #1785 covers 32029. - `translate --pipelines` or a game run on this head. - A structured-buffer case. The test covers a raw buffer only. This testing and comment were produced with Claude Code (Claude Opus 5.5). The hardware runs were on my machine.
akimfomin commented 2026-11-27 21:43:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by akimfomin on 2026-11-27T21:43:42Z.


Vice-Tay has a regression test that can help with the structured-buffer follow-up. Its merged #258 checks the emitted DXIL for separate GetDimensions and load handles, and for separate index clamps when the view limit is 2,097,152. Its optimizer guard keeps the clamps separate after lowering. KingKaom independently reported the clamped pipeline scan passing on RX 9070 XT / 32.0.32029.2010 after the merge.

The existing #2122 hardware fixture already covers raw buffers. When adding the structured-buffer case, a DXIL check with the heap clamp on and off could show whether the two caches preserve the separation after optimization. That gives a focused test before considering any of Vice-Tay's broader optimizer changes. We compared source and reports and haven't run that check on VIctory.

PortBridge compared the public sources with Codex. The implementation and AMD runs are credited to their original authors.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7228701565 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7228701565). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-27T21:43:42Z. --- Vice-Tay has a regression test that can help with the structured-buffer follow-up. Its merged #258 [checks the emitted DXIL](https://github.com/TaynanGT/Vice-Tay/blob/927da4079031d74cc987de30a3c00af28a2bf631/crates/victory-shader/src/emit/size_tests.rs#L556) for separate GetDimensions and load handles, and for separate index clamps when the view limit is 2,097,152. Its [optimizer guard](https://github.com/TaynanGT/Vice-Tay/blob/927da4079031d74cc987de30a3c00af28a2bf631/crates/victory-shader/src/emit/bitcode/opt.rs#L728) keeps the clamps separate after lowering. KingKaom independently reported the [clamped pipeline scan passing](https://github.com/TaynanGT/Vice-Tay/issues/163#issuecomment-7227831555) on RX 9070 XT / 32.0.32029.2010 after the merge. The [existing #2122 hardware fixture](https://github.com/Marvisak/VIctory/blob/bf526d765fc16ac3ae190deee355fb83acdafd77/crates/victory-shader/src/emit/stride_tests.rs#L509) already covers raw buffers. When adding the structured-buffer case, a DXIL check with the heap clamp on and off could show whether the two caches preserve the separation after optimization. That gives a focused test before considering any of Vice-Tay's broader optimizer changes. We compared source and reports and haven't run that check on VIctory. [PortBridge](https://github.com/akimfomin/PortBridge) compared the public sources with Codex. The implementation and AMD runs are credited to their original authors.
upipibi commented 2026-11-28 02:13:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T02:13:21Z.


Field evidence for this fix, from another VIctory-derived tree (read from its threads, not run):

  • ScarlettPort#73 (RX 9070 XT, Adrenalin 26.11.2, a commit limit of about 96 GB): the title died at amdxc64.dll+0x861b9f (read 0x8), the fault of #2124, right after the pipeline backlog cleared. The reporter rebuilt with avatarmanz/VIctory-7900XTX#357 ported, which gives a raw view's size query a handle of its own on RDNA 4, and played 8.5 minutes in the world without the crash. The fix is merged there as ScarlettPort#93.
  • Why their first fix wasn't enough. That tree already had a "size query not reused" fix, and it still crashed. ScarlettPort#93 says its optimiser's REUSE pass had merged the size query's handle back into the load's. Their fix therefore also marks the handle NonUniformResourceIndex and keeps it out of those passes.

VIctory main has no such merging pass that I can find, so this PR's separate caches should hold. Its GPU test, which kills the process when the size query is forced back onto the load's handle, is then the guard if a later optimisation pass starts merging identical handle creations.

AI-assisted (Claude Code, Claude Opus 5.5 read ScarlettPort#73/#93 and this diff).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7232215341 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2122#issuecomment-7232215341). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T02:13:21Z. --- Field evidence for this fix, from another VIctory-derived tree (read from its threads, not run): - **ScarlettPort#73** (RX 9070 XT, Adrenalin 26.11.2, a commit limit of about 96 GB): the title died at `amdxc64.dll+0x861b9f` (read `0x8`), the fault of #2124, right after the pipeline backlog cleared. The reporter rebuilt with avatarmanz/VIctory-7900XTX#357 ported, which gives a raw view's size query a handle of its own on RDNA 4, and played 8.5 minutes in the world without the crash. The fix is merged there as ScarlettPort#93. - **Why their first fix wasn't enough.** That tree already had a "size query not reused" fix, and it still crashed. ScarlettPort#93 says its optimiser's REUSE pass had merged the size query's handle back into the load's. Their fix therefore also marks the handle `NonUniformResourceIndex` and keeps it out of those passes. VIctory main has no such merging pass that I can find, so this PR's separate caches should hold. Its GPU test, which kills the process when the size query is forced back onto the load's handle, is then the guard if a later optimisation pass starts merging identical handle creations. AI-assisted (Claude Code, Claude Opus 5.5 read ScarlettPort#73/#93 and this diff).
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/2122:upstream-pr/2122'
git switch 'upstream-pr/2122'

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/2122'
git switch 'upstream-pr/2122'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2122'
git switch 'upstream-pr/2122'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2122'
git switch 'main'
git merge --squash 'upstream-pr/2122'
git switch 'main'
git merge --ff-only 'upstream-pr/2122'
git switch 'main'
git merge 'upstream-pr/2122'
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!2120
No description provided.