Repository navigation
Conversation
|
@Kalmarv a first in-world result with #3662 on the RTX 5090, and it's a big one for the picture, though we don't know yet which part of it does it. What ran. Our tree (our window/alias fixes and diagnostics) + #3662 + #3656 (with #3327 under it), Picture: clearly better than anything we've had in that scene. By eye and in the saved frames:
Performance: degraded. 4.6 fps in the world (stalls 7, longest 26 s) vs 6.8–7.2 fps for the #3656 A/B arms on the same save; peak commit 40,946 MB and peak local VRAM 20,376 MB (vs 39,228 / 19,217 MB for #3327 alone), no device removal or crash. Ray tracing: our GPU counter on the node test still reads 0 node tests in this run. But with #3662 the top-level headers the walk reads moved (to We don't know yet why the picture improved. Candidates: #3662's 16-window memory-layout commits (trailing view windows for overflow MEM_GRAPHICS reservations, 4 runtime sparse windows: e.g. character vertex/skinning data that was partly uncovered before), its null-window raw UAV fix, or #3656's global signature/optimizer changes. A run of our tree + #3662 alone is next and will split those; we'll post which one it is. From here we'll focus on tools that find and pin down the remaining small artifacts (the tiles and flicker) automatically. The speed side we'd happily leave to you or a later step. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen. |
|
@Kalmarv follow-up to the result above, as promised: the solid characters come from #3662's stack, not #3656. Our tree + #3662 alone (no #3656 or #3327), same env, same scene: the main character and the people in the yard are solid and lit, the window is lit, with the same flat missing-texture tiles on the character as the combined run. One more run will split #3662's memory-layout commits (the trailing view windows for overflow MEM_GRAPHICS reservations and the 4 runtime sparse windows) from the builder hook and the null raw-UAV fix; we'll add which one it is. On the ray-tracing side, with #3662 the top-level headers on the GPU now hold built structures (one walk finds ~915,000 nodes in 787 bottom levels), and the title's ray programs do start (about 540 million lanes over a run), but they leave before their first node test: in the program we read, every lane exits at an early check on a per-pixel 32-bit classification word read from a 2D texture before any intersect instruction. We're tracing which pass writes that word next. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen. |
|
@Kalmarv @CharlyRien the split run answers it: the solid characters come from the two memory-layout commits under #3662, not the builder hook or the null raw-UAV fix. Our tree + only #3517's 16-window layout change (4 runtime sparse windows) and #3653's trailing view windows for overflow MEM_GRAPHICS reservations, same env and scene: the main character and the people in the yard are solid and lit, exactly as with the full #3662 stack (and see-through on every build without them). So #3517 + #3653 on the 16-window layout fix the "glass" characters on our RTX 5090 by themselves. The remaining flat texture tiles on the character are the same with and without the rest of #3662. In that run too, the ray programs start but do no node test. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen. |
|
Review (head a69189b, diff read, not a merge-check):
Fine (by reading): the ABI layouts ( AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Diff review (head Clean ABI verification for
AI use: Antigravity (Gemini 4 Neon) audited the full diff against |
|
A narrower answer than in my last comment: #3517 alone is enough. Our tree + only @CharlyRien's #3517 (the 16-window layout keeping 4 runtime sparse windows), without #3653 or the rest of #3662, same env and scene: the characters are solid and lit, with the same flat texture tiles. So the "glass" characters come from what #3517 changes in the 16-window layout; #3653's overflow coverage isn't needed for that (it may still matter elsewhere). Ray programs: as before, they start and do no node test. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
…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)
a69189b to
a65c38b
Compare
|
Updated in
PR body updated with fresh |
|
Follow-up runtime evidence (@Foniass): once the 16-window shader cache warmed up, a 180 s |
bmjask
left a comment
There was a problem hiding this comment.
Review of a65c38b1: 4 finding(s) (1 critical, 1 high, 2 medium), most severe first.
- Critical
crates/xcl/src/hle/bvh_builder.rs:492: The CPU view of the top-level pointer array is read with rawread_unalignedafter ashader::readablecheck, a check-then-use race on title memory that can be decommitted concurrently. (inline) - High
crates/xcl/src/hle/bvh_builder.rs:487: The ARRAY_OF_POINTERS pointer array is translated withcpu_at(inp.descs)(base address only) and then read as one contiguousn*8-byte CPU run, but when the array crosses a 64 KiB GPU-view tile the next tile's CPU page needn't follow .... (inline) - Medium
crates/xcl/src/hle/bvh_builder.rs:208:UPDATE_SCRATCHgrows without bound and outlives the structures it describes: every ALLOW_UPDATE build inserts its dest VA, and an entry is removed only when a later non-update build hits the same dest. (inline) - Medium
crates/xcl/src/hle/bvh_builder.rs:517: Not certain about this one, because it depends on the builder reading bottom-level headers during the top-level pass: top-level builds ask only for the instance descriptions, not for the bottom levels each instance's `AccelerationStructu.... (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| let ptrs = cpu as *const u64; | ||
| let mut targets: Vec<u64> = Vec::with_capacity(n.min(1024)); | ||
| for i in 0..n { | ||
| let target = ptrs.add(i).read_unaligned(); |
There was a problem hiding this comment.
Critical: The CPU view of the top-level pointer array is read with raw read_unaligned after a shader::readable check, a check-then-use race on title memory that can be decommitted concurrently. bvh_want::read_title uses view_want::cpu_run plus dstorage::read_own (a kernel copy that can't fault) for exactly this. If the title's streaming thread decommits or releases the page holding the instance pointer table between readable() and the loop, the hook takes an access violation inside an extern "system-unwind" function on the title's render thread and the process crashes. Reading through read_own would make it safe.
| push_range(out, Use::Instances, inp.descs, u64::from(inp.num_descs).saturating_mul(8)); | ||
| if n > 0 && inp.descs != 0 { | ||
| if let Some(bytes) = n.checked_mul(std::mem::size_of::<u64>()) { | ||
| let cpu = cpu_at(inp.descs); |
There was a problem hiding this comment.
High: The ARRAY_OF_POINTERS pointer array is translated with cpu_at(inp.descs) (base address only) and then read as one contiguous n*8-byte CPU run, but when the array crosses a 64 KiB GPU-view tile the next tile's CPU page needn't follow the first, which view_want::cpu_run exists to detect. For a top-level build with ~3000 instances whose 24 KB pointer array starts 8 KB before a tile boundary, with tiles mapped apart (queue page mappings or kernelx mirrors), the entries past the boundary are read from whatever follows the first CPU page. The wrong instance-desc ranges are asked for and the real ones are never mapped, so the builder reads zeros and those instances drop out of the top level. Translating per tile (or using cpu_run) would fix it.
| static REAL_PREBUILD_INFO: AtomicUsize = AtomicUsize::new(0); | ||
| /// Destination AS VA -> cached `UpdateScratchDataSizeInBytes` from an `ALLOW_UPDATE` build, | ||
| /// used when a later `PERFORM_UPDATE` prebuild query returns 0. | ||
| static UPDATE_SCRATCH: Mutex<Option<HashMap<u64, u64>>> = Mutex::new(None); |
There was a problem hiding this comment.
Medium: UPDATE_SCRATCH grows without bound and outlives the structures it describes: every ALLOW_UPDATE build inserts its dest VA, and an entry is removed only when a later non-update build hits the same dest. Besides growing for the whole session (the PR's own log shows ~4000 builds every 2 s, and streaming titles use new VAs), when a dest VA is freed and reused for a different, larger ALLOW_UPDATE structure whose PERFORM_UPDATE prebuild returns 0, the stale smaller size is used and the update scratch past it is never asked for. Querying prebuild with flags & !BUILD_FLAG_PERFORM_UPDATE (the DXR-legal form) would give the size directly and remove the cache.
| } | ||
| } | ||
| } else { | ||
| push_range(out, Use::Instances, inp.descs, u64::from(inp.num_descs).saturating_mul(INSTANCE_DESC_BYTES)); |
There was a problem hiding this comment.
Medium: Not certain about this one, because it depends on the builder reading bottom-level headers during the top-level pass: top-level builds ask only for the instance descriptions, not for the bottom levels each instance's AccelerationStructure field names. If a bottom level was built frames earlier and its view tiles have since been dropped or not asked again this generation, the top-level build reads zero bounds or headers for that instance, which ends up degenerate or missing. Asking for each referenced bottom level's range (at least its header) would cover it.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
Outer
XboxBvhBuilder.dllHLE hooks that ask for every acceleration-structure build and rehydrate range whole in GPU views (d3d12x::view_want::Path::BvhBuild), laying the hook layer needed for the opt-in DXR 1.1 shadow builder follow-up.On the 16-window GPU-view layout (
XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16),XboxBvhBuilder.dll's compute passes reach vertex, index, and transform buffers through addresses inside uploaded geometry descriptions, and read/write destination, source, and scratch through root views thatview_wantonly asks for 64 KiB for. WrappingBuildRaytracingAccelerationStructureBatched2XandRehydrateRaytracingAccelerationStructureBatched2Xon import resolution andGetProcAddress(named or by ordinal) lets XCL ask for every range whole before forwarding. On the default 4-window layout nothing is wrapped.Part of #1751. Standalone on
main(5eaadb54c; no stacked PRs underneath). Note: the solid-character improvement observed earlier in this thread was bisected by @KDenKC to #3517's 16-window layout change, not this PR.(Why this is 1139 lines and not split further: ~585 lines are the
XboxBvhBuilder.dllABI definitions, range calculation, andextern "system-unwind"hooks, and ~554 lines are their unit tests, kept together becauseCONTRIBUTING.mdrequires new code to ship with its tests.)Related: #2184-#2189 (specifically #2186) and #3521. Concrete differences: this PR hooks
XboxBvhBuilder.dll(BuildBatched2X+RehydrateBatched2X) on both import resolution andGetProcAddresswithout modifying the DLL or title shaders, asks for whole ranges in 16-window GPU views viaview_want::Path::BvhBuild(sized by the DLL's ownGetRaytracingAccelerationStructurePrebuildInfo), and usesextern "system-unwind"on all hook trampolines. ThePERFORM_UPDATEscratch-size cache (UPDATE_SCRATCH) duplicates#3521's inner-hookSIZESlogic on purpose because#3521is not onmain; the two can be unified once#3521lands.What is in it
crates/xcl/src/hle/bvh_builder.rs:XboxBvhBuilder.dllABI structs (BuildInputs,BuildDesc,BatchedBuildDesc2,GeometryDesc,PrebuildInfo,PostbuildInfoDesc,StreamDesc), safe geometry/postbuild readers, whole-range calculation (ranges_of_build), andextern "system-unwind"passthrough hooks forBuildBatched2XandRehydrateBatched2X, gated on active GPU view windows.GetRaytracingAccelerationStructurePrebuildInfodirectly from the mappedXboxBvhBuilder.dllmodule when wrapping any export (named or by ordinal), instead of waiting for the title to import it.UpdateScratchDataSizeInBytesonALLOW_UPDATEbuilds so a laterPERFORM_UPDATEwhose prebuild query returns0reuses the cached size (in-place or out-of-place), falling back toscratch_size.max(update_scratch_size).max(SCRATCH_GUESS)instead of dropping the scratch range.ARRAY_OF_POINTERSTLAS builds, translates the GPU-VA pointer array vialist_x::cpu_at, reads it undershader::readable, and sorts/coalesces overlapping or contiguous 64-byteD3D12_RAYTRACING_INSTANCE_DESCtarget ranges before callingview_want::want(to avoid onewantcall per instance on large TLAS builds).R16_TYPELESS(53) index sizing, whole-range bottom-level andPERFORM_UPDATEscratch caching/fallback,ARRAY_OF_POINTERSGPU-VA translation + target coalescing, fallback estimation, and build/rehydrate hook forwarding.crates/xcl/src/hle/d3d12x/view_want.rs: addPath::BvhBuild("acceleration-structure builds",PATHS = 14).crates/xcl/src/hle/mod.rs,crates/xcl/src/resolver.rs: wirehle::bvh_builder::wrapinresolve_importandget_proc_addressforxboxbvhbuilder.dll, passing the mapped module andImportName.Tested
rustc 1.99.0, DXC1.9.2609.5.cargo build --release -p xcl(commita65c38b16bb4bb8bd68c7985c73509fe03de6a37): passed, 39 warnings (0 new vsmain)..\scripts\test.ps1(commita65c38b16bb4bb8bd68c7985c73509fe03de6a37): 2985 passed, 0 failed, 52 ignored across 43 binaries (including all 11hle::bvh_builderand 5hle::d3d12x::view_wanttests); 24SKIPPEDGPU lines on this adapter (22no wave64, 2no heap windows).XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_VIEW_STATS=1, commita65c38b16):exit: 0x0,1754frames shown,0device removals,0crashes; hooks installed (XboxBvhBuilder: builds and rehydrates wrapped (asking for their ranges whole in GPU views)), 28GPU view (2 s)lines logged, 0acceleration-structure buildslines before 240 s (180 s cold run:exit: 0x0,1959frames,0removals).XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_VIEW_STATS=1, from the stacked D3D12.X: opt-in XCL_HW_RT shadow builder #3700 binary withXCL_HW_RTunset, where D3D12.X: hook XboxBvhBuilder builds and ask for every range whole in GPU views #3662's hook is the only active one):exit: 0x0,1920frames shown,0device removals,0crashes; logged 27GPU view (2 s)lines containingacceleration-structure builds, including4089 acceleration-structure builds (139392 KB new)at91.5 sand1517 acceleration-structure builds (89152 KB new)at174.9 s.Regression run
(Clean back-to-back pair; earlier
a65c38b16runs while sibling builds saturated CPU gave1462/1482/1035/1127frames — theXboxBvhBuilderhook is not installed on the default 4-window layout.)Not tested
view_windows()is false there.acceleration-structure buildsXCL_VIEW_STATSlines above were recorded on the stacked D3D12.X: opt-in XCL_HW_RT shadow builder #3700 binary withXCL_HW_RTunset (identical#3662hook path) once the 16-window shader cache was warm; the earlier 240 s run ona65c38b16itself did not reach world BVH builds before exit.CopyRaytracingAccelerationStructureis not hooked: a compacted or cloned copy whose destination is in a view window is still only asked for its first 64 KiB.XCL_SPARSE_LAZY=1).AI use
Gemini 4 Neon): rebased standalone ontomain, implemented the 3 review fixes and unit tests, ran the build, full test suite, smoke runs, and 180 s 16-window run, and drafted the PR description.Claude Opus 5.5): authored the original range-request logic and reviewed the fixes (includinglist_x::cpu_atGPU-VA translation and target coalescing) and PR description.