Repository navigation
Conversation
A root SRV or CBV has no bounds on the host: a shader access past the memory the host mapped there is a GPU page fault. The console's buffer views of the same memory have record counts, and the offsets come from title data the host may not have mirrored (zeros, stale memory), so such accesses happen. Some hosts' GPUs stall on the fault until the driver resets the device as hung: a mesh dispatch of a program that reads its vertex streams through a root view with a formatted load hangs an RTX 5090 and the device is removed. The host now passes each root view's byte size in the user-data dword of its address (which the shader never reads, the view being bound as a root argument), and every raw, formatted and constant access through a root view checks the bytes it touches against it: reads past it give 0, writes are dropped, as for a console view past its records. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Tested on native Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).
- cargo test -p victory-shader: all 70 unit tests passed cleanly, including
oot_view_reads_stop_at_the_bound_size verifying that out-of-bounds reads past bound root view sizes safely clamp and return 0. - cargo test -p victory-gpu: all 43 tests passed cleanly (0 failed, 1 ignored benchmark).
- cargo xtask policy: 151 files ok.
- Verified Lower::root_view_size and State::root_view_bytes user-data binding to prevent GPU faults and TDR stalls on unmirrored/stray root view reads.
|
In-game AMD data point (RX 9060 XT): with this PR, #294's root-UAV programs run without the device hang it otherwise causes 25–31 s into the world (2 runs each, with and without this merge in MichaelSmithAI's AI-assisted (Claude Code, Claude Opus 5.5); no game data. |
|
Great root-cause work on the root-view page-fault hangs! I merged Verification on
|
…the host binds Marvisak#294 alone hangs the device on a BVH builder program whose root UAVs alias one host copy: its writes past the copy fault, and the GPU stalls until the driver removes the device. Marvisak#650 passes each root view's size in the user data dword of its address and checks accesses against it. Conflicts resolved so both sides keep their behavior: - draw.rs: the size is root_len of the view's host copy, as Marvisak#294's root_view binds it, so at most 64 KiB for a CBV, ROOT_SRV_MAX for an SRV and ROOT_UAV_MAX for a UAV (the bytes refreshed and copied back); views bound to a fallback (unset, null, outside the copies, misaligned) get 0. The view kind comes from the stage's root_uavs and root_srvs, so user_dword takes the stage. Marvisak#650's root_view_len is dropped. op_text prints the size without looking it up as a heap index. - lower.rs: smem keeps the integration's descriptor tracking with Marvisak#650's checks; the size is only read where a check uses it (raw reads, constant buffer reads at a computed offset), so constant buffer reads at constant offsets add no user data. Marvisak#294's global stores, which Marvisak#650 predates, drop writes past the view's size as buffer stores do. - diff_tests.rs: the heap guards and Marvisak#650's root view sizes. - valu_tests.rs: the integration's tests, with the root SRV and root UAV tests passing their views' sizes (and the root SRV cases the heap guard), plus Marvisak#650's test adapted to the four-argument resource::track and emit.
…the host binds) Out-of-range reads and writes through a root view are a GPU page fault that some hosts stall on until the driver resets the device (upstream Marvisak#650: a read 1 GB past a root SRV stalled an RTX 5090 10.7 s with no DRED report; our own runs show submissions of 2-7 s then DXGI_ERROR_DEVICE_HUNG, and the compute kernel 4ddd6f9702fab2a7, which only translates since the spill and root UAV merges, stores through an offset computed from buffer data). The PR is written for main before root UAVs: its root_view/root_view_len take a bool, ours (Marvisak#294) a RootView kind with per-kind caps. Kept ours and made the size the shader checks against root_len(kind), so UAVs are bounded too (the caller picks Cbv, Srv or Uav from the stage's lists). The three conflicts in emit/valu_tests.rs are interleaved tests of both PRs: kept ours and dropped the PR's own new test (not ported). The Root UAV hardware test now supplies view sizes in the user data, as the host does. Workspace tests pass. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Independent synthetic A/B on GTX 1660 Ti (6 GB), NVIDIA 581.42, Windows 10 22H2 build 19045.6466, Ryzen 5 3600, Rust 1.98.1 and Agility SDK 1.620.2. Both test processes confirmed NVIDIA LUID 00000000:00017c52. A: parent d2a4bae with a port of the fixture. B: PR 06657a8 with its fixture. Both use the same 256-byte backing buffer and hardware-only adapter assertion. B receives a 64-byte logical view size. The readbacks at byte offsets 0 and 60 were 0x100 and 0x10f in both; at offsets 64 and 128, A returned 0x110 and 0x120, while B returned zero. B also returned zero at the near-maximum offset; A did not attempt that offset. Each filtered test passed 1/1, 0 failed, 0 ignored, 69 filtered out. WARP excluded.
This tests synthetic compute raw-SRV loads and GPU readback. Stores, atomics, in-game host size calculation, DispatchMesh hangs and image quality remain untested. Codex prepared the worktrees and fixtures, ran the tests and drafted this report. |
…or UAV uses its raw view A root view is a bare address on the host, with no stride of its own, so indexed (structured) loads, stores and atomics through one stopped with "a typed root view". The BVH builder's programs at 0x38220, 0x39f00, 0x45c80 and 0x53fd0 stopped there. Resolved against Marvisak#650's root view bounds as the msai-pr4 merge (66ac451) does: buffer() turns an indexed access through a root view into a raw one at byte index * stride + offset (the stride the title declares; none stops with "a structured buffer of unknown stride"), and that access must both lie in the bytes the host binds and come from an index whose byte does not wrap past 4 GiB. structured() is left with heap views only. The PR's GPU test runs with the root view's size in user data, as Marvisak#650 needs, over bound sizes that cut element 2 short and an index that wraps.
…UAV raw view) Targets the 'emit: a typed root view' group: 41 -> 40 failing containers in the offline translate (the typed-root-view program now translates); prerequisite for Marvisak#710. Conflicts with the V_DYNAMIC stride path in lower.rs: kept V_DYNAMIC (no stride check) inside the PR's new structured() helper. The new-tree bounds check from Marvisak#650 only covered the in-element offset, so for a root view the index*stride is now folded into the byte offset before the check, and the PR's GPU test passes the view size in root constant 0 as Marvisak#650 requires. resource::track gained a parameter in Marvisak#294; one test call updated for it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the host binds # Conflicts: # crates/victory-shader/src/emit/valu_tests.rs
# Conflicts: # crates/victory-shader/src/emit/valu_tests.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sak#550) On NVIDIA the shader-visible view heap is capped at 1,000,000 descriptors while the title's is 1,245,184, so title slots past the cap ('title slot past the host heap') have no host slot. When a table there could not be made afresh, the draw fell back to the title's offset and the shader read past the heap's end: garbage descriptors, then device hang. Dropping that draw trades a removed device for one missing draw. Merged with the root-view size bound (Marvisak#650) in State::bind: both fallbacks kept. No unit test upstream: the path needs a bound heap on a live device. Targets symptom 1 (title slot past the host heap). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Port of upstream PR Marvisak#710 (b1faa34, ac1bc81, a5a40bc). XboxBvhBuilder's compute programs pass a 64-bit buffer address as two root-constant dwords and read it with global, scalar and buffer loads; translation stopped on them with "an address from a root parameter that is no address". The resource tracer pairs the two halves. The lowering binds the address as a root SRV t<n> in ROOT_ADDRESS_SPACE; the GPU side composes it from the constants' current values at every draw and dispatch, and drops one whose address is unset or below 64 KiB. Writes and typed views through such an address still stop the translation with a reason. Unlike Marvisak#710, reads are bounded as Marvisak#650's root views are: the host passes the bytes it maps from the address in a user-data dword past the console dwords and the heap guard slots (AddressView::size), and reads past it return 0. A root view has no bounds on the host, and a read past the host copy is a page fault NVIDIA can hang the GPU on. Census rv709 -> rv710: 21751 -> 21756 validated (compute 1428 -> 1433), no program regressed; the 10 "no address" refusals are gone.
|
On an RTX 3070 Ti Laptop (wave lanes 32..32, NVIDIA driver 610.88, Windows 11 build 26300), this PR removes the mesh-shader hangs in the world that #587 alone did not (see my correction on #587). Tree:
|
Merged with Marvisak#254's shader cache: the host's wave sizes (Target) are part of every cache key, the offline warm-up (translate --write-cache) stores under the same key and detects this machine's GPU when no target is given, and the worker queue passes the target to each worker. Stale test initializers from Marvisak#650 and Marvisak#233 updated (Parts::target/console_cf, Container::total_size). On the RTX 4070 no compute pipeline is refused any more and the world shows a full skyline of lights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fer accesses Brings byte and half loads/stores on buffers, flat and global memory, sub-word cbuffer reads, and structured UAVs for 64-bit atomics. Resolutions against the branch: - scalar loads through root descriptors keep Marvisak#294's built-source path; - root view bounds (Marvisak#650) gate the sub-dword and atomic paths too (atomics narrow their active lanes by the bound); - the Marvisak#383 LDS byte path uses lds_ptr and refuses 64-bit LDS atomics; - memory_tests fill root view sizes in user data, as Marvisak#650 requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… atomics Recovers 11 of the failing title compute programs (about 1600 of the 6620 dropped dispatches per frame measured). - resource: a 64-bit address passed in two dwords of root constants is that parameter's (Address::word); v_readfirstlane of a computed address is followed (code tables indexed per lane, made scalar). - emit: such an address is a root SRV, or a UAV when stored or atomic through, at register CONST_VIEW + its user-data index; the host rebuilds it from the constants. Its size takes a user-data dword past the root arguments, as Marvisak#650's bounds need. - emit: indexed accesses to root views read index * stride as raw bytes (no structured root views), bounds-checked as raw ones. - emit: 32-bit global atomics on root UAVs (fmin/fmax through a compare-exchange loop with the hardware's ordering of zeros). - ir: the spill-table pre-pass follows its pointer through joins (a dataflow over jumps) instead of forgetting it at every branch target. - gpu: user data goes in a root CBV (upload memory) when root constants would pass the 64-dword root signature limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent synthetic validation on desktop RTX 3050 6 GB (Ampere), NVIDIA driver 610.88, PCI ID Tested PR head The existing fixture completed on both adapters, including expected zero reads at offsets 64, 128 and Scope: synthetic raw-SRV reads only; not proof of a fix for mesh dispatch hangs, stores/atomics, table SRVs or gameplay. PR head tested as-is apart from adapter logging, not merged onto current main. AI-assisted instrumentation, test execution and reporting (ChatGPT and Codex). |
|
Test report for this PR's idea on Linux/NVIDIA, where it seems to remove the driver-level faults (not a code review). Setup: Arch Linux, Wine (GE-Proton11-6) + vkd3d-proton, GTX 1660 6 GB, NVIDIA 620.73.04 open modules, Series X mode. On this host a GPU fault shows as Tree: #1433 with #1492 merged by hand plus #1077 #1175 #523 #530 #1040 #1406 #542 #1056 #1392 #1516 #1388 #1189 #1523 #635 #988, and #1769. This branch does not merge there (8 conflicts with #542's 2 GiB guards in Runs that reached the world, same tree with and without the port:
Before that tree existed, Xid 13 also ended runs during loading, before the world (about 7 of some 50 runs this evening, always a few hundredths of a second after the first bind of the same group of loading-phase pipelines, one of which is a mesh pipeline reading through a root SRV); none of the 5 runs with the bound did. The sample is small and the 5 runs also carried a lower cap on a wave64 wait loop, so the Xid 109 column is not attributable to this PR. The Xid 13 column is the one this PR is about. The runs with the bound still end for other reasons (the title's own stop after a render iteration longer than 30 s, or a title assert while streaming). Reads that legitimately reach past the host copy now return 0 where the console would read real memory, so this trades a fault for possibly missing geometry; I cannot judge the picture yet (the world is still dark here). |
|
Automated triage for the maintainers. Closing because this change is already in Root SRV/UAV accesses are bounded in main another way (d71c388: root views read through heap views of the host copy, offset from user data; Lower::root_view). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
What
A root SRV or CBV has no bounds on the host. Any shader access past the memory the host mapped there is a GPU page fault. The console's buffer views have record counts, so a console program never faults on these. But the offsets come from title data, and when the host has not mirrored that data (zeros, stale memory) the reads land far outside the view.
Lower::root_view_sizereads the view's byte size from the user-data dword of the view's address. That dword is otherwise unused, because the view itself is bound as a root argument. The lowering records it as a newUserDataentry withroot: Descriptor. Every access through a root view checks the bytes it touches against that size: rawbuffer_*loads, stores and atomics, the raw loads behindtbuffer_load_format_*andbuffer_load_format_*,global_load_*, per-lane constant-buffer reads and scalars_buffer_load_*. Past the size, reads give 0 and writes are dropped, as for a console view past its records. An out-of-range access goes to offset 0 instead, so the hardware never touches memory past the view.State::root_view_bytesfills that dword with whatroot_viewbinds there: up to 1 MiB for SRVs and 64 KiB for CBVs (the newroot_view_len), or 0 when the title set no view.Why
Translated programs were replayed on an RTX 5090 with synthetic data (hardware probe, not part of this PR):
tbuffer_load_format_*, given nonzero data, removed the device as hung (DXGI_ERROR_DEVICE_HUNG) after 3.7 s, every time.In the world, these are the mesh hangs that #578 currently avoids by refusing wave64 mesh programs on 32-lane hosts. They are not about the wave size.
Tests
root_view_reads_stop_at_the_bound_size. A program builds a buffer descriptor around a root SRV address and reads at offsets inside, at and past the bound size. The test checks the reads past it give 0 even where the bound buffer holds data, and that the size is aDescriptoruser-data entry. Passes on an RTX 5090 and on WARP.cargo clippy --workspace --all-targets,cargo clippy -p victory --features diagnostics --all-targets,cargo test --workspace,cargo xtask policy: pass. The remaining clippy warnings are already onmain.Not covered: root UAVs, which
maindoes not bind yet. Open PR #294 adds them, and its root UAV accesses take the same check once both land.🤖 Generated with Claude Code