bvh, d3d12: rehydrate console structures as host builds (stacked on #376) #394
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/394"
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 NickStallman on 2026-11-28T11:20:06Z.
Stacked on #376, which is stacked on #375 and #320; review those first. The last two commits are new here: a merge of
main(b426c1aa; #376 is oncf0a0824) and the rehydration.Fault. ProjectScarlett streams its bottom-level structures in the console's dehydrated form and calls
XboxBvhBuilder::RehydrateRaytracingAccelerationStructureBatched2Xon them, 16 per call and at least 256 per scene. TuxBox's builder answersE_NOTIMPL(#320 logs them), so nothing is built at those addresses and the scene's instances name console node data (#232). We said on #320 that we'd provide this.Change.
TuxBoxRehydrateAccelerationStructures, found withGetProcAddress), which records a host build of that geometry. It reuses #320's title-memory storage, #375's index decode and #376's position decode. Leonida's docs/bvh.md (3.1 and 4a) says the leaves follow the index buffer's primitive order, so the host build reports the sameGeometryIndexandPrimitiveIndex. Only the facts are used; no code is taken from it.64 * (nodes + 1)bytes from the console header, as the range a later structure must overlap to release it. Using the host's result size would release neighbours the title packs 256 bytes apart.TUXBOX_LOGthe first 64 skips are logged with their reason and HRESULT, then every power of two.read_guest_bytes, the read placed textures use, which reaches the memory the CPU wrote. That function came tomainindb70b21d, after #376's base, hence the merge.geometry (0x800701e7),ERROR_INVALID_ADDRESSfrom XMem. Alongside them the title gave R32G32_FLOAT geometriesStrideInBytes0x8008, which read as bytes runs an import into pages it never mapped. #376 now reads that stride through its low 14 bits (a474745), so this PR carries no fix of its own; its late position decode at submission keeps the stride masked, as #376's decoder takes it. Confirmed in game: decoding the 36 logged packed geometries at stride 8 put 1,124 of 1,124 vertices inside the structure header's scene bounds, while at 0x8008 every range ran into unmapped pages; with the mask the run logged 84 rehydrations and 0 skips.Effect in ProjectScarlett (RTX 5090, 620.70.10, an integration build with these commits, before the stride mask,
TUXBOX_LOG=1): by the 16th call, 205 of 256 structures were built from geometry read when the call was recorded. None were left for submission, and 51 were skipped, all for0x800701e7. Before the backing read, none had geometry. With the mask (a later run), 84 rehydrations were logged and none skipped.Test.
ray-tracing-rehydraterehydrates two console structures 256 bytes apart, in separate submissions. Their geometry is synthetic format-53 indices and quantized positions, and one structure's geometry is written only after its call. Everything is in physical pages named by an address mapped for the GPU before anything was written. A ray query through a scene of both must report the expected instance, geometry and primitive.E_NOTIMPLand the scenario fails.tests/commands/rehydrate.rs: header words, and the extents from node counts.tests/commands/packed_positions.rscovers the 14-bit stride.Tested
GPU, driver and backend:
Commands run and their results:
Checks
No evidence JSON changes.
🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-28T12:50:10Z.
I've tested this PR as it is (head
928abca, which already containsmainb426c1a) on RDNA2. Rehydration works there, and the page faults from #320 alone are gone.Setup: RX 6600 (
1002:73ff, 8 GB), Ryzen 5 5600, 32 GB RAM + 34 GB swap, Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, Microsoft DXC 1.9.2609. ProjectScarlett 1.0.2.1, offline, 3840x2160, no preload, warm shader caches. D3D12 provider sha256d811700d…ede0e9e33,XboxBvhBuilder.dllf9d957b9….tuxbox.py check --no-gpupasses.Rehydration
There were 6 calls with 74 structures, all built at record time, none skipped. Two guest-memory pools were created, and private storage peaked at 64 MiB. No
Failed to place destAccelerationStructure.Same card, three builds
All runs reach world entry: the title sets mission
0x98c85f2a, and the run ends a few frames later.mainb426c1a, 2 runsmain+ #320E_NOTIMPL)PERMISSION_FAULTS: 0x3)With #320 alone, the run had gfxhub page faults on a compute ring, as reported on #320. With this branch there are none. That fits the reading on #232 that the faults come from scenes naming structures that were never built. It's one run per build.
What still ends the run
The same gfx ring timeout as on
main, without any fault:The device was lost about 31 s after the last rehydration call, by vkd3d's timestamps. The title then stopped with exit code 3 at frame 1,743. Since this ending appears both with every BLAS dropped (
main) and with all of them built (this branch), I don't think the structures cause it.Other things in the log:
pipeline has no paged descriptor layout: its root indexes the resource heap directly(guest caller0x4e33f98, the same caller as in #232's list), and 1 skipped compute dispatch (0x248cbc1).main.I can add #373 on top next, which was part of the build that reached the opening scene on #232, and report back.