Proposal: run the title's ray/node test on the hardware instruction instead of emulating it (AMD) #110
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#110
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Fran-co-F on GitHub · 2026-11-26 03:45 UTC · original
The title traverses its own acceleration structures in compute shaders and uses the console GPU's per-node test,
image_bvh_intersect_ray/image_bvh64_intersect_ray. Here that instruction is emulated in DXIL (crates/victory-shader/src/emit/intersect.rs): four slab tests plus a sorting network per box node, and a watertight test per triangle node. AMD GPUs from RDNA2 to RDNA4 still have the instruction, and the AMD driver already exposes it to D3D12 shaders. So the emulation could be swapped for the real thing at one point in the translator, leaving the title's builder and traversal loops as they are.Evidence
AmdExtD3DShaderIntrinsics_IntersectBvhNode(opcode0x22), documented as "Intersects a ray with a HW-format BVH node", available in all stages, returninguint4. It takes a 64-bit node pointer, ray extent, origin, direction, inverse direction, flags (BoxSortEnable,ReturnBarycentrics) andboxExpansionUlp. It ships in the FidelityFX SDK'sAmdExtD3DShaderIntrinsics.hlsl, called through the magic-UAVInterlockedCompareExchangepattern, and gated byCheckSupport(AmdExtD3DShaderIntrinsicsSupport_IntersectBvhNode).llvm-mc -mcpu=gfx1201assembles bothimage_bvh_intersect_rayandimage_bvh64_intersect_ray. On an RX 9070 XT, RADV withRADV_DEBUG=bvh4traverses withimage_bvh64_intersect_rayover the older node format (confirmed in the ACO disassembly) and matched a CPU reference exactly: 0 hit/miss and 0 primitive mismatches over 65,536 rays.RADV_EXPERIMENTAL=emulate_rt): 1.57–2.71 ms against 3.64–7.30 ms. The emulation here also reads nodes through the guest-page directory, so the gap may be larger.0x22indxil_ags.hpp, but does not implement it. With a small RADV extension that lowers a new SPIR-V op tonir_intrinsic_bvh64_intersect_ray_amd, the same DXIL would run on Linux too. Nobody exposes that op today, so it is more work than the Windows path.What it needs
intersect.rswhen the device reports support, and keep the emulation as the fallback (NVIDIA, Intel, unsupported drivers).Open questions: the 16-bit box node format and the exact rounding and tie order against the console (
bvh.rsand the GPU tests that compare with it would settle that), and how the driver's built-in descriptor handles flags the title sets in its T#.How much ray tracing costs here (measured). This fork on Linux (RX 9070 XT, RADV),
play.ps1settings, same street scene (~5,200 draws/frame),VICTORY_GPU_TIMING=1, which times each list on its own and so inflates absolute numbers:-RayTracing-RayTracingSo with ray tracing on, its passes take about 100–140 ms of card time per frame, more than everything else together. (Without the timing switch the frame is ~50 ms and CPU-bound; the frame recorder's replay puts the drawing queue at ~22 ms of card time.)
How much the instruction buys depends on the split I couldn't get: how much of those 100–140 ms is traversal (the ~64 programs that use the instruction) and how much is the builder, resolve and denoise passes, which don't speed up. If traversal is half, a 2–3× faster node test saves roughly 35–45 ms of card time per frame. The pipelines in the timing log and the replay aren't named, and the replay leaves out the async compute queue, where this work probably runs, so a per-pass split needs a tool that sees all queues (RGP on Windows, or a replay that records the other queues).
Related, for the memory side: #95.
@Jrjy3 on GitHub · 2026-11-27 02:14 UTC · original
A data point on where the ray-tracing time goes on RDNA 4 (Radeon AI PRO R9700, Windows 11, Ryzen 9 9950X3D). Build: main
014d52d+ #55. Scene: idle at the boat, 2560x1440 output.Frame time: 73.5 ms with RT off and 108.3 ms with
VICTORY_BVH_BUILDER=1, about 35 ms more.Per-dispatch GPU time with RT on: diagnostics build,
VICTORY_RT_STAMPS=1, 145.7 ms frame with the stamps on.Of the walking programs,
6d7fe7745ab9c6d8takes 10 ms in 3 dispatches. The others (b58eb3ca6ee46427,3592426e3e9142d8,f22a76fcb967ee59,f607780aa8e502d0,36f04a4ed0ad1d9b) take 2.5-4.4 ms each.So on this card the builder is nearly free. The cost is the walking itself, which reads title memory by address. Moving that work onto the hardware node test, or onto port RT's views, would help most.
🤖 Generated with Claude Code