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:35:33 +00:00 by Machad3x · 4 comments
Machad3x commented 2026-11-28 03:35:33 +00:00 (Migrated from github.com)
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Machad3x on 2026-11-28T03:35:33Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:6658626258 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689). Originally posted by [Machad3x](https://github.com/Machad3x) on 2026-11-28T03:35:33Z. --- **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-actions[bot] commented 2026-11-28 03:35:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-11-28T03:35:42Z.


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)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233201430 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233201430). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T03:35:42Z. --- 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)
Machad3x commented 2026-11-28 03:37:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Machad3x on 2026-11-28T03:37:58Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233232686 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233232686). Originally posted by [Machad3x](https://github.com/Machad3x) on 2026-11-28T03:37:58Z. --- 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.
tharun-37 commented 2026-11-28 04:06:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tharun-37 on 2026-11-28T04:06:51Z.


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

AI-assisted (OpenCode).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233705632 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233705632). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-28T04:06:51Z. --- 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 commented 2026-11-28 04:19:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tharun-37 on 2026-11-28T04:19:43Z.


done: claim 7233705632 -> #718

AI-assisted (OpenCode).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233930035 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/689#issuecomment-7233930035). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-28T04:19:43Z. --- done: claim 7233705632 -> #718 AI-assisted (OpenCode).
Sign in to join this conversation.
No labels
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.

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