Repository navigation
fix(agc): import shared guest memory through a read-write alias and never offer read-only pages - #186
Merged
boykopovar merged 2 commits intoSep 30, 2026
Conversation
…ever offer read-only pages Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
MichonGoddijn231849
force-pushed
the
fix/host-import-shared-alias
branch
from
September 30, 2026 15:18
df1079b to
8b8b710
Compare
8 of 9 tasks
9 tasks done
Owner
|
Instead of quiet fallbacks, let's throw a clear exception in these places:
If after this the game starts to crash earlier than before the changes, this will only show the real problem. |
…r copied exactly Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Done in f4be8f4, thanks. Both now throw with the reason:
It surfaced two things in GTA V right away. Both are in the relinked executable's own image, read by compute shader
With that, GTA V reaches the world again. If you'd rather not copy read-only memory, the alternative is for the loader to place the executable's read-only sections in private memory, so they import like the rest. Happy to do that instead. |
9 tasks done
9 tasks done
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
On NVIDIA (RTX 5080, driver 610.74),
vkAllocateMemoryrefuses a host-pointer import (VK_ERROR_OUT_OF_DEVICE_MEMORY) when any page in the range is read-only. After one refusal, later large imports in the same process fail too, even of memory that imported fine before.mainarms shared (direct memory) pages read-only for write tracking. So the first import of a direct-memory range is refused, and from then on every import fails ("out of memory ... retried later", thousands of times). Every BDA build then falls back to heap mirrors refreshed by copying: single dispatches took 11–16 s in "address bindings (bda)".This change:
GuestArenaMapAlias). Write tracking never arms that view; the GPU reads the same pages, so CPU writes stay visible. The view is unmapped when the import is destroyed.WindowsMappingskeeps a duplicated section handle per mapping, so the alias can be made after the caller closed its own handle.PAGE_READONLY/PAGE_EXECUTE_READ, not shared) is copied on purpose. It is the one kind the driver refuses, and it can't change without a protection change, which updates the registry, so the copy is exact.MapViewOfFile3(withGetLastError()).Tested
Windows 11, RTX 5080 (driver 610.74), MinGW GCC 15.2.
Standalone Vulkan test, each case in a fresh process, 64 MiB unless noted:
VirtualAllocRW, with or withoutMEM_WRITE_WATCHMEM_WRITE_WATCH-2-2: a range that imported before-2-2: fresh 16 MiB or 1 MiB.data), and untouched copy-on-write image pagesGTA V (PPSA04264), with #167, measured before the rebase onto the latest
main(the Windows import path is unchanged by it):cteston currentmainwith this change: the libc and guest tests pass. Not run on this machine:agc_driver,agc_shader_memory,agc_driver_flipandagc_driver_pm4exit with0xc0000139at startup, the same as on plainmainbefore the rebase;agc_driver_graphicsdoesn't build here (tests/Graphics.cpp:1246, from the recent merges, untouched here);empty_tls,tls_function_coverageandwindows_gui(relinker) fail.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🤖 Generated with Claude Code