d3d12: log placed texture drops with their time on the performance counter #639

Merged
Kayotic1337 merged 1 commit from upstream-pr/639 into main 2026-12-01 23:35:47 +00:00
Kayotic1337 commented 2026-12-01 21:34:07 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-12-01T21:34:07Z.


TUXBOX_LOG_TEXTURE_DROPS=1 logs each placed texture as it is released:

placed texture dropped at 6726.490973 s: address 0x99784c000 size 0x57000 512x1024x1 format 71 mips 8 flags 0x300000

The time is in seconds on the performance counter, which is the clock vkd3d-proton's VKD3D_CONFIG=fault address history uses. A GPU read of a destroyed image can then be matched to the texture whose release unbound it. In every #603 fault I could attribute, the drop line came 10–15 µs before vkd3d's UNBIND of the same image.

This PR is optional. It doesn't fix anything. Several of us are chasing the same fault on different cards (#603). vkd3d's address history and RADV's binding history name the Vulkan image and its VA range, not the title's texture. With this log, everyone can tie a fault to a texture (its guest address, size and format) the same way. @NickStallman already carried an earlier copy of this commit in his integration build.

Change

  • diagnostics::placed_texture_dropped, called from Texture::drop. It is off by default; when off, each drop costs one cached flag check.
  • The logic lives in diagnostics.rs because device/placement.rs was at 1,199 lines; the call adds one line there, to 1,200.
  • A row in docs/ENVIRONMENT.md.

Tests

  • python tuxbox.py check --no-gpu: 13 passed, 0 failed.
  • GPU checks for runtime/d3d12/ (python tuxbox.py check --changed) on RX 9070 XT (1002:7550), Mesa 26.3.1 RADV, GE-Proton11-15:
    Evidence: TuxBox check of 76c386aa9b8a, no uncommitted changes, GPU default adapter: 15 passed, 1 failed, 0 not run
    
    The one failure is lanes-selftest-texture-publication. It fails the same way on main (2a850114) without this change, on the same card; that's #625. All other Lanes scenarios and the D3D12 regression controls pass.
  • No NVIDIA card here.
  • No Lanes scenario: the change only adds a log line behind an off-by-default variable, and changes no behaviour a scenario could fail on.

Game

ProjectScarlett on the RX 9070 XT: an earlier copy of this commit, identical except that the code sat in placement.rs and any value of the variable turned it on, was on in all seven of my runs today, six of which I reported on #634 and #603. Those runs logged up to 75,823 drops each. The one use-after-free among them was matched to its texture this way (run 1 in my comment on #603).

I also ran this exact commit in the game, cherry-picked onto that earlier build (main 712fb960 + #630) rather than this PR's base. The PR's base changes the translator, so a run on it would have meant recompiling every shader first, and the commit is the same on both. With TUXBOX_LOG_TEXTURE_DROPS=1 TUXBOX_LAZY_PUBLICATION=0 (#634), it ran 400 s into the world, which I ended myself. It logged 50,863 drop lines, all in the format above. No GPU fault occurred in that run.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5594961195 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/639). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-12-01T21:34:07Z. --- `TUXBOX_LOG_TEXTURE_DROPS=1` logs each placed texture as it is released: ```text placed texture dropped at 6726.490973 s: address 0x99784c000 size 0x57000 512x1024x1 format 71 mips 8 flags 0x300000 ``` The time is in seconds on the performance counter, which is the clock vkd3d-proton's `VKD3D_CONFIG=fault` address history uses. A GPU read of a destroyed image can then be matched to the texture whose release unbound it. In every #603 fault I could attribute, the drop line came 10–15 µs before vkd3d's `UNBIND` of the same image. **This PR is optional.** It doesn't fix anything. Several of us are chasing the same fault on different cards (#603). vkd3d's address history and RADV's binding history name the Vulkan image and its VA range, not the title's texture. With this log, everyone can tie a fault to a texture (its guest address, size and format) the same way. @NickStallman already carried an earlier copy of this commit in his integration build. ## Change - `diagnostics::placed_texture_dropped`, called from `Texture::drop`. It is off by default; when off, each drop costs one cached flag check. - The logic lives in `diagnostics.rs` because `device/placement.rs` was at 1,199 lines; the call adds one line there, to 1,200. - A row in `docs/ENVIRONMENT.md`. ## Tests - `python tuxbox.py check --no-gpu`: 13 passed, 0 failed. - GPU checks for `runtime/d3d12/` (`python tuxbox.py check --changed`) on RX 9070 XT (`1002:7550`), Mesa 26.3.1 RADV, GE-Proton11-15: ```text Evidence: TuxBox check of 76c386aa9b8a, no uncommitted changes, GPU default adapter: 15 passed, 1 failed, 0 not run ``` The one failure is `lanes-selftest-texture-publication`. It fails the same way on `main` (`2a850114`) without this change, on the same card; that's #625. All other Lanes scenarios and the D3D12 regression controls pass. - No NVIDIA card here. - No Lanes scenario: the change only adds a log line behind an off-by-default variable, and changes no behaviour a scenario could fail on. ## Game ProjectScarlett on the RX 9070 XT: an earlier copy of this commit, identical except that the code sat in `placement.rs` and any value of the variable turned it on, was on in all seven of my runs today, six of which I reported on #634 and #603. Those runs logged up to 75,823 drops each. The one use-after-free among them was matched to its texture this way (run 1 in my comment on #603). I also ran this exact commit in the game, cherry-picked onto that earlier build (main `712fb960` + #630) rather than this PR's base. The PR's base changes the translator, so a run on it would have meant recompiling every shader first, and the commit is the same on both. With `TUXBOX_LOG_TEXTURE_DROPS=1 TUXBOX_LAZY_PUBLICATION=0` (#634), it ran 400 s into the world, which I ended myself. It logged 50,863 drop lines, all in the format above. No GPU fault occurred in that run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!639
No description provided.