perf(rt): zero-waterfall wave-uniform SRV BVH walker and single-lookup Box32 #287
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/287"
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 TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T13:40:13Z.
Summary
Eliminates redundant directory lookups, descriptor waterfalls, and uncached raw UAV reads in by-address ray-tracing BVH walkers while keeping builders and storing shaders on coherent raw UAVs:
Box32fast path (crates/victory-shader/src/emit/intersect.rs)bvh_memory(low + 64)lookup inbvh_second_half()behind(low & 0xFFFF) >= 0xFFC0. Becausebvh_address()is always 64-byte aligned, on the1,023 / 1,024(99.902%) same-page path all 28Box32dwords (112bytes) lie in the same 64 KiB page and view slot and issue under one descriptor handle and one wave-uniform check (at most 1 divergent waterfall instead of 2).bvh_memory()lookup inside the active-lane (begin_guarded) and valid-kind (is_box | is_triangle) guard so masked-out and kind6/7lanes never touchSLOT_MEMORYorSLOT_FAULTS.intersect.rs,bvh.rs,lib.rs)waveReadLaneFirst.i32+icmp eq+waveAllTrueinbvh_with_handle()on non-PS stages so coherent compute waves take a uniformcreateHandleFromHeap(nonuniform = false, zeroNonUniformResourceIndexwaterfall), joining only plaini32PHIs (zero%dx.types.HandlePHIs). Pixel shaders (StageIo::Ps) fall back directly toNonUniformResourceIndexfor helper-lane safety.tvia DXILFMad(opcode 46), keeping box slabs(b - origin) * invand watertight triangle cross products unfused to preserve axis-aligned NaN safety, Sterbenz precision far from the origin, and shared-edge antisymmetry.TRANSLATOR_VERSIONfrom9to10(rebased ontomain7728185).lower.rs,shader.rs,mod.rs,memory.rs,draw.rs,host.rs,host/place.rs)ByteAddressBufferSRV run (USER_MEMORY_SRV_BASE = 0x107, DXIL properties(11, 0)) alongside the raw UAV run (2 * (COPIES + 1)dynamic slots per heap) for read-only non-storing shaders (!store && !stores_by_address); builders and storing shaders continue using raw UAVs (11 | 0x1000 | coherent).HostList::note_memory_access, emitting a global cache-coherency barrier (place::wait_for_all) on both RAW (UAV -> SRV) and WAR (SRV -> UAV) transitions inside a command list with zero barriers on pure walker or pure non-RT recordings.intersect_tests.rs,memory.rs,host/rtbench.rs)0x0000/0xFF80) vs cross-page (0xFFC0)Box32nodes, unmapped fault pages and masked-out lanes, coherent/divergent SRV vs UAV waves, separate uniform-CS vs helper-lane PS fallback coverage, and intra-listUAV -> SRV -> UAVcoherency on aCOMMONbuffer under D3D12 Debug.ID3D12QueryHeapSM 6.6 (cs_6_6)rtbench(--ignored) comparing the baseline 2-lookupNonUniformResourceIndexUAV path against the 1-lookup wave-uniform SRV path with bit-exact parity.GPU Benchmark (
host::rtbench,--release, RTX 4070 SUPER)ID3D12QueryHeapmedian of 5 runs,3,686,400rays x48Box32nodes/ray over a full 16 MiB (MEMORY_PAGES) directory, with bit-exact output parity asserted across intra-page and cross-page (0xFFC0) nodes:17,342.5 us(17.34 ms)14,416.9 us(14.42 ms)-2,925.6 us(-16.9%)1.20x37,461.0 us(37.46 ms)28,140.5 us(28.14 ms)-9,320.5 us(-24.9%)1.33x59,565.1 us(59.57 ms)34,917.4 us(34.92 ms)-24,647.7 us(-41.4%)1.71x139,657.2 us(139.66 ms)103,348.2 us(103.35 ms)-36,309.0 us(-26.0%)1.35xVerification
cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings(default &--features diagnostics): 0 warningscargo run -p xtask -- policy --staged&cargo test -p xtask: 11/11 passed, policy cleanvictory-shader(VICTORY_D3D12_DEBUG=1,dxil.dllvalidation):bvh16/16,intersect_tests11/11 HW & 11/11 WARPvictory-gpu(VICTORY_D3D12_DEBUG=1,0ID3D12InfoQueueerrors):memory::tests3/3 HW (default &diagnostics) & 3/3 WARP (incl.intra_list_uav_srv_uav_coherency_on_common_buffer)Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T13:43:32Z.
@Vladimir-Human The cross-page Box32 case and masked lanes matter here. Keep the uniform compute path and pixel helper-lane fallback separately covered. Use the same ray results and the right translator cache key before measuring the runtime benefit.
Imported from TaynanGT/Vice-Tay. Originally posted by Vladimir-Human on 2026-11-27T13:52:06Z.
Rebased cleanly onto
main(7728185, clean merge-tree against latestmain) and updatedTRANSLATOR_VERSIONfrom9 -> 10incrates/victory-shader/src/lib.rs(commitb79d9891).Coverage addressing each review point (all verified on both HW RTX 4070 SUPER and WARP under
VICTORY_D3D12_DEBUG=1withdxil.dllvalidation and bit-exact ray-result parity againstbvh::intersect_fusedon HW /bvh::intersecton WARP):Box32(0xFFC0) & masked-out lanes:emit::intersect_tests::box32_same_page_and_cross_page_directory_on_the_cardruns a realSLOT_MEMORY+SLOT_FAULTSdirectory on HW and WARP testing intra-page0x0000/0xFF80(with an unmapped successor page proving no spurious second lookup/fault), cross-page0xFFC0spanning two distinct copies (with poison bytes immediately after page 0), cross-page0xFFC0with an unmapped second page (children 0..1 hit, 2..3 masked toNONE, only missing page faulted), and masked-out lanes pointing at an unmapped page (output untouched, zero faults recorded).emit::intersect_tests::wave_uniform_and_divergent_srv_vs_uav_on_the_cardexercises both coherent (uniformWaveReadLaneFirst+WaveAllTruepath) and divergent (NonUniformResourceIndexfallback) compute waves across read-only SRV (USER_MEMORY_SRV_BASE) and UAV (USER_MEMORY_BASE) modes on HW and WARP with bit-exact parity.emit::intersect_tests::pixel_shader_bvh_memory_skips_wave_ops_for_helper_lane_safetyverifies the identicalStageIo::Csprogram emitswave_ops == truewhileStageIo::Psskips wave ops (wave_ops == false, falling back toNonUniformResourceIndexfor helper-lane safety), passesdxil.dllvalidation, and still routes read-only walks throughUSER_MEMORY_SRV_BASE.UAV <-> SRVcoherency:memory::tests::intra_list_uav_srv_uav_coherency_on_common_bufferrunsUAV write -> RO SRV read -> UAV overwriteon the sameCOMMON-stateuav_bufferinside a singleHostListviaHostList::note_memory_accesswith0ID3D12InfoQueueerrors on both HW and WARP.Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T14:11:09Z.
@Vladimir-Human The missing second page and masked-lane tests cover the Box32 boundary I was concerned about. The compute/pixel split and the UAV/SRV coherency test cover the other two paths. Use a cache directory dedicated to
b79d989for timing. #258 and #289 also declare translator version 10.Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:13:09Z.
mainhas moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the currentmainand open a new PR; I'll review it there.Pull request closed