Shaders: lower buffer record-count reads without buffer uses #58

Open
IAmTheSween wants to merge 1 commit from upstream-pr/58 into main
IAmTheSween commented 2026-11-25 07:06:27 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by IAmTheSween on 2026-11-25T06:46:40Z.


Fixes ShallowWaterSim:CS_MinTimestepReduce_5447091c_Wrapped (ceb5eb68cd99cb07, named in #38) failing in emit with "a descriptor's address or format read as data".

Cause

At 0x28, ShallowWaterSimCS_MinTimestepReduce loads a 4-dword structured SRV descriptor (s_load_dwordx4 s[0:3], s[4:5], null) and checks dword 2 (s2 == 0 at 0x34) for an empty buffer before doing any work, without issuing any buffer_* instructions against s[0:3]. Because use_at was None, descriptor_data fell through to the view_address fallback, which populated dwords 0..1 (even though unread) and marked dword 2 (num_records) as Val::Missing("a descriptor's address or format read as data").

What is in it

  • crates/victory-shader/src/emit/lower.rs:
    • Extracts Lower::buffer_props, Lower::dimensions, and Lower::buffer_records to share dx.op.getDimensions and raw-stride record-count calculation across both paths of descriptor_data.
    • When a static 4-dword Table buffer descriptor (Srv or Uav) has no buffer_* use (use_at is None), resolves its UsedResource entry: reads view_address only when the low address dwords 0..1 are actually read (avoiding spurious USER_VIEW_ADDRESS user-data requests), and populates dword 2 (num_records) via dimensions + buffer_records when dword 2 is read.
    • Adds unit test buffer_record_count_without_buffer_ops_lowers verifying that checking dword 2 compiles cleanly without requesting USER_VIEW_ADDRESS for the unread low dwords.

Shader pack check

  • Checked ShallowWaterSimCS_MinTimestepReduce_5447091c_Wrapped (ceb5eb68cd99cb07) with victory.exe translate --validate --pipelines:
    • 1 emitted of 1 compute programs; 1 validated, 1 pipelines (passes dxil.dll 10.0.26100.0 validation and RTX 5070 pipeline creation).

Tested

  • Hardware: NVIDIA GeForce RTX 5070, Windows 11 x64, Windows SDK dxil.dll 10.0.26100.0.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings).
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings).
  • cargo test --workspace --locked -- --test-threads=1: all suites passed with 0 failures (victory 1, victory_core 11, victory_formats 24 / 4 ignored, victory_game 2, victory_gpu 110 / 1 ignored, victory_hle 95 + no_dll_planting 1, victory_loader 24 + load_probe 2 + title_dlls 1, victory_pe 7, victory_pipeline 4, victory_shader 211 / 2 ignored, xtask 4). Single-threaded execution was used for the full workspace run due to pre-existing WARP device contention when victory_gpu GPU tests run concurrently (valu_tests.rs:198).

AI use

Written with Antigravity.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6598903826 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/58). Originally posted by [IAmTheSween](https://github.com/IAmTheSween) on 2026-11-25T06:46:40Z. --- Fixes `ShallowWaterSim:CS_MinTimestepReduce_5447091c_Wrapped` (`ceb5eb68cd99cb07`, named in #38) failing in `emit` with `"a descriptor's address or format read as data"`. ### Cause At `0x28`, `ShallowWaterSimCS_MinTimestepReduce` loads a 4-dword structured SRV descriptor (`s_load_dwordx4 s[0:3], s[4:5], null`) and checks dword 2 (`s2 == 0` at `0x34`) for an empty buffer before doing any work, without issuing any `buffer_*` instructions against `s[0:3]`. Because `use_at` was `None`, `descriptor_data` fell through to the `view_address` fallback, which populated dwords `0..1` (even though unread) and marked dword 2 (`num_records`) as `Val::Missing("a descriptor's address or format read as data")`. ### What is in it - **`crates/victory-shader/src/emit/lower.rs`**: - Extracts `Lower::buffer_props`, `Lower::dimensions`, and `Lower::buffer_records` to share `dx.op.getDimensions` and raw-stride record-count calculation across both paths of `descriptor_data`. - When a static 4-dword `Table` buffer descriptor (`Srv` or `Uav`) has no `buffer_*` use (`use_at` is `None`), resolves its `UsedResource` entry: reads `view_address` only when the low address dwords `0..1` are actually read (avoiding spurious `USER_VIEW_ADDRESS` user-data requests), and populates dword 2 (`num_records`) via `dimensions` + `buffer_records` when dword 2 is read. - Adds unit test `buffer_record_count_without_buffer_ops_lowers` verifying that checking dword 2 compiles cleanly without requesting `USER_VIEW_ADDRESS` for the unread low dwords. ### Shader pack check - Checked `ShallowWaterSimCS_MinTimestepReduce_5447091c_Wrapped` (`ceb5eb68cd99cb07`) with `victory.exe translate --validate --pipelines`: - `1 emitted of 1 compute programs; 1 validated, 1 pipelines` (passes `dxil.dll` `10.0.26100.0` validation and RTX 5070 pipeline creation). ### Tested - Hardware: NVIDIA GeForce RTX 5070, Windows 11 x64, Windows SDK `dxil.dll` `10.0.26100.0`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed (0 warnings). - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed (0 warnings). - `cargo test --workspace --locked -- --test-threads=1`: all suites passed with 0 failures (`victory` 1, `victory_core` 11, `victory_formats` 24 / 4 ignored, `victory_game` 2, `victory_gpu` 110 / 1 ignored, `victory_hle` 95 + `no_dll_planting` 1, `victory_loader` 24 + `load_probe` 2 + `title_dlls` 1, `victory_pe` 7, `victory_pipeline` 4, `victory_shader` 211 / 2 ignored, `xtask` 4). Single-threaded execution was used for the full workspace run due to pre-existing WARP device contention when `victory_gpu` GPU tests run concurrently (`valu_tests.rs:198`). ### AI use Written with Antigravity.
futurepro62 commented 2026-11-25 16:13:08 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by futurepro62 on 2026-11-25T15:15:08Z.


Full-suite run on Windows, since this PR has no test report yet. Tested exact head dcb71f8 (on its base 90b529f).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (rust-toolchain.toml), DXC + dxil.dll 1.9.2602.17, debug.
  • cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored (main 90b529f on this machine: 492 passed, 0 failed, 7 ignored).
  • cargo clippy --workspace --all-targets --locked -- -D warnings (the CI lint step): passed.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (the CI lint step): passed.
  • The new tests ran and passed: buffer_record_count_without_buffer_ops_lowers.

Not tested

  • AMD (ztrx targets NVIDIA), a release build, the game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Zettrox/ztrx:comment:7166544151 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/58#issuecomment-7166544151). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T15:15:08Z. --- Full-suite run on Windows, since this PR has no test report yet. Tested exact head `dcb71f8` (on its base `90b529f`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (`rust-toolchain.toml`), DXC + dxil.dll 1.9.2602.17, debug. - `cargo test --workspace --locked`: **497 passed, 0 failed, 7 ignored** (main `90b529f` on this machine: 492 passed, 0 failed, 7 ignored). - `cargo clippy --workspace --all-targets --locked -- -D warnings` (the CI lint step): passed. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (the CI lint step): passed. - The new tests ran and passed: `buffer_record_count_without_buffer_ops_lowers`. **Not tested** - AMD (ztrx targets NVIDIA), a release build, the game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/58:upstream-pr/58'
git switch 'upstream-pr/58'

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