GPU: on NVIDIA, structured buffer views are made raw #2464
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2464
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2464"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lhnizdo on GitHub · 2026-11-25 14:02 UTC · original
lhnizdo:pr/structured-scalar-loads→main· +60 −0 · 2 files · 1 commits · openOn NVIDIA hosts, a title SRV that holds a structured buffer view is now made as a raw view of the same bytes.
The problem. Scalar and offset-only buffer reads are translated as raw reads:
rawBufferLoadthrough a raw handle, at a byte offset. When the slot holds the title's structured view, D3D12 leaves that read undefined, and NVIDIA took the byte offset as the element.WindNew:CS_CopyLatestWindFieldForRenderingWithSmoothreads its loop counts that way, fromt71(680-byte records, offsets 0 and 0xC4). With other records' data as counts, its loops ran until Windows reset the device. That happened every run, in the opening credits, on Windows 10 with an NVIDIA wave32 card. DRED named that dispatch.The change (
descriptor/host.rs,buffer_srv):VICTORY_RAW_STRUCTURED=0or=1overrides the vendor check.host::host_vendor()reads the device's adapter vendor once, by its LUID.Why not in the shaders. The first version of this PR read such slots both ways in the shader and picked the result by the slot's stride. That made the largest shaders too much for the NVIDIA driver's compiler. I checked with
translate --pipelines, filtered to theCS_RaytracingResolveand skinning mesh shaders:E_OUTOFMEMORY, and their draws dropped in game.This version leaves the shaders unchanged.
Checked on Windows 10 with an NVIDIA card, together with the Agility SDK (#2460), heap-limit (#2461) and UAV-format (#2462) PRs:
victory-gputests are unchanged againstmain.🤖 Generated with Claude Code. The change was written by Claude Code (Claude Opus 5.5) in my session; the commit carries a
Co-Authored-By: Claudeline.@lhnizdo on GitHub · 2026-11-25 14:46 UTC · original
Heads-up before merging. In a game run, reading table SRVs both ways made the largest shaders (the materials'
CS_RaytracingResolvevariants and some deferred pixel shaders) too big for the NVIDIA driver's compiler: 145 pipelines were refused withE_OUTOFMEMORYand their draws dropped. I have a follow-up commit that looks the slot's stride up once per descriptor and block, and splits constant offsets at translation time. I'll push it oncetranslate --pipelinesconfirms the refusals are gone. Please hold this one until then.@lhnizdo on GitHub · 2026-11-25 16:37 UTC · original
Update: I've replaced this PR's approach, so the branch was force-pushed.
As I mentioned above, reading table SRVs both ways in the shader made the largest shaders too big for the NVIDIA driver's compiler. A filtered
translate --pipelinesrun on theCS_RaytracingResolveand skinning mesh shaders gave 569 pipelines refused withE_OUTOFMEMORY, against 0 without the shader change.The PR now fixes it on the host instead: on NVIDIA, a structured SRV is made as a raw view of the same bytes. Raw reads then read what they name, reads by element keep their structured handle (which NVIDIA reads right on a raw view), and the shaders are unchanged. Other vendors are unchanged too.
In a game run with it, the opening credits played through into the prologue with no device removal and no loop cap, and no pipelines were refused for lack of memory. Details are in the updated description. The earlier approvals were for the old version, so a fresh look would be appreciated.
@Marvisak on GitHub · 2026-11-25 16:39 UTC · original · edited 2026-11-26 07:22 UTC
Automated triage for the maintainers.
Needs work: needs the maintainer's decision, plus one small change. The head is unchanged (
b9dc4b0). steven-seagull27's synthetic readback on an RTX 5080 confirms both the fix and its limit. Through 16-byte-aligned SRV origins, wrong dwords drop from 950/960 to 0/960. Unaligned origins (12, 24, 36 bytes) still misread, becausebuffer_srvindescriptor/host.rskeeps those views structured.On your reply: #2885 is also open and makes structured SRVs and UAVs raw, with aligned copies for unaligned origins. The maintainer should pick one. If #2885 is chosen, this can close in its favour, as you offer. Until then, the earlier points stand:
host_vendor() == 0x10DE. That needs the maintainer's decision.CI:
checkpassing.Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 16:52 UTC · original
Mechanics check out: gated to
stride > 0so raw/typed views are untouched; guardsbyte % 16 == 0(raw-view alignment) andstride % 4 == 0(socount*stride/4is exact) before converting toR32_TYPELESS+ RAW with dword FirstElement — the fallback stays structured and logs once. Vendor detection viaEnumAdapterByLuidis the right way (not name matching).The hardware rationale is plausible — a byte-offset read through a structured SRV on NVIDIA indexing by element instead would return wrong records, which explains the wind-sim loop-count corruption. WARP already behaving correctly on raw views makes the raw path the safer default on the hosts that get it right.
Note: a structured view whose
first*strideisn't 16-aligned keeps the buggy NVIDIA behaviour — unavoidable without a copy, but worth remembering if a title hits it.@moe-miau on GitHub · 2026-11-25 17:42 UTC · original
Tested on an RTX 4070 SUPER (driver 32.0.16.1742, Windows 11 26300), title 1.0.2.1, Series X profile, diag build. 6-minute runs with scripted Enter presses. The stack is
main67e8ae1+ #1906 + #2098 + #2626 (RGBA8 stand-in for formats 86/115) + #2628 (capped view heap). This PR was merged on top; the only conflict was inhost.rs, where both sides add a function in the same place.host adapter vendor vendor=0x10deandstructured buffer views made raw on=true. One view stayed structured:not on 16 bytes byte=168744600 stride=100.buffer_uav, same 16-byte rule). That gave no visible difference in a 6-minute run, so I don't think this PR needs it.WaveSize(64)compute pipelines NVIDIA still refuses here (exposure and lighting), not this PR.AI-assisted (Claude Code); the runs were done on my machine.
@lhnizdo on GitHub · 2026-11-25 18:07 UTC · original
Thanks @kotekompotek for the review, and @moe-miau for the RTX 4070 SUPER run. A black screen at 0.1 fps turning into the world drawing at about 1 fps is a clearer result than mine.
main(13f91ca). The conflict was the one moe-miau saw: both sides add a function at the same place inhost.rs, and both are kept.byte=168744600 stride=100, not on 16 bytes) shows up in my runs too. As kotekompotek says, it keeps the old NVIDIA behaviour, and fixing it would need a copy. I've left it as a logged shortcut.@frenziedcoder on GitHub · 2026-11-25 19:01 UTC · original
RTX 5080 (Blackwell), driver 621.40: @moe-miau's stack with this PR draws the world here too, at about 1.5–2.5 fps, and ran the full 10 minutes with no device removal.
Setup: NVIDIA GeForce RTX 5080 16 GB (driver 621.40, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB RAM, Windows 11 Pro 26200. Title 1.0.2.1, Series X profile,
diagbuild with--features diagnostics,VICTORY_D3D12_DRED=1, scriptedEnterfrom 15 s to 280 s. Shader cache and pipeline library made beforehand withtranslate --cache --pipelineson each tree.Tree:
main13f91ca+ #1906 (a554b15) + #2098 (33a65d1) + #2626 (d1dc7ad) + #2628 (46d530a) + this PR (b9dc4b0), merged in that order. Two conflicts, both indescriptor/host.rsand neither in code: #2098's doc comment onwrite_addressagainst #1906's (merged), and #2628's two new tests at the same spot as #1906's (both kept).Runs, one each, 600 s limit:
main13f91ca0x887A0001at 9 sno host texture … format: 115(2560x1440 render target), as in #1952 / #1781main+ #26260x887A0006at 85 s0x80070057) as the world loads, then a hang in the list that was runningWith the stack:
0x80070057(WaveSize(64)on a 32-lane host; @moe-miau had 166), and 8 programs whose draws are dropped because they don't translate.translate --cache --pipelineson this card: 25,752 of 25,985 programs translate (233 refused); of the pack's 28,164 pipelines, 23,112 made and 3,624 already in the library in 770 s with--jobs 12, 397 refused by the host (the same count onmainand on the stack, close to the 394 in #2220).Not tested: more than one run per tree; #2176 / #189 or #2118 on top; Series S profile; release build.
AI use: Claude Code (Claude Opus 5.5) merged the trees, ran the title on my machine (sandboxed at Low integrity, game folder read-only), read the logs and frame captures, and wrote this report.
@steven-seagull27 on GitHub · 2026-11-26 01:31 UTC · original
I tested the default vendor gate on this PR and its direct parent with an overlapping-view GPU write/readback on an RTX 5080 (driver 621.40) and built-in WARP. On the RTX, this change fixed every read through the two 16-byte-aligned SRV origins. The three unaligned origins reproduced the parent’s results.
13f91cab9dc4b0Five 12-byte-stride structured UAVs at different origins write into one allocation in separate trials. For each trial five overlapping SRVs read three fields across 32 lanes. With the writer at byte 0 and reader at byte 12, lane 1 of the first field read
0xa170000cinstead of0xa1700006. The unaligned reads diverged even on fields the writer left untouched. WARP reported the raw-view gate off and the RTX reported it on.The test-only commit on this exact PR head is available if you want to compare other adapters. With
VICTORY_RAW_STRUCTUREDunset, run this twice in separate processes, settingVICTORY_D3D12_WARPto0and1respectively.For the merge comparison, the same fixture on #2178 gave 544/2,400 on each adapter. Those mismatches were confined to newly written words read through a different origin. These are synthetic readbacks, independent of the in-game frame-rate runs above.
AI-assisted with Codex.
@lhnizdo on GitHub · 2026-11-26 06:12 UTC · original
Thanks @steven-seagull27, that's a clean measurement, and it shows exactly this PR's limit. A raw view has to start on 16 bytes, so
buffer_srvonly makes a structured view raw whenfirst * stride % 16 == 0. Views at 12, 24 or 36 bytes stay structured and keep NVIDIA's misread, as your table shows.#2885 goes further: a view off 16 bytes gets its own copy at an aligned start, and the table-bound path is lowered through raw handles too. So it should cover your unaligned origins as well. If the maintainers prefer #2885, this PR can be closed in its favour. Your fixture would be a good check of #2885's unaligned case.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.