Shaders: bindless through pointer chasing, bias means only the pointer's own adds #1333
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!1333
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1333/head"
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?
@MagiccConch on GitHub · 2026-11-24 17:30 UTC · original
MagiccConch:shader/pointer-chase-bindless→main· +1158 −46 · 9 files · 3 commits · closed without mergingWhat and why
A descriptor can live behind a pointer that the shader itself computes: load the pointer's halves from the root constants, mask them, add a constant, then load through it. Until now
resource.rsonly recognized descriptors loaded directly from the root parameter area, so such shaders fell back to descriptor binding instead of the cheaper root view.This change teaches the tracer to follow the chase, and makes the recorded address honest about which adds belong to the pointer itself.
The change
Address.biasredefined: only the pointer's own adds. Previously an instruction's flat offset could reach the recorded bias, and the lowering added it again from the instruction — double-counting. Fixed inresource.rs: the bias now folds onlys_add_u32-style adds applied to the pointer, while flat offsets stay out and are re-added by the lowering at both the scalar and flat sites.Pointer-chase tracing in
resource.rs:s_load_dwordx2pairs its halves into a deref'd pointerAddresss_and_b32masks (the 48-bit VA mask) keep the bias flowing through the derefLowering (
emit/lower.rs):pointer_smemand the flat-deref path computea.bias + instruction_imm, so the recorded bias and the instruction's own offset compose exactly once.Testing
resource.rs: masked pointer keeps its bias through the deref; non-zero flat offset stays out of the bias (a_flat_offsets_stay_out_of_the_bias— assertsbias == 8, would be28if double-counted)emit/lower.rs: pointer chase binds the pointed buffer as a root view; masked + biased variant binds the same root viewmain(upstream waterfall/per-lane suite included),cargo clippy --all-targetscleanwindows-2025; the known Linux-onlyvictory-gpuhost_resourceissue does not affect these crates@shortselow-byte on GitHub · 2026-11-24 17:54 UTC · original
This branch does not compile at head
ae8d79d(onmainffe310e); checked on Windows 11, Rust 1.98.1 MSVC, in an isolated target directory.cargo build --workspace --locked:and
cargo testalso stops onCause:
root_srvswas widened fromu8tou16(for the0x500pointer register), but not everywhere that reads it.Two fixes I checked locally:
emit/host.rs:138:s.root_cbvs.iter().map(|&r| (u16::from(r), false)), so the chain has one item type.emit/valu_tests.rs: the new helpers and tests were inserted before the closing}ofv_cmp_class_f16_matches_rdna2(after its});at line 938), and that brace is gone. One}there closes it.With those two, more errors appear that they were hiding:
victory-gpu(lib):pipeline/host.rs:365,shader_cache.rs:209,shader_cache.rs:276, all the sameu8/u16mismatch.victory-shader(tests):ShaderandAttrnot in scope inemit/mod.rs(constant_color, lines 527 and 548),diff_tests.rs:1217(Vec<(u16, bool)>from(u8, bool)), aresource::trackcall with 3 arguments, and several mismatched types and derefs. 11 errors in all.The shader cache matters most here.
shader_cache.rswritesroot_cbvs/root_srvsone byte per register (out.extend(slots)) and reads them back the same way, under theVSH1magic. A0x500register doesn't fit, so the on-disk format needs a wider encoding and a new magic, or caches written bymainwould be read wrong.I did not get as far as running the new tests. A
cargo test --workspace --lockedandcargo clippy --workspace --all-targets -- -D warningsbefore pushing would show all of the above.@marquezinii on GitHub · 2026-11-24 18:48 UTC · original
The newer head
55e745bstill doesn't build on Windows (Rust 1.98.1 MSVC, its own target directory).cargo build -p victory-shader --features hoststops at the sameE0271inemit/host.rs:139((u8, bool)vs(u16, bool)), plus anE0599on thecollectafter it.cargo teststops earlier, at the unclosed delimiter invalu_tests.rs(v_cmp_class_f16_matches_rdna2, opened at line 872).@wwwwwwww3333333 on GitHub · 2026-11-24 21:15 UTC · original
At
2901bb6on mainffe310e, victory-shader builds on Windows, but the two new GPU tests fail at the same assert inpointer_chase_shader()(valu_tests.rs:1036):lowered.root_srvsis[0x500](1280), and the helper expects[0x501]. The three lowering tests in lower.rs expect[0x500]for the same kind of chase and pass. So either the helper's expectation or the register numbering needs another look.Failing tests:
emit::valu_tests::a_buffer_reached_through_a_pointer_loaded_from_the_constantsandemit::valu_tests::a_pointer_chase_lowers_to_a_pointer_root_view. RX 6750 XT, Windows 11, Rust 1.98.1 MSVC,cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 2 failed.Unit tests only, no game files. AI-assisted (Claude; I ran it on my machine).
@marquezinii on GitHub · 2026-11-24 22:00 UTC · original
Same two failures at
2901bb6on NVIDIA: RTX 5070, driver 621.40, Windows 11, Rust 1.98.1 MSVC, its own target directory. It now builds, thanks for the fix.cargo test -p victory-shader --lib -- --test-threads=1gives 132 passed and 2 failed, both atvalu_tests.rs:1036withleft: [1280],right: [1281].The lowering looks right and the assert looks off by one.
pointer_handlegives((dword + 1) << 8) | slot, and the pointer here is constants dword 4 of root parameter slot 0. That is0x500, the value the helper's own doc comment gives (((4 + 1) << 8) | 0) and the one the threelower.rstests expect. With only that line changed tovec![0x500], both tests pass on the RTX 5070. That includesa_buffer_reached_through_a_pointer_loaded_from_the_constants, which bindsRoot::Pointer { slot: 0, dword: 4, .. }, runs the dispatch on the hardware device and reads back the chased dword. All 12pointertests pass.@Marvisak on GitHub · 2026-11-25 00:37 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Built on an Address.bias field main does not have; pointer-chased loads are served in main by USER_DATA and MEMORY addresses (
27c3dc9d, resource.rs address()).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.
@sinan-cmyk on GitHub · 2026-11-25 01:49 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: +310 programs over
main, 0 lost. Two of this PR's own tests fail, on hardware and on WARP.Offline. I merged head
2901bb6ontomainffe310e(clean merge; the head is based onffe310e) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 → 22,034.main295 of the 310 are among the programs that #1402 gains (through #1067). 15 are new, and neither #1402 nor #1597 gains them.
Tests.
cargo test --locked -p victory-shader --libfails two of this PR's new tests:a_pointer_chase_lowers_to_a_pointer_root_viewa_buffer_reached_through_a_pointer_loaded_from_the_constantsmainVICTORY_WARP=1, the merge ontomain2901bb6alone, no mergeSo the off-by-one comes from the PR itself, not from a merge or a driver. The other tests pass.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Pull request closed