d3d12: make a list hold the console structure buffer it binds #644

Merged
3kynox merged 1 commit from upstream-pr/644 into main 2026-12-01 23:35:37 +00:00
3kynox commented 2026-12-01 22:53:34 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by 3kynox on 2026-12-01T22:53:34Z.


Summary

Asked for on #586: a list that binds the buffer of console-format structures by address now holds that buffer.

The buffer grows by being made again, larger, and the smaller one is given back once the GPU is 64 presents past it. A list recorded before a growth and run later than that would read a buffer already released, the use-after-free class of #603. console_scenes now puts the buffer among the resources its list keeps until it is reset. It takes the buffer and its address together under the buffer's lock, in both paths: the walks that declare scene offsets and those given the buffer alone. A walk whose list has no room to hold it keeps its empty buffer.

The 64-present rest stays, as a second guard.

Tested

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: AMD has not run it.

No Lanes scenario and no unit test. Holding the buffer needs a real device's buffer and a recorded list: Lanes has no walk that reads console-format structures, and the unit tests have no hardware device. The change is 25 lines in three files.

GPU, driver and backend: RTX 4070 Ti SUPER 16 GB, 620.73.04, GE-Proton11-14, vkd3d-proton. Not run in the game: today's main stops in the title on this card with or without the switch (#625).

The Evidence: line tuxbox.py check prints last, one per card (it names the commit it tested; run it on this pull request's head):

Evidence: TuxBox check of 5f737dc90300, no uncommitted changes, no GPU checks: 12 passed, 1 failed, 0 not run

The one failure is test_stage_baseline.GuestWatch, which fails on this machine on main too.

Commands run and their results:

cargo fmt --all --check                           clean
cargo clippy ... -p tuxbox-d3d12 -- -D warnings   clean (Rust 1.98.1)
tuxbox-d3d12 unit tests under Wine                600 passed, 3 failed, 8 ignored
                                                  (the 3 are scene_publication, which need a hardware device)

Checks

CI runs the code checks. No evidence JSON changes.

<!-- greyfinch-sync:brcly/TuxBox:issue:5596108011 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/644). Originally posted by [3kynox](https://github.com/3kynox) on 2026-12-01T22:53:34Z. --- ## Summary Asked for on #586: a list that binds the buffer of console-format structures by address now holds that buffer. The buffer grows by being made again, larger, and the smaller one is given back once the GPU is 64 presents past it. A list recorded before a growth and run later than that would read a buffer already released, the use-after-free class of #603. `console_scenes` now puts the buffer among the resources its list keeps until it is reset. It takes the buffer and its address together under the buffer's lock, in both paths: the walks that declare scene offsets and those given the buffer alone. A walk whose list has no room to hold it keeps its empty buffer. The 64-present rest stays, as a second guard. ## Tested - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: AMD has not run it. No Lanes scenario and no unit test. Holding the buffer needs a real device's buffer and a recorded list: Lanes has no walk that reads console-format structures, and the unit tests have no hardware device. The change is 25 lines in three files. GPU, driver and backend: RTX 4070 Ti SUPER 16 GB, 620.73.04, GE-Proton11-14, vkd3d-proton. Not run in the game: today's main stops in the title on this card with or without the switch (#625). The `Evidence:` line `tuxbox.py check` prints last, one per card (it names the commit it tested; run it on this pull request's head): ```text Evidence: TuxBox check of 5f737dc90300, no uncommitted changes, no GPU checks: 12 passed, 1 failed, 0 not run ``` The one failure is `test_stage_baseline.GuestWatch`, which fails on this machine on main too. Commands run and their results: ```text cargo fmt --all --check clean cargo clippy ... -p tuxbox-d3d12 -- -D warnings clean (Rust 1.98.1) tuxbox-d3d12 unit tests under Wine 600 passed, 3 failed, 8 ignored (the 3 are scene_publication, which need a hardware device) ``` ## Checks CI runs the code checks. No evidence JSON changes.
copilot-pull-request-reviewer[bot] commented 2026-12-01 22:55:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by copilot-pull-request-reviewer[bot] on 2026-12-01T22:55:45Z.

Review: COMMENTED


🔵 Needs a closer look

The GPU resource-lifetime change lacks regression or runtime coverage for delayed submission across buffer growth and retirement, and required AMD hardware validation remains outstanding.

No open issues 🎉

What changed in this PR

This PR makes command lists retain the console-structure buffer they bind, preventing buffer growth and delayed execution from leaving a list referencing a released buffer.

Changes:

  • Retrieves the buffer and its GPU address together under the heap lock.
  • Retains the buffer in both binding paths, falling back to the empty buffer if retention fails.
  • Keeps the existing 64-present retirement delay as a secondary safeguard.
File Description
runtime/​d3d12/​src/​device/​console_heap.rs Returns a retained buffer reference together with its GPU address.
runtime/​d3d12/​src/​commands/​recording.rs Passes the list’s resource collection into console-scene binding.
runtime/​d3d12/​src/​commands/​compute_bindings.rs Holds bound console buffers in the list’s resource collection.

Review effort: Balanced

<!-- greyfinch-sync:brcly/TuxBox:review:6141694970 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/644#pullrequestreview-6141694970). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-12-01T22:55:45Z. **Review:** COMMENTED --- <!-- ccr-overview-v2 --> ### 🔵 Needs a closer look The GPU resource-lifetime change lacks regression or runtime coverage for delayed submission across buffer growth and retirement, and required AMD hardware validation remains outstanding. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> This PR makes command lists retain the console-structure buffer they bind, preventing buffer growth and delayed execution from leaving a list referencing a released buffer. **Changes:** - Retrieves the buffer and its GPU address together under the heap lock. - Retains the buffer in both binding paths, falling back to the empty buffer if retention fails. - Keeps the existing 64-present retirement delay as a secondary safeguard. | File | Description | | ---- | ----------- | | `runtime/​d3d12/​src/​device/​console_heap.rs` | Returns a retained buffer reference together with its GPU address. | | `runtime/​d3d12/​src/​commands/​recording.rs` | Passes the list’s resource collection into console-scene binding. | | `runtime/​d3d12/​src/​commands/​compute_bindings.rs` | Holds bound console buffers in the list’s resource collection. | </details> <sub>Review effort: Balanced</sub>
Sign in to join this conversation.
No reviewers
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
brcly/TuxBox!644
No description provided.