Repository navigation
Conversation
GuestMemory::WriteChanged stores only the bytes the GPU changed, so that CPU writes to the bytes around them survive. It found them a byte at a time inside every changed 256-byte block and stored each run with memcpy. Where changed and unchanged bytes interleave (the low bytes of floats), every run is a few bytes long, and that loop took 43% of the GPU submission thread in Disney Epic Mickey: Rebrushed's first level (0.9-1.0 ms per MiB). Each 16-byte chunk is now compared with SSE2. A chunk with no change is skipped, a chunk that changed entirely is stored whole, and a mixed one is stored with MASKMOVDQU, which writes only the bytes selected by the mask. An SFENCE after the loop orders those non-temporal stores before the stores that follow. Bytes the GPU did not change are still never written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0134RWCyiyydJBbfKz8g9Bwe
|
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes. |
Contributor
Author
|
Windows run: Windows 11 (26200), i7-13700K, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. |
9 tasks done
Contributor
Author
|
Reopened as #3137 (rebased onto current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
GuestMemory::WriteChangedstores only the bytes the GPU changed in a mirrored buffer, so that CPU writes to the bytes around them survive. It found those bytes one at a time inside every changed 256-byte block and stored each run withmemcpy. When changed and unchanged bytes interleave (for example, only the low bytes of floats change), every run is a few bytes long, so each costs a byte loop and amemcpycall.Each 16-byte chunk is now compared with SSE2:
_mm_storeu_si128);MASKMOVDQU(_mm_maskmoveu_si128), which writes only the bytes its mask selects.An
SFENCEafter the loop orders the non-temporal masked stores before the stores that follow. A tail shorter than 16 bytes still goes byte by byte. Bytes the GPU did not change are never written, as before, and the reported changed range is the same.Tested
Linux (Ubuntu 24.04, GCC 13.3), i3-12100, RX 7600 (RADV).
New
testWriteChangedStoresExactlyTheChangedRuns(agc_driver_pm4_tests): 1037 bytes of random runs (changed, unchanged, and changed with some bytes left equal) over guest bytes that differ from both copies. Checks that exactly the changed bytes are stored and that the 13-byte tail is handled.Full
ctest: 553/554. The failure isguest_video_out_resolution_status, which needs a Vulkan-capable SDL display and fails over SSH (offscreen driver) without this change too.tools/check_conventions.pyandtools/check_test_registration.pypass.Microbenchmark, 1 MiB, best of 30, one core:
Disney Epic Mickey: Rebrushed (PPSA15657, UE4), first level, on its testing stack (Disney Epic Mickey: Rebrushed (PPSA15657) on Linux #2255) with
APS5_NO_HOST_IMPORT=1, so the level's compute buffers are mirrored:WriteChangedtook 43% of the GPU submission thread, the bottleneck thread here (the GPU was ~1.4% busy), at about 1.0 ms per MiB written back.Windows (MinGW) is covered by CI only; SSE2 is part of the x86-64 baseline.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code