Skip to content

Windows: whole-surface compares of imported render targets dominate GTA V's draw path (measurement) #4432

Closed

Description

@tibzejoker

docs/dev/TechnicalDebt.md says that on Windows, host-pointer imports of the guest mapping are compared instead of write-watched, and that "measuring the comparison cost" is not done yet. Here is a measurement from one title, where this cost is most of the frame.

Setup. GTA V (PPSA04264), Windows 11, RTX 4090 (NVIDIA), WinLibs GCC 15.2.0, Release, write watch on. Tree: main 325e0a8 plus the PRs the title needs to reach Story, plus #2802. The scene is the first minutes of the Story prologue.

Where the time goes. I added local timers inside StorageTexture::Refresh (summed over all threads, per 10 s):

Why the memo still misses with #2802. Out of 420k compareUntracked calls:

Outcome Calls
memo hit 365k (87%)
miss because CollectEpoch changed 40k
miss because ForgetSerial changed 4.1k
miss because NewestStamp changed 0.8k
no memo entry yet 5.6k
not memoizable (memoize false or epoch 0) 8.3k

So almost every remaining compare is the one that guards against a CPU store into unwatched memory at a new ordering point. Splitting the compare into 64 KiB units would not change that, because at a new epoch every unit is a candidate. In this scene the compared surfaces were found unchanged about 98% of the time.

I don't have a proposal for how to keep these imports watched on Windows; the TechnicalDebt entry explains why the driver can dirty imported pages after the import window. I'm posting this so the cost is on record for whoever picks it up. Happy to run a branch on this title and report numbers.

AI-assisted (Claude Code).

Activity

  1. tibzejoker commented on Oct 13, 2026

    @tibzejoker
    ContributorAuthor

    Update: #4878 (nikowolf123) addresses this. On GTA V's Story prologue, the whole-surface compares go from 7 s to about 4 s per 10 s, and the frame rate from 0.60 to 1.09 FPS. Numbers are in #4878 (comment). I will close this issue once #4878 is merged.

    AI-assisted (Claude Code).

  2. tibzejoker commented on Oct 14, 2026

    @tibzejoker
    ContributorAuthor

    Closing: #4878 is merged. On GTA V's Story prologue, the frame time went from 1372 to 856 ms (p50) on the same tree (traces in #4878 (comment)). The whole-surface compare is still the largest single cost; a follow-up would get its own issue.

    AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions