Shaders: a buffer view picked from the resource heap by index is read as a raw buffer, not a constant buffer (missing world geometry and device removal on a Radeon 8060S) #148
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/148"
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?
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by SPFCChris on 2026-11-25T17:07:46Z.
Closes #48 (whose title is wrong: it was never textures).
Problem
On a Radeon 8060S the world's large geometry (buildings, roads, terrain, vehicle bodies) was not drawn, webs of one-pixel sliver triangles were, and about one run in five ended in a device removal.
In
emit/lower.rs, a scalar load through a descriptor takes its view class fromused_kind(src). That only finds a used-resource record for descriptors loaded from a table. For a descriptor the program loads from the resource heap by index it returnsNone, andNonefell into the "else a constant buffer view" arm, so the handle was annotated as a CBV and read withcbufferLoadLegacy. The host mirrors what the title keeps in those slots as buffer views (raw SRVs).Reading an SRV descriptor as a CBV is outside what D3D12 defines. GPU-based validation names it:
Heap index 17 is the title's 174 MB scene buffer, which the meshlet-culling programs take as user data (
u6=0x11). An RX 9070 XT evidently returns the data anyway. The 8060S does not: the culling programs passed almost no meshlets (1,944 of 2,194 indirect mesh draws had a group count of 0 in a dumped frame), and in the new test below the same access suspends the device.Change
A descriptor loaded from the resource heap by index, with no used-resource record, is read as a raw buffer (
rawBufferLoad, class SRV), which is what the host slot holds. 25 lines inlower.rs.Upstream
mainand fxceless/victory-fork already do the equivalent in their own ways (upstream: "Constant data through the resource heap itself is a raw buffer"; fxceless picks between the two reads at run time from the slot's stride, which also covers a real constant buffer view at a directly indexed slot). If you would rather port one of those, this PR at least pins down the cause and brings a test.Test
emit::tests::scalar_loads_through_a_heap_indexed_buffer_view_execute_on_gpu: a compute program loads a descriptor from heap slot 1, reads three dwords through it withs_buffer_load_dword/_dwordx2, and stores them. Run on the hardware adapter and on WARP.main(01aadd1)Tested
Radeon 8060S (Ryzen AI Max+ 395), driver 32.0.32029.2010, Windows 11 build 26300, diag build, Series X profile,
VICTORY_PRESENT_TARGET=1x1:1,VICTORY_HAIR=1.cargo test -p victory-shader --lib -- --test-threads=1: 267 passed, 0 failed, 6 ignored.cargo clippy -p victory-shader --all-targets --locked: 12 warnings, the same 12 as onmain.Not tested
Shader,UnorderedandPlacedviews at such slots.AI-assisted (Claude Code); no game data.
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by KernelSmoker on 2026-11-25T19:44:21Z.
Independent A/B verification on NVIDIA GeForce RTX 3090 (Bazzite Linux 45 x86_64, driver 620.73.04, GE-Proton 10-34 / Wine 10.0 / vkd3d-proton 3.0.0
bd3f5e3d245c3ad, Rust 1.98.1) on PR head7670245:This fix is not Radeon 8060S-only — it also fixes silent zero-reads on NVIDIA RTX 3090 under vkd3d-proton 3.0.0:
emit::tests::scalar_loads_through_a_heap_indexed_buffer_view_execute_on_gpu)01aadd1(lower.rswithout PR #148)[0, 0, 0]instead of[0xC0DE0002, 0xC0DE0004, 0xC0DE0005]([3235774466, 3235774468, 3235774469])7670245)hardwareexecuted directly on RTX 3090, noskippedline; noteEnumWarpAdapterin DXVK/vkd3d-proton falls back to the hardware RTX 3090 rather than Windows WARP)Additional checks on
7670245:cargo test --locked -p victory-shader: 186 passed, 0 failed, 6 ignored (lib) + 3 passed, 0 failed, 1 ignored (tests/resource_tracking.rs).cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-gnu: 0 new warnings (10 pre-existing warnings).let mut dxil = l.dxil;atcrates/victory-shader/src/emit/mod.rs:1488emitsunused_mut/unused_variableswarnings on non-Windows targets (same pattern as the neighboring#[cfg(windows)]GPU tests).Imported from Belobug/VIctory-Belobug-AMD. Originally posted by adrianmjim on 2026-11-25T19:52:52Z.
Corpus data from the game's
shaders.rpfon an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), head7670245on01aadd1,victory translate --validate --list --host-lanes 32-64, comparing a hash of each program's DXIL with01aadd1:cargo test -p victory-shader --lib -- --test-threads=1: 267 passed, 0 failed, 6 ignored, including the new GPU test. It ran without a device removal on this card.So the change reaches vertex programs too, not only the culling compute shaders, which is worth knowing for the shader cache. Pipelines were not created and the game was not run here.
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-27T14:52:01Z.
Code review location:
crates/victory-shader/src/emit/lower.rs; line 6733Could this get a focused CFG-join fixture as well? The new classification depends on every leaf of
srcbeing a resource-heap load, while the added shader fixture exercises only a direct heap-indexed descriptor. A small shader whose join selects between two heap-indexed buffer descriptors would verify that thePhipath still lowers the load as a raw-buffer view.Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-27T14:52:01Z.
Review: COMMENTED
AI-assisted static review (ChatGPT); I inspected the lowering change and fixture but did not run tests.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.