Proposal: build the title's acceleration structures with host DXR and trace them with inline RayQuery #17
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/fxceless--victory-fork#17
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?
@AlexMJHGF421 on GitHub · 2026-11-24 19:57 UTC · original
Summary
The title's ray-traced lighting (probes, bounce, reflections, lamp and sun shadows) is currently either off or planned as an emulation: the title's BVH builder programs run as translated compute and
image_bvh_intersect_rayis emulated in shader code.That path keeps the console node format, but it does not use the GPU's ray-tracing hardware, some builder pipelines still fail on wave32 hosts, and rounding and edge behaviour of the emulated test are unverified.
This issue proposes a different path aimed at hardware-accelerated traversal where available:
XboxBvhBuilder.dll, translate the Xbox batch records into desktop DXR build inputs, and build host DXR BLAS/TLAS.image_bvh_intersect_ray) with DXR 1.1 inlineRayQuery, keeping the original loop as a per-dispatch fallback.Nothing here is measured yet; it is a design proposal with pointers to existing code in other projects.
Its correctness and cost need to be measured against emulation on the same scene.
Why it is feasible: the title describes its geometry through a DXR-like API
docs/fork-ray-tracing.mdsays mapping onto host DXR "is not practical: the layer would have to know the geometry behind structures the title never describes to it".The title does describe it.
five-star-recomp reversed this in detail (
docs/raytracing.md,docs/d3d12x-shim.md):DisableDXR = 1, builds every structure throughXboxBvhBuilder.dll, and traverses inline.BuildRaytracingAccelerationStructureBatched2X(..., D3D12XBOX_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_BATCHED_DESC2*). Its 0x50-byte batch records carryD3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS(Type, Flags, NumDescs, geometry or instance descs) plus guest addresses, scratch slices and postbuild records.0x38-byte triangle geometry descs built from the title's mesh records (vertex and index buffers).D3D12_RAYTRACING_INSTANCE_DESC.core_bvh4.rpfand are restored withRehydrateRaytracingAccelerationStructureBatched2X, which rebuilds the structure in place from the game's own vertex data (docs/raytracing.mdL74-L108).BvhBuilderShim.cs. five-star builds console-format structures on the CPU from them (src/FiveStar.Shaders/Bvh/XdxrBlas.cs,XdxrTlas.cs).So the host can translate these records into desktop DXR inputs: query host prebuild sizes with
ID3D12Device5, allocate host scratch and result buffers, remap TLAS instance records to host BLAS addresses, and record builds onID3D12GraphicsCommandList4.For mirrored structures this bypasses the console builder programs, including the ones that need 64-lane waves (fork-ray-tracing.md "Known gaps").
The emulated fallback still reads console-format nodes, so console-format structures have to be kept where the fallback is used, for example with a compatible CPU builder like five-star's.
The hard part: traversal is the title's own code
The trace programs traverse console-format nodes using a per-thread stack in shared memory and raw-address loads (fork-ray-tracing.md L14-L28), and read the TLAS root and instance nodes in the layout documented in five-star
docs/raytracing.md"Traversal header".To use opaque host DXR structures, this proposal replaces those walks with inline
RayQuery.Prior art for exactly this, on PS5 (same RDNA node test): KytyPS5
RayQueryTraversal.ir/passes/RayQueryTraversal.cppmatches specific PS5 traversal IR shapes (flat, nested TLAS→BLAS, and shared-stack walks) and rewrites the matches to ray-query operations.spirvEmitterRayQuery.cpp).PSR_BVHLheader and validates the mirrored data with GPU-side hashes (gpu_bvh_mirror.comp, L445-L450; host side starts inrayTracing.cppPrepare).RayQueryversions may be simpler than a general matcher.Prior art for console DXR on host DXR on Xbox: OpenScarlett (californiaAlmonds).
CommandListX::BuildRaytracingAccelerationStructureis forwarded to the host list4 when the host list, tier and descriptors allow it (command_list_x.cpp).XboxBvhBuildershim exposes separate BLAS and TLAS helpers backed byDxrHardwareEngine(BLAS, TLAS,dxr_hardware.cpp). Its export matching this title'sBatched2Xsignature is a stub that records no build (L1281, L1306-L1317).RayQueryor a compute BVH4 fallback from host capabilities and shader requirements (device_x.cpp).Proposed plan
XboxBvhBuilder(exports listed above). Keep the console-sized prebuild answers so title memory layout does not change.Rehydrate, either rebuild from the title's vertex data (as the DLL does) or decode triangle nodes from the serialized BLAS.RayQuery:bvh.rsand the serialized barycentric swizzle in five-stardocs/raytracing.md), map geometry-local primitive indices and instance identifiers, and verify winding and hit-distance conventions (the console test returns a signed denominator).gpu_bvh_mirror.compL462,spirvEmitterRayQuery.cppL141-L144).validflag for the first frames and for anything not mirrored (with console-format data kept for it, see above).Expected result
Open questions
Notes for this fork
In this fork
image_bvh*_intersect_rayis emulated and the builder stays off on 32-lane GPUs. InterceptingXboxBvhBuilderwould let mirrored structures be built without the builder programs.Separately, in
emit/mod.rsthe cross-wave retry now requiresVICTORY_WAVE_WIDE=1, but a separate default-onLANE_MASKretry (L432-L446) calls the same helper. It is intended for the barrier-free trace shaders, but its guard does not explicitly exclude wave64 (the helper can admit a split wave64 with a 64-thread group, L483-L493). It may be worth checking which shaders reach the cross-wave lowering there before ruling it out for the device-loss reports.