Skip to content

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

Merged
brcly merged 1 commit into
brcly:mainfrom
3kynox:pr-console-hold
Dec 1, 2026
Merged

brcly merged 1 commit into
brcly:mainfrom
3kynox:pr-console-hold

Conversation

@3kynox

@3kynox 3kynox commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

A walk is given the buffer of console-format structures by address. The buffer grows by being made again, larger, and the smaller one is given back after a rest: a list recorded before the growth and run long after it would read a buffer already released. The list now keeps the buffer among the resources it holds until it is reset.
Copilot AI balanced review requested due to automatic review settings December 1, 2026 22:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@brcly
brcly merged commit 4c74469 into brcly:main Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants