Repository navigation
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:
- Preserving high pointer bits in root-derived BVH node addresses (
#2368) passes all unit and live GPU BVH intersection tests. cargo test -p victory-shader bvh: 15/15 passed on RTX 5090, 15/15 passed on WARP (includingroot_derived_node_address_keeps_high_pointer_bitsand all GPU intersection tests).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.
AI-assisted (Gemini 4 Neon).
|
Overlap check: #2402 (Xvania7, opened 12:57Z, "fixes #2368") and #2040 (mgunes1311-lab) target the same issue, and andrewpozdnakov7-jpg has been comparing #2402 with #2040 on WARP. From reading the diffs against
So the three need one pick, or a combination. I haven't run any of them. AI-assisted (Claude Code). Read from the diffs only. |
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: merged into main 940d32f, cargo test -p victory-shader --locked on macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — high bits preserved in root-derived buffer addresses.
oni-swr
left a comment
There was a problem hiding this comment.
Side-by-side check of #2501 (ca57ed43) and #2467 (c79cb207). Both change only the Source::Built + root_address (Nodes::Raw) arm of crates/victory-shader/src/emit/lower/bvh.rs, for #2368. I read both diffs in full.
Overlap: both stop shifting the node offset in 32 bits and then zero-extending it. Both build base64 + (node << 3) + k (+ dynamic) in 64 bits. The Nodes::Buffer fallback is unchanged in behaviour in both.
Differences
| #2501 | #2467 | |
|---|---|---|
image_bvh64 high node word (node_hi) |
still ignored on this arm; only lo<<3 is widened |
folded in: ptr = lo | node_hi<<32, then <<3 |
dynamic term |
ZExt to 64 bits |
SExt to 64 bits |
k |
constant i64 |
ZExt of the 32-bit value |
| tests | none added | one test, a Rust mirror of the arithmetic; it does not call the lowering. It is also not rustfmt-clean (rustfmt --check fails on the test fn signature) |
| buffer path | rewritten in an explicit else branch (same ops) | untouched |
Edge cases.
- With
node_hi != 0, #2501 still drops the high pointer bits. It fixes thelo<<3overflow for BVHs above 512 MiB, but not 64-bit pointers. #2467 handles both, and the already-passingintersections_with_64_bit_pointers_on_the_gpu_equal_the_referencetest exercises theNonepath rather than this one. dynamicsign: the two disagree for values >= 2^31. Under #2501, a negativedynamicthat used to wrap correctly in 32 bits, with the sum below 2^32, now lands 2^32 too high. Under #2467 it is correct for negative values but wrong for an unsigned offset >= 2^31. Nothing I read inAddress.dynamicorbuilt_offsetstates which is intended. The authors should say, ideally with a test through the real lowering.- Neither adds a GPU/WARP test of the
Nodes::Rawpath, so the new arithmetic is not exercised end to end by the suite.
Supersede or complement? They are alternative fixes to the same lines and will conflict, so only one can merge as written. #2467 is the more complete one (it includes node_hi). #2501 has the cleaner 64-bit constants, and its comment about negative offsets does not match its own ZExt of dynamic. If #2467 is picked, its dynamic sign question and a real lowering test should be settled first.
Verification (Windows, VICTORY_D3D12_WARP=1, WARP only):
- #2501
ca57ed43289e97748adb277cbfcbcec4994dcc0e:cargo test -p victory-shader --locked --lib— 247 passed, 0 failed, 3 ignored;... --lib bvh— 14 passed, 0 failed, 0 ignored. rustfmt clean. - #2467
c79cb207dcbea305a35f91a541b6bea0a522f9d8:cargo test -p victory-shader --locked --lib— 248 passed, 0 failed, 3 ignored;... --lib bvh— 15 passed, 0 failed, 0 ignored (includes its new test).
AI-assisted (Claude Code / Claude Sonnet 5.5)
|
Automated triage for the maintainers. Needs work (the test). Thanks for the update. In The new test This still overlaps #2501 on the same lines, and the maintainer should pick one or combine them. CI: Generated by Claude Code |
|
Real fix, two bugs in the old path: Minor: |
fyernald
left a comment
There was a problem hiding this comment.
Tested on RTX 3080 (617.42), Windows 10 (19045) plus WARP, main 67e8ae1 + #486 + #2596 (the suite crashes on NVIDIA without #2596, #2571). cargo test -p victory-shader --lib --locked -- --test-threads=1: 268 passed, 3 failed (the #1835 ones, also on the base). Nothing regresses. Two things, though:
dynamicis sign-extended (Cast::SExt), but it's the byte offset the built descriptor adds to the root address (built_offset). The console adds that with an unsigned carry, and this PR zero-extends the constant partk. A dynamic offset of 2 GiB or more would come out 4 GiB too low. #2501 zero-extends it.- The test can't fail on the lowering.
built_root_node_addressre-implements the arithmetic in plain Rust and checks it against itself, so it would pass even ifbvh.rswere unchanged. #2501 has an end-to-end test (a_node_pointer_above_two_gib_reads_where_it_points) that passes on an RTX 3080.
#2501 is the same 64-bit shift and add without node_hi. The node_hi part is what this PR adds over it (it matches the explicit-descriptor path on main), so it might be easiest to rebase that onto #2501 with zero-extension and a hardware test.
…ed BVH node addresses (Marvisak#2368)
c79cb20 to
90ee09d
Compare
|
Tested head 90ee09d on Windows 11 with an RTX 4050 Laptop (595.97) and WARP, running
The two PRs fix the same lines, each covering what the other misses. The simplest landing is #2501 plus AI-assisted (Claude Code). |
fyernald
left a comment
There was a problem hiding this comment.
Retested 90ee09d on the same RTX 3080 / Windows 10, now on main 63bcca4 (+ #486, #2596 for #2571).
- The sign extension is gone. The offsets now go through zero extension, and the self-checking test is removed.
- To exercise the lowering itself, I applied only #2501's
bvh_tests.rschange (the 4 GiB-higher page and node pointer with bit 29 set) on top of this branch.a_node_pointer_above_two_gib_reads_where_it_pointspasses on the RTX 3080 with this PR and fails onmain, and all 15bvh_testspass. - Full
cargo test -p victory-shader --lib -- --test-threads=1: 298 passed, 4 failed, the same four as the base. Nothing regresses.
The one thing left is that the PR has no test of its own now. Carrying #2501's end-to-end test over, or landing the two together, would cover it. One difference from #2501 for whoever picks between them: here k + dynamic is summed in 32 bits before widening, so a carry out of that sum is dropped, while #2501 adds each part in 64 bits. That only matters when the two together reach 4 GiB.
|
Pushed three follow-up commits addressing the triage and review points:
Validation (Windows, Rust 1.100.0/MSVC,
Thanks @Marvisak, @rminzao and @fyernald for the precise reviews. Please re-check the updated head AI-assisted (Hy4 flash). No game assets, extracted data, shaders or DRM-related material were used or uploaded. |
…ed BVH node addresses (Marvisak#2368)
nathanbzrr
left a comment
There was a problem hiding this comment.
Reviewed 8676134 merged onto main (63bcca4). The 64-bit widening in crates/victory-shader/src/emit/lower/bvh.rs:138-158 (super::flags::INT64 with wide64 and Cast::ZExt on k and dynamic) correctly propagates carries into the upper 32 bits of Nodes::Raw, and policy (191 files ok), clippy, and bvh tests pass on Windows 11 (AMD Radeon RX 7600 + VICTORY_WARP=1, 15 passed; 0 failed).
However, two test gaps should be addressed before merge:
intersections_when_a_node_pointer_carries_into_the_high_word(crates/victory-shader/src/emit/bvh_tests.rs:818-854) does not fail if the 64-bit carry is dropped.
It callsrun_cases_at(false, 4, false, TITLE - 0x1_0000_0000, 0x2000_0000). Inpage_table_at(bvh_tests.rs:825-837), bothbase(0x11_3450_0000) andtarget(0x12_3450_0000) share the exact same low 32 bits (0x3450_0000), map both L1 indices (275and291) to the same L2 block1, and populate the same L2 slot[view, 0x3450_0000]backed byView::Memory(&data). If the carry out of the low word were truncated and the shader loaded frombase(0x11_3450_0000) instead ofTITLE(0x12_3450_0000), the page table would still return identical data and the test would still pass. Givingbaseandtargetdistinct page-table targets (e.g., mappingbasetonullor a different offset) would make it genuinely catch a dropped high-word carry.- No coverage with
wide = true(node_hi != 0) in title memory.
intersections_when_a_node_pointer_carries_into_the_high_wordpasseswide = false(node_hi = None), whilerun_cases(true, 8, false)passes a zero node-pointer base (node_hi == 0). Adding awide = truecase wherenode_hi != 0contributes to(base + (ptr << 3))resolving to a distinct high-word title page would coverbvh.rs:145withnode_hinon-zero.
AI-assisted; synthetic tests only, no game files.
Claim on the coordination issue #1633:
claiming: new item, issue #2368 — shaders: preserve high pointer bits and 256-byte descriptor alignment for root-derived BVH node addresses; CPU-only arithmetic fix + synthetic unit test, no game data, AI-assisted (Hy4 flash)(comment 7163470612).Problem: in
crates/victory-shader/src/emit/lower/bvh.rs, theSource::Built+root_addresspath computed the node offset as a 32-biti32and then zero-extended it withwide64(at, zero). High pointer bits and carries fromnode_hi,kanddynamicwere lost; the explicit-address path already reconstructed the full 64-bit pointer.Change: one file, +42/−2. The title-memory root path now widens
lo|node_hito 64 bits, shifts in i64, widenskwithCast::ZExtanddynamicwithCast::SExt, and adds everything in 64 bits before constructingNodes::Raw. TheNodes::Bufferfallback keeps its 32-bit offset. A#[cfg(test)]module adds a pure CPU arithmetic mirror test for the two counterexamples:lo=0x20000005→ base+4GiB,lo=5, node_hi=1→ base+32GiB.I initially also applied the explicit descriptor path's 256-byte base quantization (
base << 8), but that made the existing hardware BVH tests fail: the root descriptor in the synthetic fixture carries the base directly, already aligned. The quantization is therefore deliberately NOT applied here; the fix covers the high-bits/carry loss only.Validation (Windows, Rust 1.100.0/MSVC, no game data):
cargo test --locked -p victory-shader --lib emit::lower::bvh::tests::root_derived_node_address_keeps_high_pointer_bits -- --exact— 1 passedcargo test --locked -p victory-shader --lib emit::bvh_tests::intersections_on_nodes_in_title_memory_equal_the_reference -- --exact— 1 passedcargo test --locked -p victory-shader --lib emit::bvh_tests::intersections_on_the_gpu_equal_the_reference -- --exact— passed (hardware, RTX 5060 Laptop)cargo test --locked -p victory-shader --lib— 248 passed, 0 failed, 3 ignoredcargo test --workspace --locked— exit 0git diff --check— cleanAI-assisted (Hy4 flash). GPU/driver: NVIDIA GeForce RTX 5060 Laptop, driver 621.24, Vulkan 1.4.357. No game data, assets, executables or extracted content were used, created or uploaded.