xshader: lower inline BVH64 ray-query walks to native ray queries #425
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/425"
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?
Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-28T23:18:46Z.
Summary
The compiler turns an HLSL RayQuery with one Proceed() and no candidate code into a loop around
image_bvh64_intersect_ray: a shared-memory node stack, an instance-node branch that transforms the ray, and a first-hit or closest-hit triangle test. Upstream refuses these with "raw BVH node intersection requires traversal translation at N" unless the program is one of the four thatscarlett_raysrecognises by hash.hlsl/ray_query.rsrecognises the walk by its structure: the innermosts_cbranch_scc1loop around a singleimage_bvh64_intersect_raywith no other memory traffic, entered only at its top, with the scene header read through(descriptor & 0xffffff00) | 0x30before it. It reads the ray registers, tMin, the instance mask, the static facing cull, and the committed outputs (tMax, barycentrics, facing, hit flag) from the loop, and replaces the loop, its root-node load and its stack seed with one query instruction. The Committed*() node loads after the walk become reads of the query's CommittedInstanceID(), PrimitiveIndex() and so on.The scene descriptor is resolved from the masking
s_and_b32to the title's acceleration structure at that table slot and read from the runtime's private scene space 900 at its index (scarlett_rays' numbering, now shared), whichruntime/d3d12already binds from the title's table or root SRV. The lowering runs afterscarlett_raysand the radiance probes, so their programs keep their own path.Over 36,644 recorded ProjectScarlett 1.0.2.1 requests main refused 21 with "raw BVH node intersection requires traversal translation"; 11 now translate (every program whose walks are all pure BVH64 queries), 11 compile with DXC and pass DXV. All other requests translate to byte-identical HLSL. BVH32 walks and walks with candidate code are left for later changes.
Tests:
hlsl::ray_query::tests::a_closest_hit_bvh64_walk_becomes_one_native_query(fails on main with the refusal above),a_walk_whose_scene_is_not_an_acceleration_structure_is_refused,a_walk_that_reads_other_memory_is_left_alone,committed_accessors_after_the_walk_read_the_query,instance_masks_and_cull_modes_are_read_from_the_walk.Tested
Run the checks relevant to this change.
No Lanes scenario for the new walk. Lanes has no RayQuery program with an inline BVH64 node loop.
bvh64-querytranslates that walk and comparesCommittedRayTwith one front-facing triangle. The full check still ran the Lanes suites on both cards.GPU, driver and backend: NVIDIA GeForce RTX 2070 SUPER (10de:1e84), driver 620.73.04; AMD Ryzen 7 9800X3D (RADV RAPHAEL_MENDOCINO, 1002:13c0); GE-Proton11-14 for both, under
gamescope --backend headlesswithENABLE_GAMESCOPE_WSI=0.Commands run and their results. The Proton build is GE-Proton11-14 and the prefix is
upstream-pr-checks.--windows-dxcpoints at Microsoft's x64dxcompiler.dllanddxil.dll.Present was inside that full check (private rootful Xwayland,
ENABLE_GAMESCOPE_WSI=0): guest-present, guest-present-rgb10, guest-present-planes, the four 4k cases, on both adapters. The named Lanes suites in the shader-compiler row passed on both cards:lanes-shader-cache,lanes-raster-tables,lanes-compute-root,lanes-compute-root-recovery, andlanes-bindless-compute. The shader translator GPU check passed on both. Results are inbuild/check/results.jsonon the machine that ran them.The new behaviour is covered by a translator GPU check. Same headless gamescope wrapper, Proton GE-Proton11-14, prefix
upstream-pr-checks.--compiler-diris the directory of Microsoft's x64dxcompiler.dllanddxil.dll.--dxcis the native dxc executable, with dxv beside it.PASS on NVIDIA (10de:1e84). Hit bits
0000803f(t = 1), 16 words.PASS on AMD (1002:13c0). Same hit, 16 words.
AI use: Claude Code ported the change and wrote the tests. The headless checks above were already recorded on both GPUs. This session added the BVH64 GPU check, ran it on both GPUs, and updated the branch.