Repository navigation
Conversation
…GPU views Add outer XboxBvhBuilder.dll HLE hooks (BuildRaytracingAccelerationStructureBatched2X and RehydrateRaytracingAccelerationStructureBatched2X, extern "system-unwind") that ask view_want (Path::BvhBuild) for every range a build or rehydrate names whole before forwarding to the DLL. The builder's compute programs reach vertex and index buffers through addresses inside uploaded geometry descriptions and reach destination, source, and scratch through root views, which view_want only asks for 64 KiB from their base address. On the 16-window GPU-view layout, tiles past that first 64 KiB stay unmapped until requested. Asking for each item's result, source, scratch, instance descriptions, per-geometry vertices/indices/transforms/AABBs (handling R16_TYPELESS=53 as 2 bytes), and postbuild destinations sized via GetRaytracingAccelerationStructurePrebuildInfo closes that gap: - Resolve GetRaytracingAccelerationStructurePrebuildInfo directly from the mapped XboxBvhBuilder.dll module when wrapping any export (including ordinal imports) instead of waiting for the title to import it. - Cache UpdateScratchDataSizeInBytes on ALLOW_UPDATE builds so a later PERFORM_UPDATE whose prebuild query returns 0 reuses the cached size (or falls back to scratch_size.max(update_scratch_size).max(SCRATCH_GUESS)) instead of dropping the scratch range. - For ARRAY_OF_POINTERS TLAS builds, translate the GPU-VA pointer table via list_x::cpu_at, read it under shader::readable, and request coalesced 64-byte D3D12_RAYTRACING_INSTANCE_DESC target ranges alongside the pointer array. Wrapping is gated on Uma view windows existing, so default 4-window runs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Antigravity (Gemini 4 Neon)
Add the pure acceleration-structure shadow registry and DXR 1.1 triangle geometry and TLAS instance translation helpers in hle::d3d12x::hw_rt. Nothing calls this module yet; the shadow command-list builder and XboxBvhBuilder hooks follow in a stacked PR. Tracks native BLAS/TLAS entries keyed by console GPU VA, validates DXR 1.1 PERFORM_UPDATE refits against build flags and per-geometry signatures, marks referencing TLASes stale whenever a BLAS GPU VA relocates or is invalidated, canonicalizes console typeless index formats (R16_TYPELESS / R32_TYPELESS) to PC typed uint formats, and gates opt-in XCL_HW_RT=1 against XCL_RAYTRACING=0. Part of xcl-dev#1751. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Antigravity (Gemini 4 Neon)
Wire the opt-in native D3D12 DXR 1.1 BLAS/TLAS shadow builder (XCL_HW_RT=1, off by default) into XboxBvhBuilder.dll's BuildBatched2X, RehydrateBatched2X, and CopyRaytracingAccelerationStructure hooks. Builds native DXR 1.1 bottom-level and top-level acceleration structures alongside the console compute path (leaving console output untouched for software fallback): - Translates triangle BLAS geometry (including R16_TYPELESS/R32_TYPELESS canonicalization) and rewrites TLAS instance descriptors to native BLAS GPU VAs (masking unresolved instances cleanly). - Builds rehydrated BLASes natively when their geometry has at least as many triangles as the archive header's primitive count, and clones native structures on clone/compact copies. - Invalidates stale entries on every skipped rebuild or fallback, marks referencing TLASes stale when a BLAS GPU VA relocates or is removed, and retires replaced AS buffers past RETIRE_FRAMES presents into late_release::hold_owned_resource so active GPU queues finish before drop. - Respects XCL_RAYTRACING=0 dynamically on every hook and logs a periodic summary line in host.rs when active. Part of xcl-dev#1751. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Antigravity (Gemini 4 Neon)
Add direct-DXIL inline ray tracing support on Shader without changing any runtime path yet: - RaytracingAccelerationStructure SRVs (static t# binding and ResourceDescriptorHeap indexing requiring SM 6.6+, kind 16, U32 element type, PSV0 SrvRaw). - allocateRayQuery (requiring SM 6.5+), rayQuery_TraceRayInline, Proceed, Abort, CommitNonOpaqueTriangleHit, and StateScalar / StateVector queries (committed and candidate status, type, t, barycentrics, instance index / ID, geometry, primitive, front face). - Opcodes, overloads, and attributes match DXC 1.9 (state queries are readonly so CSE never merges them across Proceed); Feature::RaytracingTier1_1 sets metadata bit 25 and container bit 0x100000. - Helpers Shader::trace_any_hit (opaque first-hit shadow query with SKIP_PROCEDURAL_PRIMITIVES so procedural AABBs cannot stall the single-Proceed search) and Shader::trace_translucent (FORCE_NON_OPAQUE Proceed loop committing back faces and tracking the nearest front face). - DXIL 1.9 validator, SM 6.5/6.6 guard tests, and WARP DXR 1.1 execution tests comparing closest hit (t0 and descriptor heap, 48 single-triangle BLAS instances so the comparison does not depend on WARP's multi-triangle BLAS builder), non-zero primitive index on a 2-triangle BLAS, first hit, procedural-AABB skip in trace_any_hit, translucent back-face commit, FRONT_COUNTERCLOCKWISE, negative-determinant mirrored transform (object-space winding per DXR spec), front1/back2, and fronts-only against a CPU walk / f64 Moller-Trumbore reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Antigravity (Gemini 4 Neon)
Add the GPU-visible native top-level table (hw_rt_table) and Shader::native_tlas lookup so translated shaders can look up complete native DXR TLASes by console VA. Reserve 9 fixed descriptors in the shared heap (MEM_HW_RT_TABLE + 8 MEM_HW_RT_TLAS slots, shifting MEM_FIXED_END by +9). Complete native TLASes are published only after STABLE_FRAMES (4) presents in the same buffer, removed immediately when relocated/invalidated/incomplete, and freed slots are quarantined for STABLE_FRAMES presents. Empty slots retain their own TLAS descriptor index (MEM_HW_RT_TLAS + k) and updates write only changed slots with write-combining fences so concurrent GPU readers never observe torn entries or descriptor index 0. Also add hw_rt::traverse_enabled() (gating XCL_HW_RT_TRAVERSE on hw_rt::enabled() dynamically so XCL_RAYTRACING=0 is respected), wire hw_rt_table::sync() from hw_rt build/rehydrate/copy/summary paths, add direct-DXIL RayQuery copy verification to warp_rehydrated_and_copied_blas_are_native, and extend ray_query WARP tests with swap_kernel lookup + trace cases. Assisted-by: Claude Code (Claude Opus 5.5) Assisted-by: Antigravity (Gemini 4 Neon)
|
@Kalmarv a heads-up for #3705 from reading the retail title's main ray program (not a run yet; we'll run your stack as soon as our rig is free):
Would the swap be possible before compact planning (or inside it, per region)? Happy to test whatever you try. Your loyal testing minion, rig permitting. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen. |
|
Thanks for the heads-up @KDenKC — confirmed on the code: Yes, wiring the swap into the compact path is doable cleanly in a follow-up PR: One caveat to check when testing Keeping |
|
@Kalmarv a correction to my note above, sorry: I counted the whole listing (~11,700 lines), not what For the matcher, from the disassembly: the loop is AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen. |
|
Thanks for the correction and the live-out breakdown @KDenKC! Good news that From those live-outs ( |
…RSE) Add gpurt.rs recognition and direct-DXIL lowering for opt-in XCL_HW_RT_TRAVERSE=1 (requiring XCL_HW_RT=1 and XCL_RAYTRACING not disabled). Recognises single-entry/single-exit GPURT visibility loops and translucent closest-hit loops (folded FORCE_NON_OPAQUE without culling, proving front-face 0xFE polarity directly on the lane mask driving V_CNDMASK_B32 for the nearest-front register). At each loop's entry, checks the native top-level table (MEM_HW_RT_TABLE); when every active lane finds a native TLAS, valid lanes (ordered tmax >= tmin) trace with Shader::trace_any_hit / Shader::trace_translucent and jump past the loop, while waves with any missing TLAS fall back to the software walk. Cache keying is scoped strictly to Stage::Compute via a `_hwrt3` filename suffix in `translated::file_for` (and `direct_output_identity` for rerouted enormous compute shaders) rather than modifying the global `translated::identity_from_source()` directory hash, so enabling `XCL_HW_RT_TRAVERSE=1` reuses all existing graphics (`VS`/`PS`/`MS`) translated caches instead of forcing a full graphics rebuild. `XCL_HW_RT_TRAVERSE` is also listed in `shaders::semantic_pipeline_setting` for warm pipeline preparation. Includes synthetic RDNA2 unit tests covering visibility and translucent loop recognition, S3 front-face polarity acceptance/rejection, S4 tmax >= tmin guarding, DXC 1.9 validation, compute-only cache key isolation, and warm pipeline setting keying. Assisted-by: Claude Code (Claude Opus 5.5) Assisted-by: Antigravity (Gemini 4 Neon)
112374d to
1f488ac
Compare
Add direct-DXIL GPURT inline traversal loop recognition and native
RayQuerylowering (XCL_HW_RT_TRAVERSE=1, requiringXCL_HW_RT=1andXCL_RAYTRACINGnot disabled). Off by default; compute disk translation cache entries are isolated via a compute-only_hwrt3filename suffix intranslated::file_forso enablingXCL_HW_RT_TRAVERSE=1reuses all existing graphics (VS/PS/MS) translated caches instead of busting the global cache directory.Part of #1751. Stacked on #3704 (only commit
1f488ac7cbelongs here).Related: #2184, #2185, #2186, #2187, #2188, #2189.
Why this PR is over 800 changed lines: The diff is +1171 / -6 lines across 5 files, consisting of ~870 production lines (
gpurt.rsCFG liveness, visibility and translucent loop recognizers, andLw::traversal_swap/Lw::translucent_swaplowering;kernel.rsloop-entry hook;pso.rscompute-scoped_hwrt3cache discriminator;shaders.rssemantic pipeline setting) and ~301 lines of synthetic RDNA2 and cache-isolation unit tests. The native top-level table,Shader::native_tlas, and shared-heap descriptor reservation were already split into #3704; splitting the loop recognizers from theLwlowering or their validation tests would either add unused code or land unverified DXIL emission.What is in it
crates/xcl/src/gpu/dxil/gpurt.rs&mod.rs:traverse_enabled()delegating directly tohw_rt::traverse_enabled(), plus test helperwith_traverse_for_tests(mutex + drop-guard reset).image_bvh64_intersect_raysites.visibility_of: recognizes opaque first-hit visibility loops (single live-out hit VGPR read only via zero comparisons after the loop, no side-effecting memory ops and no non-nodeBUFFER_/TBUFFER_/S_LOAD/S_BUFFER_LOAD/SCRATCH_/FLAT_or non-BVHIMAGE_loads, known ray and top-level registers, single instance-mask test).translucent_of: recognizes translucent closest-hit loops with foldedFORCE_NON_OPAQUEray flags (no culling), proving front-face0xFEhit-kind polarity directly on the lane mask SGPR driving everyV_CNDMASK_B32write tofront(V_CMP_EQ_U32 0xFEwith(front, min)orV_CMP_NE_U32 0xFEwith(min, front)in the same block), plus committed-pointer, optional iteration-cap, and post-loop LDS checks.Lw::traversal_swap/Lw::translucent_swap: looks up each active lane's console TLAS VA inMEM_HW_RT_TABLE; if any active lane misses, the whole wave falls back to the software BVH walk; otherwise each active lane with an ordered valid ray interval (tmax >= tmin,Pred::FOGe) traces viaShader::trace_any_hitorShader::trace_translucentand jumps past the loop (zeroingcappedfor all active lanes).BUFFER_LOAD_DWORDandIMAGE_SAMPLE), translucent S3 polarity acceptance and rejection (inverted polarity and unrelated0xFEmask), S4fcmp oge floatguard emission, and DXC 1.9 validation.crates/xcl/src/gpu/dxil/kernel.rs: wiregpurt::swapsinto non-compact compute/kernel translation, routing each swapped loop's entry edge throughlw.swap(...).crates/xcl/src/gpu/recomp/pso.rs: scope theXCL_HW_RT_TRAVERSE=1translation disk cache discriminator strictly toStage::Computevia a_hwrt3filename suffix intranslated::file_for/file_for_with(leaving globaltranslated::identity_from_source()unchanged so graphics shadersVS/PS/MSkeep their existing cache directory and files;direct_output_identitykeepsxcl-hw-rt-traverse-3for rerouted enormous compute shaders, andhw_rt::traverse_enabled()is process-constantOnceLockso in-RAMShaderCachecannot mix entries). Addshw_rt_traverse_cache_key_is_compute_onlycoveringidentity_from_source,file_for_with/file_foracross graphics and compute stages, and disk round-trip non-collision.crates/xcl/src/shaders.rs: addXCL_HW_RT_TRAVERSEtosemantic_pipeline_setting(and assert it inwarm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches) so warm pipeline preparation tracks the compute setting without altering globaltranslation_cache_identity.Tested
Hardware: Windows 11 x64 (10.0.26200), NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074 / 610.74, 15995 MiB VRAM, DXR Tier 1.1), AMD Ryzen 9 9950X,
rustc 1.99.0, DXC1.9.2609.5(XCL_DXC_DIR).cargo build --release -p xcl(commit1f488ac7c3ce247b23a6a0b9a54092f105aee9ab): succeeded, 39 warnings (0 new vsmain)..\scripts\test.ps1(commit1f488ac7c3ce247b23a6a0b9a54092f105aee9ab): 3004 passed, 0 failed, 52 ignored across 43 test suites; 24 GPU tests skipped on this adapter (22no wave64, 2no heap windows), includinghw_rt_traverse_cache_key_is_compute_only,warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches, and bothgpu::dxil::gpurtsynthetic tests (visibility_loop_recognized_and_translates_with_s4_guardandtranslucent_loop_polarity_s3_and_s4_guard).XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16run on previous revision112374d1907e1d234a2cea4a9edd1eb1a83ca540(same traversal lowering, before the compute-scoped cache fix;XCL_PREPARE=0,XCL_NETWORK=0,XCL_PSO_EVICT_FRAMES=600, automated title-screen advance):exit: 0x0,1971frames shown,0device removals,0crashes:D3D12.X: XCL_HW_RT_TRAVERSE: native top-level table at descriptor 22 (8 entries)[SHADER] direct DXIL: 1 ray traversal loop(s) swapped for a native RayQuery when the top level has oneD3D12.X: XCL_HW_RT_TRAVERSE: native top-level table: 3 published, 0 taken outHW RT shadow (XCL_HW_RT): live 2620 BLAS / 5 TLAS / 134 rehydrated (240 MiB AS, 123 MiB pools); built 1331 BLAS (0 updates, 1327 skipped), 150 TLAS (80 complete, 70 hybrid, 0 skipped); insts 106502 resolved / 0 null / 2194 rehydrated-skip / 33102 missing-skip; 1764 rehydrated recorded (1618 built natively, 146 count mismatch), 159 stale invalidated, 0 copy-invalidated, 0 copied natively, 0 alloc-err, 0 budget-skipXCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1run on previous revision112374d1907e1d234a2cea4a9edd1eb1a83ca540(same settings):exit: 0x0,1947frames shown,0device removals,0crashes; 4 shaders swapped,native top-level table: 2 published, 0 taken out:HW RT shadow (XCL_HW_RT): live 2 BLAS / 5 TLAS / 225 rehydrated (1 MiB AS, 10 MiB pools); built 2 BLAS (0 updates, 13247 skipped), 536 TLAS (240 complete, 296 hybrid, 0 skipped); insts 259119 resolved / 0 null / 9506 rehydrated-skip / 236718 missing-skip; 4526 rehydrated recorded (0 built natively, 388 count mismatch), 0 stale invalidated, 0 copy-invalidated, 0 copied natively, 0 alloc-err, 0 budget-skipRegression run
Base (
main):PR (
pr/hw-rt-traverse):Not tested
XCL_HW_RT_TRAVERSE=1runs were performed on previous revision112374d19and were not re-run after scoping the disk cache key on1f488ac7c(the traversal lowering itself did not change).3on 16-window,2on default), and0device removals.GLOBAL_loads in the loop are accepted as node fetches (same astranslucent_of), so an alpha test that fetches only through global loads with no image sample or buffer/scalar load would not be caught.0xFEselect is proven. That the commit (tmax, pointer) happens only on the back-face side is not proven separately; theFORCE_NON_OPAQUEfold and the0xFEmin imply it.RayQuerytraversal.XCL_HW_RT=116-window runs ended in0x887a0006; this PR's 180 s 16-windowXCL_HW_RT_TRAVERSE=1run completed cleanly with0device removals).XCL_SAMPLE_*unset).AI use
Claude Opus 5.5): architecture, traversal loop safety audit (S3 front-face polarity proof, S4tmax >= tminguard, visibility non-node load rejection, B4 env gating, B5 synthetic test cleanup).Gemini 4 Neon): implementation, rebase ontomain, compute-scoped_hwrt3cache key fix and cache-isolation unit tests, synthetic RDNA2 unit tests, release build, full test suite, regression smoke, live 16-window and defaultXCL_HW_RT_TRAVERSE=1verification, and PR description.