agc: keep the driver memory where macOS maps it (GTA V) #1454
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1454
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1454/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@AN0DIN on GitHub · 2026-10-12 14:07 UTC · original
AN0DIN:pr/agc-macos-driver-base→main· +24 −6 · 2 files · 2 commits · closed without mergingProblem
On macOS, every title that initializes AGC now exits at boot. With GTA V (PPSA04263 01.010.002) on an Apple M5,
the log shows the driver block landing at
out_addr = 0x0000007000000000, then:Since
165cd884(agc: initialize function table in tracked driver memory),Gen5Driver::Initialize()maps thedriver block at the PS5 address
DriverDmemBase(0x0fe0000000) and treats any other address as fatal. In themacOS x86_64 guest layout, the system-reserved range ends at
0x0fbfffffff(HOST_SYSTEM_RESERVED_MAXinmemoryAddressSpace.inc), so the kernel cannot place the block there and returns the first free address of the userarea instead.
Change
__APPLE__,Initialize()keeps the address the kernel returns (it only exits if the mapping returned noaddress), and builds the driver function table and its descriptor from that address instead of
DriverDmemBase.since the check guarantees
address == DriverDmemBase.Note: #1399 changes the same function (it reserves the driver memory at startup) and keeps the fixed address, so
it does not cover this case; whichever lands second will need a small rebase.
Testing
the macOS CI job runs).
mainthe Apple GPU is rejected earlier at device selection, so both builds beloware
mainplus #1083 (MoltenVK 1.4.x device features), one run each:DriverDmemBasecheck above, driver block at0x7000000000;separate, already known MoltenVK limitation (subgroup built-ins in vertex shaders), not related to this change.
and the Story mode prologue.
__APPLE__.AI assistance
An AI coding assistant (Claude Code) helped me find the cause, write the change and draft this description. I
reviewed the change and this text.
@coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original · edited 2026-10-17 08:10 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
1c6322cc-a362-4481-b980-1e6cfc319414📥 Commits
Reviewing files that changed from the base of the PR and between
bde3b9fb71and2c355ae02f.📒 Files selected for processing: 1
tests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
📝 Walkthrough
Gen5Driver::Initializenow accepts a non-null mapped address on macOS and uses it to calculate the DMEM table base. The AGC system table test discovers theSceAgcDrivermapping at runtime. Non-Apple platforms retain the fixed-address check.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
2c355macOS can use the driver memory address selected by the kernel, while other platforms retain the fixed address. The test checks the discovered mapping and table layout; no concrete merge-blocking risk remains.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -4176,1 +4180,4 @@EXIT_IF(address == nullptr);#elseEXIT_IF(reinterpret_cast<uint64_t>(address) != DriverDmemBase);#endif@coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original · edited 2026-10-17 08:06 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12473
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7139
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 17146
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2884
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10123
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 20141
Derive the test base from the mapped
SceAgcDriverrange.Gen5Driver::Initialize()can relocate the macOS mapping.CheckAgcSystemTable()still requiresmapping.start == DriverDmemBaseand reads the table atDriverDmemBase + 0x40000. The registered test can therefore fail on macOS before the descriptor checks. The macOS workflow builds this test but excludes it from its 14-test selection.Find the
SceAgcDriverrange withKernelVirtualQuery(..., 1, ...), then derivedriver_baseandtable_addressfrommapping.start.Suggested fix
✅ Addressed in commit
2c355ae@coderabbitai[bot] on GitHub · 2026-10-12 14:18 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
d964e97b-5624-4952-81d6-04040d027cdc📥 Commits
Reviewing files that changed from the base of the PR and between
df5b9b92beandbde3b9fb71.📒 Files selected for processing (1)
src/libs/agc.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@AN0DIN on GitHub · 2026-10-17 08:06 UTC · original
Pushed
2c355aefor the CodeRabbit note:CheckAgcSystemTableno longer assumes 0x0fe0000000. It looks up theSceAgcDriverrange by name and reads the table from wherever it is mapped. Other platforms still require thePS5 address.
Tested on macOS (Apple M5, Rosetta 2, MoltenVK 1.4.2): build OK, ctest 14/14 (the macOS CI selection), and the
test compiles. I could not run it: the Vulkan harness needs 64-bit buffer/shared atomics, which MoltenVK does not
expose, and CI builds
shader_recompiler_compute_testsbut does not run it. A local run on Windows or Linux wouldconfirm it.
@Nmzik on GitHub · 2026-10-21 19:42 UTC · original
Duplicate of #1682.
Pull request closed