Shaders: preserve raw scalar buffer loads on NVIDIA #437

Closed
github-bot wants to merge 3 commits from gh-pr/437/head into gh-pr/437/base
Owner

@⁠bodnjenie14 on GitHub · 2026-11-24 03:21 UTC · original
bodnjenie14:fix/rtx-scalar-byte-loads → main · +378 −53 · 4 files · 3 commits · closed without merging

Depends on #136 by mpDom. This draft carries that PR's commits. The focused follow-up is 598d221.

Scalar GPU loads use byte offsets. When the host descriptor is a raw buffer, emitting a structured DXIL handle based on the console stride can return zero on NVIDIA. This change emits a raw handle and uses the byte offset directly. The plain-buffer descriptor data path also uses the raw handle.

A synthetic shader test binds a raw SRV, supplies console metadata with a 16-byte stride, and reads at byte offset 20. On the same Windows machine, the test returned 0 on the unpatched #136 head and 86 with this change. The shader suite reported 70 passing tests. The asset policy check passed.

The executable built from this draft rendered the intro and loading screens in a local run. World loading later ended with DXGI_ERROR_DEVICE_HUNG. The synthetic test above isolates the startup shader fix.

**@⁠bodnjenie14** on GitHub · 2026-11-24 03:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/437) `bodnjenie14:fix/rtx-scalar-byte-loads` → `main` · +378 −53 · 4 files · 3 commits · closed without merging Depends on #136 by mpDom. This draft carries that PR's commits. The focused follow-up is 598d221. Scalar GPU loads use byte offsets. When the host descriptor is a raw buffer, emitting a structured DXIL handle based on the console stride can return zero on NVIDIA. This change emits a raw handle and uses the byte offset directly. The plain-buffer descriptor data path also uses the raw handle. A synthetic shader test binds a raw SRV, supplies console metadata with a 16-byte stride, and reads at byte offset 20. On the same Windows machine, the test returned `0` on the unpatched #136 head and `86` with this change. The shader suite reported 70 passing tests. The asset policy check passed. The executable built from this draft rendered the intro and loading screens in a local run. World loading later ended with `DXGI_ERROR_DEVICE_HUNG`. The synthetic test above isolates the startup shader fix.
A console buffer descriptor can carry a stride while its host view is
raw. Lower the scalar loads with byte addressing so the DXIL matches
that view. A synthetic GPU regression used to read zero at byte offset
20 and now reads the expected dword.

Builds on Marvisak/VIctory#136 by mpDom. Adapted from 0628716 in the
local RTX bring-up branch.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:03:56 +00:00
github-bot closed this pull request 2026-11-26 04:03:56 +00:00
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 03:43 UTC · original

Verified on an NVIDIA RTX 5070 (driver 621.24, the only adapter in the machine), Windows 11, rustc 1.98.1, debug, each head built in its own target directory:

head scalar_buffer_load_uses_byte_offsets_with_a_raw_host_view
#136 8ae232f + only this PR's valu_tests.rs fails 3 of 3: left: [0], right: [86]
this PR 598d221 passes 3 of 3
  • cargo test -p victory-shader on 598d221: 70 passed, 0 failed, 3 runs in parallel. The validator picked up the Windows SDK's dxil.dll (10.0.26100.0), so the modules were validated, not skipped.
  • So the zero from a structured handle over a raw view reproduces on this GPU, and the raw handle fixes it.

Not covered: the title (no game data here) and other GPU vendors.

**@⁠marquezinii** on GitHub · 2026-11-24 03:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7121353544) Verified on an NVIDIA RTX 5070 (driver 621.24, the only adapter in the machine), Windows 11, rustc 1.98.1, debug, each head built in its own target directory: | head | `scalar_buffer_load_uses_byte_offsets_with_a_raw_host_view` | |---|---| | #136 `8ae232f` + only this PR's `valu_tests.rs` | fails 3 of 3: `left: [0]`, `right: [86]` | | this PR `598d221` | passes 3 of 3 | - `cargo test -p victory-shader` on `598d221`: 70 passed, 0 failed, 3 runs in parallel. The validator picked up the Windows SDK's `dxil.dll` (10.0.26100.0), so the modules were validated, not skipped. - So the zero from a structured handle over a raw view reproduces on this GPU, and the raw handle fixes it. Not covered: the title (no game data here) and other GPU vendors.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 05:11 UTC · original

Tested 598d221 merged onto main d2a4bae, native Windows 11, RTX 4070 SUPER (driver 621.24).

  • cargo test --workspace --locked: 265 passed, 0 failed, 4 ignored (main: 264 / 0 / 4). One new clippy warning: type_complexity at emit/mod.rs:322 (from #136's 8ae232f).

  • Your test on main alone reads 86 on hardware and on WARP; with #136's lower.rs it reads 0 on the 4070 SUPER and 86 on WARP. main already uses a raw handle for SRV scalar loads (lower.rs:2768), so this repairs #136; folding it into #136 would be safer than landing both.

  • The reverse case also reads 0 on NVIDIA. The host view follows the title's view kind (descriptor/host.rs, buffer_srv), so a title StructuredBuffer gets a structured host view. Same program with Stride::Structured(16): a raw handle (this PR) reads 0 on the 4070 SUPER, a structured handle (#136) reads 86. WARP reads 86 in all four combinations:

    raw host view structured host view
    raw handle 86 0
    structured handle 0 86

    So on NVIDIA the handle kind has to match the host view kind, and neither fixed choice is right for every title buffer. The test is scalar_buffer_load_reads_a_structured_host_view on QemmHD/VIctory repro/437-view-kind-both-ways (2f15ef1); it fails on the 4070 SUPER (left: [0], right: [86]) and passes with VICTORY_WARP=1. Keying the handle kind on the host view per slot, or making title buffer views one kind, would cover both rows.

No game data used.

AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.

**@⁠QemmHD** on GitHub · 2026-11-24 05:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7122710374) Tested `598d221` merged onto `main` `d2a4bae`, native Windows 11, RTX 4070 SUPER (driver 621.24). - `cargo test --workspace --locked`: 265 passed, 0 failed, 4 ignored (main: 264 / 0 / 4). One new clippy warning: `type_complexity` at `emit/mod.rs:322` (from #136's `8ae232f`). - Your test on `main` alone reads 86 on hardware and on WARP; with #136's `lower.rs` it reads 0 on the 4070 SUPER and 86 on WARP. `main` already uses a raw handle for SRV scalar loads (`lower.rs:2768`), so this repairs #136; folding it into #136 would be safer than landing both. - **The reverse case also reads 0 on NVIDIA.** The host view follows the title's view kind (`descriptor/host.rs`, `buffer_srv`), so a title `StructuredBuffer` gets a structured host view. Same program with `Stride::Structured(16)`: a raw handle (this PR) reads 0 on the 4070 SUPER, a structured handle (#136) reads 86. WARP reads 86 in all four combinations: | | raw host view | structured host view | |---|---|---| | raw handle | 86 | **0** | | structured handle | **0** | 86 | So on NVIDIA the handle kind has to match the host view kind, and neither fixed choice is right for every title buffer. The test is `scalar_buffer_load_reads_a_structured_host_view` on [QemmHD/VIctory `repro/437-view-kind-both-ways`](https://github.com/QemmHD/VIctory/tree/repro/437-view-kind-both-ways) (`2f15ef1`); it fails on the 4070 SUPER (`left: [0], right: [86]`) and passes with `VICTORY_WARP=1`. Keying the handle kind on the host view per slot, or making title buffer views one kind, would cover both rows. No game data used. AI-assisted (Claude Code, Claude Opus 5.5). Discord: bigpeppa.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 05:53 UTC · original

I tested the descriptor reconstruction on 598d221 by reading both the scalar load at byte offset 20 and descriptor word 2 in the same synthetic dispatch. With an actual raw host SRV, both stride-metadata settings (0 and 16) returned [86, 32] on the RTX 5090 (32.0.16.1656) and WARP. The translated shaders passed the Windows SDK DXIL validator (1.8.2502.11).

For comparison, independent DXC HLSL on the same 32-byte allocation returned [86, 32] with a raw view and [86, 2] with a 16-byte structured view on both adapters. The second value is bytes for the raw view and records for the structured view. The translated result covers the matched raw binding. The structured result is the HLSL reference for testing the view-kind selection discussed above.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 05:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7123365673) I tested the descriptor reconstruction on `598d221` by reading both the scalar load at byte offset 20 and descriptor word 2 in the same synthetic dispatch. With an actual raw host SRV, both stride-metadata settings (0 and 16) returned `[86, 32]` on the RTX 5090 (32.0.16.1656) and WARP. The translated shaders passed the Windows SDK DXIL validator (1.8.2502.11). For comparison, independent DXC HLSL on the same 32-byte allocation returned `[86, 32]` with a raw view and `[86, 2]` with a 16-byte structured view on both adapters. The second value is bytes for the raw view and records for the structured view. The translated result covers the matched raw binding. The structured result is the HLSL reference for testing the view-kind selection discussed above.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:54 UTC · original

Corpus run on the full retail shader pack (26,503 containers), Windows 11, AMD RX 9070 (Adrenalin), dxil.dll from SDK 10.0.26100. This PR conflicts with current main, so it was built at its own base (main before #612; there translate --validate --pipelines completes, with VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129).

  • victory translate shaders.rpf --validate --pipelines crashes with an access violation (exit code 0xC0000005) right after loading the validator, with no Rust panic message. It reproduced twice, on two separate builds.
  • victory translate shaders.rpf --validate --jobs 1 (no host pipelines) completes: VS/PS 12619 / 12619, CS 1796 / 1697, MS 8355 / 8302 (the same counts as #136, which this branch seems to include).

So one of the modules this PR emits seems to crash the host pipeline path (the driver or our D3D12 calls) on AMD. My earlier #136 run did not create pipelines, so I cannot say yet whether the crash comes from #136 or from this PR. I have not isolated the module yet.

**@⁠slint6614-dev** on GitHub · 2026-11-24 10:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7129412983) Corpus run on the full retail shader pack (26,503 containers), Windows 11, AMD RX 9070 (Adrenalin), dxil.dll from SDK 10.0.26100. This PR conflicts with current main, so it was built at its own base (main before #612; there `translate --validate --pipelines` completes, with VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129). - `victory translate shaders.rpf --validate --pipelines` **crashes with an access violation (exit code 0xC0000005)** right after loading the validator, with no Rust panic message. It reproduced twice, on two separate builds. - `victory translate shaders.rpf --validate --jobs 1` (no host pipelines) completes: VS/PS 12619 / 12619, CS 1796 / 1697, MS 8355 / 8302 (the same counts as #136, which this branch seems to include). So one of the modules this PR emits seems to crash the host pipeline path (the driver or our D3D12 calls) on AMD. My earlier #136 run did not create pipelines, so I cannot say yet whether the crash comes from #136 or from this PR. I have not isolated the module yet.
Author
Owner

@⁠bodnjenie14 on GitHub · 2026-11-24 15:44 UTC · original · edited 2026-11-24 15:45 UTC

Rebased onto main at ffe310e and pushed 7a29f52. GitHub now reports no merge conflicts, so this is ready for another look. The scalar byte-load regression passed, and the shader suite finished with 121 passed and 1 ignored.

**@⁠bodnjenie14** on GitHub · 2026-11-24 15:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7136523209) · edited 2026-11-24 15:45 UTC Rebased onto `main` at `ffe310e` and pushed `7a29f52`. GitHub now reports no merge conflicts, so this is ready for another look. The scalar byte-load regression passed, and the shader suite finished with 121 passed and 1 ignored.
Author
Owner

@⁠DeerSilver on GitHub · 2026-11-24 17:48 UTC · original

Tested head 7a29f52 merged onto main ffe310e (clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only.

  • scalar_buffer_load_uses_byte_offsets_with_a_raw_host_view passes on the RTX 5060 (hardware device, not WARP), and so does the rest of the workspace: 343 passed, 0 failed, 6 ignored, against 342 / 6 on main.
  • The new test also passes without the fix. I put only this PR's valu_tests.rs onto main ffe310e and kept main's lower.rs: the test passes there too, reading 86. So on current main, on Blackwell, I can't reproduce the 0 you saw on the #136 head. Either something on main already covers this case, or the failure is specific to the #136 head or your GPU. Which GPU did you see the 0 on?
  • Clippy fails with -D warnings, as CI runs it, on lines this PR adds:
    • type_complexity at emit/mod.rs:334: fn psv_interp(...) -> Option<Vec<(Option<u32>, u8, u8, u8)>>
    • needless_borrow at emit/valu_tests.rs:133: io::raise(&p, &native) in lower_compute, where native is already a reference

AI-assisted (Claude Code).

**@⁠DeerSilver** on GitHub · 2026-11-24 17:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7139724561) Tested head `7a29f52` merged onto `main` `ffe310e` (clean merge) on **NVIDIA GeForce RTX 5060 Laptop GPU** (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only. - `scalar_buffer_load_uses_byte_offsets_with_a_raw_host_view` passes on the RTX 5060 (hardware device, not WARP), and so does the rest of the workspace: **343 passed, 0 failed, 6 ignored**, against 342 / 6 on `main`. - **The new test also passes without the fix.** I put only this PR's `valu_tests.rs` onto `main` `ffe310e` and kept `main`'s `lower.rs`: the test passes there too, reading `86`. So on current `main`, on Blackwell, I can't reproduce the `0` you saw on the #136 head. Either something on `main` already covers this case, or the failure is specific to the #136 head or your GPU. Which GPU did you see the `0` on? - **Clippy fails** with `-D warnings`, as CI runs it, on lines this PR adds: - `type_complexity` at `emit/mod.rs:334`: `fn psv_interp(...) -> Option<Vec<(Option<u32>, u8, u8, u8)>>` - `needless_borrow` at `emit/valu_tests.rs:133`: `io::raise(&p, &native)` in `lower_compute`, where `native` is already a reference AI-assisted (Claude Code).
Author
Owner

@⁠Daniel333313131 on GitHub · 2026-11-24 22:18 UTC · original

Translation census with this PR merged alone onto main ffe310e: it adds the most programs of the 12 shader PRs I ran.

Setup: release build, victory translate <dump>/shaders.rpf --list (26,084 programs, no --validate, no --pipelines), Windows 11, RX 7900 XTX. The PR's head is 7a29f52.

vertex/pixel compute mesh
main 12,231 of 14,027 1,441 of 2,582 8,214 of 8,713
#437 12,457 (+226) 1,772 (+331) 8,501 (+287)

The first refusal per program changes like this (main → #437):

first refusal main #437
a scalar memory read as data 771 0
a descriptor read only as data 394 40
a biased image sample with 16-bit coordinates 108 0
a descriptor's address or format read as data 92 31
image_sample_d_cl 29 0
a lane mask read as data 250 617
a lane mask holding lanes elsewhere read as data 272 299
  • The effect is not NVIDIA-specific: the census runs on the translator alone, and the numbers above come from an AMD machine.
  • About 390 programs that got past the scalar read now stop at the lane-mask refusals instead.

In game (diag build, two runs each, stopped after 180 s): main 981 / 976 ms per world frame, #437 1202 / 1167 ms. With #437, more draws per frame were dropped while their pipelines were still being made (2281 / 1542 against 1242 / 915). That is expected with ~850 more programs to build, and 180 s is too short to see it settle. Both setups still end in the freed-texture page fault that #431 addresses: main after 161 s and 106 s; #437 after 68 s in one run, and the other's log stopped at 134 s. So this run says nothing yet about whether the newly translated programs render correctly.

AI use: Claude Code (Claude Opus 5.5) merged and built the commits, ran the census and the title, compared the outputs and wrote this comment. The numbers come from the runs above.

**@⁠Daniel333313131** on GitHub · 2026-11-24 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/437#issuecomment-7146069772) Translation census with this PR merged alone onto `main` `ffe310e`: it adds the most programs of the 12 shader PRs I ran. **Setup:** release build, `victory translate <dump>/shaders.rpf --list` (26,084 programs, no `--validate`, no `--pipelines`), Windows 11, RX 7900 XTX. The PR's head is `7a29f52`. | | vertex/pixel | compute | mesh | |---|---|---|---| | `main` | 12,231 of 14,027 | 1,441 of 2,582 | 8,214 of 8,713 | | **#437** | **12,457** (+226) | **1,772** (+331) | **8,501** (+287) | The first refusal per program changes like this (`main` → #437): | first refusal | `main` | #437 | |---|---|---| | a scalar memory read as data | 771 | 0 | | a descriptor read only as data | 394 | 40 | | a biased image sample with 16-bit coordinates | 108 | 0 | | a descriptor's address or format read as data | 92 | 31 | | image_sample_d_cl | 29 | 0 | | a lane mask read as data | 250 | **617** | | a lane mask holding lanes elsewhere read as data | 272 | **299** | - The effect is not NVIDIA-specific: the census runs on the translator alone, and the numbers above come from an AMD machine. - About 390 programs that got past the scalar read now stop at the lane-mask refusals instead. **In game** (diag build, two runs each, stopped after 180 s): `main` 981 / 976 ms per world frame, #437 1202 / 1167 ms. With #437, more draws per frame were dropped while their pipelines were still being made (2281 / 1542 against 1242 / 915). That is expected with ~850 more programs to build, and 180 s is too short to see it settle. Both setups still end in the freed-texture page fault that #431 addresses: `main` after 161 s and 106 s; #437 after 68 s in one run, and the other's log stopped at 134 s. So this run says nothing yet about whether the newly translated programs render correctly. **AI use:** Claude Code (Claude Opus 5.5) merged and built the commits, ran the census and the title, compared the outputs and wrote this comment. The numbers come from the runs above.

Pull request closed

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!437
No description provided.