Ray tracing: compacted structure size is read back before the builder writes it (race), copies use a stale size #689

Closed
opened 2026-11-28 03:37:40 +00:00 by github-bot · 4 comments
Owner

@⁠Machad3x on GitHub · 2026-11-28 03:35 UTC · original

Setup: Windows 11, RTX 3080 Ti 12 GB, Ryzen 7 5700X, 32 GB RAM, Series X profile, title ray tracing on (VICTORY_BVH_BUILDER=1), 240 s runs from the prison cell scene.

What happens
The title asks for a structure's compacted size through the batched build call's postbuild info. On the console that size is ready at the call. Here the emulated builder writes it later, on the card. The title then reads the old value and makes its compacted copy with a stale size.

Fix we run
The batched-build and prebuild calls are wrapped. Each compacted-size slot gets the builder's own maximum size (ResultDataMaxSizeInBytes, remembered per input shape) before and after the real call. The builder's later store is kept off those slots in put_changed.

  • Switch: VICTORY_BVH_SIZE_ANSWER (on; =0 turns it off).
  • Element layout found: 80 bytes per element, postbuild count at +48, postbuild descs at +56. Each postbuild desc is 16 bytes, and kind 0 is the compacted size.

Result
Average of the last 120 s: 66.8 ms/frame against 75.2 before, and the card went from 19.4 to 6.1 ms. This was in one batch with three smaller changes. No draws dropped, picture unchanged. Commit e98abea5 on Machad3x/VIctory-nvidia branch tn1-base.

Known risk
An answered slot stays protected until the title asks for another kind of postbuild info there. If the title reuses that memory for other card-written data, those 8 bytes would keep the old value.

**@⁠Machad3x** on GitHub · 2026-11-28 03:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689) **Setup:** Windows 11, RTX 3080 Ti 12 GB, Ryzen 7 5700X, 32 GB RAM, Series X profile, title ray tracing on (VICTORY_BVH_BUILDER=1), 240 s runs from the prison cell scene. **What happens** The title asks for a structure's compacted size through the batched build call's postbuild info. On the console that size is ready at the call. Here the emulated builder writes it later, on the card. The title then reads the old value and makes its compacted copy with a stale size. **Fix we run** The batched-build and prebuild calls are wrapped. Each compacted-size slot gets the builder's own maximum size (`ResultDataMaxSizeInBytes`, remembered per input shape) before and after the real call. The builder's later store is kept off those slots in `put_changed`. - Switch: `VICTORY_BVH_SIZE_ANSWER` (on; `=0` turns it off). - Element layout found: 80 bytes per element, postbuild count at +48, postbuild descs at +56. Each postbuild desc is 16 bytes, and kind 0 is the compacted size. **Result** Average of the last 120 s: 66.8 ms/frame against 75.2 before, and the card went from 19.4 to 6.1 ms. This was in one batch with three smaller changes. No draws dropped, picture unchanged. Commit e98abea5 on Machad3x/VIctory-nvidia branch `tn1-base`. **Known risk** An answered slot stays protected until the title asks for another kind of postbuild info there. If the title reuses that memory for other card-written data, those 8 bytes would keep the old value.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 03:37:40 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 03:35 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-28 03:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233201430) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠Machad3x on GitHub · 2026-11-28 03:37 UTC · original

GPU: RTX 3080 Ti 12 GB, driver 621.40. Windows 11 (build 26300). Built from source, diag profile. Not a crash: the session stays alive for the whole 240 s run, so there is no crashes.log for it. The full play logs contain local paths, so these are the relevant lines with paths removed. More lines on request.

INFO victory_gpu::dxr: dxr: the builder's method is watched symbol="?BuildRaytracingAccelerationStructureBatched2X@XboxBvhBuilder@@..."
INFO victory_gpu::dxr: dxr: the builder's method is watched symbol="?GetRaytracingAccelerationStructurePrebuildInfo@XboxBvhBuilder@@..."
INFO victory_gpu::dxr: dxr builder prebuild (result, scratch, update scratch) inputs=Some(Inputs { top: false, flags: 1, count: 1, pointers: false, .. }) stream=0x0 sizes=Some([3072, 17556, 400])
INFO victory_gpu::dxr: dxr builder over 148 frames: 952 prebuild calls, 252 sizes answered
INFO victory_gpu::dxr: dxr builder over 144 frames: 908 prebuild calls, 237 sizes answered

These are from the run with the fix on. The line sizes not answered never shows up.

**@⁠Machad3x** on GitHub · 2026-11-28 03:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233232686) GPU: RTX 3080 Ti 12 GB, driver 621.40. Windows 11 (build 26300). Built from source, diag profile. Not a crash: the session stays alive for the whole 240 s run, so there is no crashes.log for it. The full play logs contain local paths, so these are the relevant lines with paths removed. More lines on request. ``` INFO victory_gpu::dxr: dxr: the builder's method is watched symbol="?BuildRaytracingAccelerationStructureBatched2X@XboxBvhBuilder@@..." INFO victory_gpu::dxr: dxr: the builder's method is watched symbol="?GetRaytracingAccelerationStructurePrebuildInfo@XboxBvhBuilder@@..." INFO victory_gpu::dxr: dxr builder prebuild (result, scratch, update scratch) inputs=Some(Inputs { top: false, flags: 1, count: 1, pointers: false, .. }) stream=0x0 sizes=Some([3072, 17556, 400]) INFO victory_gpu::dxr: dxr builder over 148 frames: 952 prebuild calls, 252 sizes answered INFO victory_gpu::dxr: dxr builder over 144 frames: 908 prebuild calls, 237 sizes answered ``` These are from the run with the fix on. The line `sizes not answered` never shows up.
Author
Owner

@⁠tharun-37 on GitHub · 2026-11-28 04:06 UTC · original

claiming: #689 — I’ll fix the structure-builder compacted-size answer with a focused switch and tests, then open a PR.

AI-assisted (OpenCode).

**@⁠tharun-37** on GitHub · 2026-11-28 04:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233705632) claiming: #689 — I’ll fix the structure-builder compacted-size answer with a focused switch and tests, then open a PR. AI-assisted (OpenCode).
Author
Owner

@⁠tharun-37 on GitHub · 2026-11-28 04:19 UTC · original

done: claim 7233705632 -> #718

AI-assisted (OpenCode).

**@⁠tharun-37** on GitHub · 2026-11-28 04:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233930035) done: claim 7233705632 -> #718 AI-assisted (OpenCode).
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#689
No description provided.