fix: upload rewritten guest textures before the next submit #2

Open
github-bot wants to merge 1 commit from github-bot/gh-2 into main AGit
Owner

@⁠AutoComput on GitHub · 2026-11-21 10:03 UTC · original
AutoComput:fix/guest-texture-same-frame-upload → main · +22 −17 · 2 files · 1 commits · open

TL;DR

  • Problem: When a game changes a texture and draws with it in the same frame, the old image is drawn.
  • Fix: Recently changed textures are now sent to the graphics card before every batch of drawing, not once per frame.

Guest texture memory is only scanned once per presented frame, so a write after the frame's first submit shows up a frame late, and never if nothing is presented. That's why test_d3d12_guest_texture fails.

Textures created or written within the last frame are now also checked on every submit. The full scan stays once per frame, since GetWriteWatch costs about 1.5 us per MB here (roughly 3 ms for 2 GB of textures). A texture that sat idle for more than a frame and then gets rewritten mid-frame can still be one frame late.

test_d3d12_guest_texture passes on Release (MSVC 2022, WARP). I don't have the title, so the per-submit cost in a real game is unmeasured; flush_ms/f in --stats now includes it. Status files not regenerated.

**@⁠AutoComput** on GitHub · 2026-11-21 10:03 UTC · [original](https://github.com/Freminet/ScarlettX/pull/2) `AutoComput:fix/guest-texture-same-frame-upload` → `main` · +22 −17 · 2 files · 1 commits · open **TL;DR** - **Problem:** When a game changes a texture and draws with it in the same frame, the old image is drawn. - **Fix:** Recently changed textures are now sent to the graphics card before every batch of drawing, not once per frame. Guest texture memory is only scanned once per presented frame, so a write after the frame's first submit shows up a frame late, and never if nothing is presented. That's why `test_d3d12_guest_texture` fails. Textures created or written within the last frame are now also checked on every submit. The full scan stays once per frame, since `GetWriteWatch` costs about 1.5 us per MB here (roughly 3 ms for 2 GB of textures). A texture that sat idle for more than a frame and then gets rewritten mid-frame can still be one frame late. `test_d3d12_guest_texture` passes on Release (MSVC 2022, WARP). I don't have the title, so the per-submit cost in a real game is unmeasured; `flush_ms/f` in `--stats` now includes it. Status files not regenerated.
Guest texture memory was only scanned once per presented frame, so a write
after the frame's first submit reached the host texture a frame late, and
never when nothing was presented (test_d3d12_guest_texture).

Textures created or written within the last frame are now also checked on
every submit. The full scan stays once per frame.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:55:02 +00:00
This pull request has changes conflicting with the target branch.
  • README.md
  • src/shims/d3d12_xs_shim.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2/head:github-bot/gh-2'
git switch 'github-bot/gh-2'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2'
git switch 'github-bot/gh-2'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2'
git switch 'github-bot/gh-2'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2'
git switch 'main'
git merge --squash 'github-bot/gh-2'
git switch 'main'
git merge --ff-only 'github-bot/gh-2'
git switch 'main'
git merge 'github-bot/gh-2'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.