Skip to content

Shaders: preserve raw scalar buffer loads on NVIDIA - #437

Closed
bodnjenie14 wants to merge 3 commits into
Marvisak:mainfrom
bodnjenie14:fix/rtx-scalar-byte-loads
Closed

bodnjenie14 wants to merge 3 commits into
Marvisak:mainfrom
bodnjenie14:fix/rtx-scalar-byte-loads

Conversation

@bodnjenie14

@bodnjenie14 bodnjenie14 commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

@marquezinii

Copy link
Copy Markdown
Contributor

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.

@QemmHD

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown

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

No game data used.

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

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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.

@slint6614-dev

slint6614-dev commented Nov 24, 2026 •

Copy link
Copy Markdown

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

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 slint6614-dev mentioned this pull request Nov 24, 2026

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.

jeremygold02 added a commit to jeremygold02/VIctory that referenced this pull request Nov 24, 2026
Merge upstream main, retain both shader regression tests, and pass absent PSV metadata in the three synthetic fixtures that construct lowering inputs directly.

Refs: Marvisak#136, Marvisak#329, Marvisak#437
ThatMaddLadd added a commit to ThatMaddLadd/VIctory that referenced this pull request Nov 24, 2026
Marvisak#437 orders a container signature by row alone, keeping declaration order
within a row (main ordered by row, then column). A vertex shader declaring
two outputs of row 0 with the higher columns first validates with Marvisak#437's
order; with main's, dxil.dll answers "Container part 'Program Output
Signature' does not match expected for module", since the metadata keeps
declaration order. The test keeps that from coming back. Also rustfmt of
the shader host's adapter choice.
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dom and others added 3 commits November 24, 2026 15:39
… phis, PSV0/ISG1 fixes, calculateLOD and image_gather4_l
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#136 by mpDom. Adapted from 0628716 in the
local RTX bring-up branch.
@bodnjenie14
bodnjenie14 force-pushed the fix/rtx-scalar-byte-loads branch from 598d221 to 7a29f52 Compare November 24, 2026 15:42
@bodnjenie14

bodnjenie14 commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

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
bodnjenie14 marked this pull request as ready for review November 24, 2026 15:45
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
The tester tree (upstream main ffe310e plus its PRs, update 8; see its
INTEGRATION.md) ran 11-25 minutes in the world on an RTX 5070 without a
device removal. Where both sides carry the same PR (the wave64 stack
#223/#233/#320 with #439 and #180, #454, #336, #259, #331 and others), the
tester tree's newer head is taken; our own work and the PRs only we
merged are kept.

Conflicts, file by file:

- descriptor/host.rs: the tester layout (`spare`, the guard slot after the
  dynamic slots, `free_table`, the capped sampler heap). A capped view
  heap keeps `capped_reserve()` dynamic slots, now 2^18 by default (the
  tester measurement, and our 91fed158), still `VICTORY_DYNAMIC_SLOTS` in
  diagnostics builds; uncapped hosts keep our 2^19. Our slot statistics
  (TAKEN/PEAK/SHORT), the bindless plan cache (`CommittedRegions`,
  `timed_valid_title_address`, `timed_find`, `title_bounds`) and the
  revision triple are kept beside the tester's `guard_slot`.
- Buffer states: the tester tree's buffer-state tracker (#334: every list
  moves host copies of title memory between GENERIC_READ and
  UNORDERED_ACCESS and back to common before it closes) and depth twins
  (#469) are taken. #40's enhanced/legacy indirect barriers (the indirect
  prelude, `use_indirect_buffers`, the title buffer handoff mirrored in
  `host_barrier`) cannot share buffers with that tracker and are dropped;
  #40's argument checks (`byte_len`, exact spans, overflow-safe clamp
  shader, aligned counts) stay. `indirect::bound` and #282's
  `rectangles` go through `buffer_state`, and `indirect::execute` (#334)
  replaces `done`. #178's DXC fallback compiles both of our passes.
  Our segments (#387: `close` ends the segment, `close_native` closes a
  native list) carry the tracker: each native list returns its buffers
  to common and its twins to their depth targets, and each prelude also
  holds our texture uploads.
- shadow.rs: our write flow (`queue_write`, one `snapshot` after the
  batch's refreshes, `finish_writes`, the unchanged-page cache) with
  #261's copy-back that also gives the snapshot the title's bytes; its
  tests run through our flow.
- pipeline/make.rs: #275's per-frame budget and per-pipeline wake pair,
  with our compute waits (a dispatch waits for its pipeline, up to 20 s).
- pipeline/library.rs: the tester version (#347, #275's saver thread);
  our concurrent-write test kept. shader_cache.rs: our byte-returning
  cache API with #358's "translated, only not kept".
- draw.rs: #493's root SRV tables; where no table can stand in, our
  drop of a draw whose root view is unset or outside title buffers. Our
  refusal of a table offset past the capped heap stays.
- resource.rs: `HostTexture` has both our `staged` generation and the
  depth twin.
- Shaders: the tester's lower.rs for the wave64 stack, #160's image
  sampling (it covers our #73 and #136 sample forms) and #453/#587; kept
  from our side: #136's preference for an image or buffer use of a
  descriptor read as data and its `s_buffer_` arm, #422's nearest-even
  narrowing (also for #169's d16 loads and #453's interpolation), #452's
  spin-wait limit, #391's LDS limit, #302's spilled root arguments (now in
  `NativeProgram::translation_ir`), #136's PSV0 interpolation beside the
  tester's row harmonisation. split_tests.rs, lane_read_loop_tests.rs and
  docs/wave64-on-wave32.md are the tester versions (the same PRs at newer
  heads).
- Tests: #483's heap guard dwords filled in our GPU tests of #200
  (v_div_scale) and #437 (scalar loads from a raw view), which read
  through the guard slot otherwise; #334's debug-layer test passes an
  offset to our `indirect::bound`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Two testers bisected #136 as making every frame black on RTX 5080 and
4080, loading screens included (upstream issue #71); the tester tree
leaves it out. A plain revert of 5254cfa conflicts with #160, #437 and
the tester merge, so each of #136's constructs is set to the tester
tree's form:

- s_load through a tracked descriptor: SRV only, as before #136 (no UAV
  raw reads); #437's byte offsets and its test stay.
- A descriptor read as data: the first use found, not #136's preference
  for an image or vector buffer use; #136's s_buffer_ arm is gone.
- PSV0 interpolation modes (psv_interp) are no longer read; the
  conservative-depth centroid and the row harmonisation stay (tester).
- calculateLOD passes cs[0..2] as the tester tree does.
- Dead descriptor dwords at data joins: the tester's undef arm
  (descriptor_dword) only, not #136's zero for has_data joins.

Kept because the tester tree has the same form: the signature sort by
row, barycentrics (23 => 28), the comparison-sample check, and #160's
gather and a16 sampling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DeerSilver

Copy link
Copy Markdown

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.

AI-assisted (Claude Code).

@Daniel333313131

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants