bvh: fix canonical 64-bit VA and non-hidden lazy mapping for hardware BVH64 (#33) #38
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!38
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-38"
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?
@HeroOfOlympus on GitHub · 2026-11-30 19:29 UTC · original
HeroOfOlympus:main→main· +30 −16 · 3 files · 1 commits · closed without mergingFixes #33
Root cause
Two issues prevented
VICTORY_BVH_HARDWARE=1(image_bvh64_intersect_ray) from returning hits on RADV:Non-canonical 40-bit base VA & wrong descriptor bounds (
crates/victory-shader/src/emit/intersect.rs)um.rsmirror allocations land in high canonical AMDGPU VA space (e.g.0xffff80025e600000), which gets truncated when packed intoword0/word1of the BVH descriptor.word2was set tocard[3] - 1(64-byte node count instead of 8-byte units / full range).((1 << 42) - 1) << 3) and pass a zero-based full-range descriptor (word0 = 0,word1 = flags,word2 = 0xffff_ffff,word3 = 0x3ff | (DESCRIPTOR_TYPE << 28) | RETURN_BARYCENTRICS), matching RADV (radv_nir_rt_common.c).HIDDENlazy mappings backed byzero_bo(crates/victory-gpu/src/um/lazy.rs)bind()andmake()mapped unseen pages withHIDDEN(VK_MEMORY_ALIAS_HIDDEN_BIT_RADV). BecauseTest::CardbypassesSLOT_MEMORY/SLOT_FAULTS, hardware BVH64 reads hitzero_boinstead of actual title BVH memory.HIDDENinbind()andmake()(keepingprobe_card()intact).Bumped
TRANSLATOR_VERSIONto11incrates/victory-shader/src/lib.rsto invalidate cached shaders.Result
Tested on RX 9070 XT (RADV 26.3.1, Linux):
VICTORY_BVH_HARDWARE=1renders full geometry and daytime RT GI cleanly (~35–48 FPS, 0 dropped draws, 0 GPU hangs).@enjoyerofslop on GitHub · 2026-11-30 23:25 UTC · original
Tested on a Radeon 8060S (Strix Halo, RDNA 3.5 iGPU): Bazzite 45, Mesa 26.3.1 with this repo's RADV patch, Proton-CachyOS 11.0, at
4cce312plus this PR (plus a local change soum.rsaccepts an integrated GPU).Before the PR,
VICTORY_BVH_HARDWARE=1drew most geometry black, as in #33. With the PR, most geometry renders, but some thin geometry (the railing balusters on the prologue deck) is still solid black in some camera shots.With
VICTORY_BVH_HARDWARE=0the PR renders correctly and has no measurable effect on frame time.Timing (diag, 2560x1440, Series X profile, 330 s window, matched draw count): hardware test 41.4 ms vs inline 46.7 ms.
@enjoyerofslop on GitHub · 2026-12-01 02:31 UTC · original
Correction to my comment above: I can no longer reproduce the black thin geometry with this PR on the 8060S.
VICTORY_BVH_HARDWARE=1since then render it correctly. One was a full run: 42.0 ms at 8,582 draws, against 46.8 ms at 8,875 draws withVICTORY_BVH_HARDWARE=0(diag, 2560x1440, Series X profile, 150–480 s window).The builds carried two local changes besides this PR:
um.rsaccepts an integrated GPU (device type 1) when there's no discrete one.bvh_hardware, a triangle test on a node the card doesn't hold goes in as kind 7 and returns0xffffffffin all four dwords. That's four NaNs, which the walk programs' distance tests accept as a hit. It now returns[inf, 0, 0, 0], as a node of zeros does inline. This didn't affect the black, but it looks like a real hole. I can open a PR for it if useful.For what it's worth, on RDNA 3.5 the instruction returns all four triangle dwords scaled by |largest direction component|³. The ratios are the same, so num/den and the barycentrics come out unchanged. An in-game comparison against the inline test over the seven walk programs shows hit decisions agreeing apart from ties at the ray's extent.
@YaBulochka on GitHub · 2026-12-01 08:30 UTC · original
Hardware BVH64 on RDNA3 renders, but the whole scene comes out dark: underexposed, as if every surface sits in shadow. Not dark textures — the light itself is missing.
Environment. RX 7600 XT (8 GB, RDNA3), Ryzen 5 9600X, 30 GB RAM, RADV 26.3.1 from
./setup.sh. Buildede9bc9(pr38+ #51 + #52 merged on37bb30f).series-x,VICTORY_OUTPUT=1920x1080, RT on.What happens.
VICTORY_BVH_HARDWARE=1:the ray-tracing node test by the card's own instruction on=true, no errors in the log, geometry is there and correct (no black meshes, faces fine),~12.2 fps / 81.8 msin the harbour scene, 1280x720 -> 1920x1080. The picture, though, is far too dark: pavement, cars and foliage read as if in shade, while the sky and the water reflections are normal.VICTORY_BVH_HARDWARE=0on the same build and settings, the same place is lit normally.So the node test itself passes now (it did not before the PR), but the traced results look like a hit that should miss, for shadow/GI rays rather than primary ones: reflections and direct light survive, shadowed regions swallow everything.
Two things I could not tell apart from the outside, in case one of them is a known limitation: ray origin epsilon / self-intersection, or the instance transform (BLAS -> TLAS) being applied with the wrong basis, both of which would darken shadow rays first.
Happy to run any diagnostic switch you point me at. No game files, screenshots or captures included.
@Luxuride on GitHub · 2026-12-04 12:00 UTC · original · edited 2026-12-05 11:24 UTC
As I read it, this is already in
main: this exact change was cherry-picked tomainas8aec563, with the same title, the same--stat, and a body naming this PR's head (79e9a57).The lines are live today:
crates/victory-gpu/src/um/lazy.rs:496let protection = if touched { READ_WRITE } else { 0 };(and:640-641), andintersect.rsbuilds the descriptor frombvh_addresswith word30x3ff | (DESCRIPTOR_TYPE << 28) | RETURN_BARYCENTRICS. The merged copy was then refined bye7e7bb4("gpu: pre-encode the native BVH64 mirror base"), andTRANSLATOR_VERSIONis now 20, so the version bump has been superseded three times over.Nothing here is unreviewed work — the PR is older than what runs. If you want to continue on BVH64, start from
main.Whether it still has work of its own is the maintainer's call, not mine.
Pull request closed