Repository navigation
Upstream sync 10 (slice C): AGC driver onto Metal - #495
Merged
Merged
Conversation
…bel satisfies waitMemory starts a new collect epoch when it returns, so the next CollectWrites of every surface walks the write watch again. The label-table path already keeps the epoch for a non-late hit whose store came from the waiting queue: such a label orders only that queue's own work, no store by the guest or another queue. The two storedSince returns (at entry and while polling) answer the same question from the label-store history but kept the bump for a store of the waiting queue. They now keep the epoch in that case too. (cherry picked from commit 17984f8) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…ble imports A build mapping only the cached address space but writing through V#s got a table keyed by its writes: a new key for nearly every set of written addresses, so each such build merged the space's imported ranges, stored them, then hashed and compared them in BdaResources. AddressRanges splits only ranges without write permission around the written intervals. When no written interval overlaps such a range of the space, its result is the space's own ranges, so the build binds the space's table by the space serial, as a build without writes does. A write overlapping a range without write permission keeps the per-writes table. Test: builds with one and two writes inside a writable import bind the serial and the ranges of the build without writes, equal to AddressRanges(), and keep the read-only import without write permission. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit d95634b) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
(cherry picked from commit ac145e9) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…e misses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 5cf0aa4) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
SW_64KB_Z_X (0x18) color targets use the texture equations and 64 KiB block geometry of that swizzle mode, including the equation bits above the block that R_X targets already apply. A title renders the R32 float copy of its depth into one. Fork: the debt note goes into docs/dev/TechnicalDebt.md. On Metal the shared decode maps the mode to kZ64KBX, which the Metal texture path already detiles through its equation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f6aa98b) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e88b5c2) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…ISSES is set The per-miss component comparison allocates and walks the whole key, and it ran under APS5_PROFILE_DRAW as well, where it cost queue time on every resource-content miss. It now runs only with the trace variable, which is also the only one that prints its [keymiss] lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 7e00eda) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
A 2D-array image_load or image_store bound to a 3D T# addresses the slice as z. Add a 3D runtime mode for these accesses and drop loads and stores whose slice is past the volume depth. (cherry picked from commit 945b970) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
The zero fill kernel (v_mov_b32 v1, 0; buffer_store_format_x) is also emitted with other inline integer constants as its source. Run as compute dispatches, those writes are pending writes of unknown value, so a later read of DCC keys over their range waits for the dispatch. A constant of 0 to 64 or -1 to -16 is now matched like the zero fill and stored as a buffer fill of that value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Fork: the fork has no MatchZeroDwordFill or memory-value buffer fills (an earlier upstream series), so MatchConstantDwordFill is added on its own and tried after MatchDwordPatternFill. Vulkan driver only: the Metal backend does not use BufferFill.cpp. (cherry picked from commit b83755a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
(cherry picked from commit ffc6c89) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
(cherry picked from commit 53acbf0) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
… color target radeonsi exports MRT0 as 32_AR when alpha-to-coverage is on and no color buffer is bound, so a depth-only draw can depend on that alpha. The decoder now accepts 32_AR and an absent MRT0 target, and reads the MRT0 export format from SPI_SHADER_COL_FORMAT, which it masked to 0 for draws without a color target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Fork: the debt note is updated in docs/dev/TechnicalDebt.md. State.cpp is shared with Metal, so Metal draws with alpha-to-coverage from a 32_AR MRT0 export or without an MRT0 color target are no longer refused at decode. The Metal draw path does not pass alphaToCoverage to the pixel stage (unchanged by this commit). (cherry picked from commit c8662b6) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Add a --layout-pair mode to agc_shader_memory_tests, registered as agc_shader_layout_pair and agc_shader_layout_pair_off (the latter with APS5_NO_PERF_LAYOUT_PAIR=1), next to the frontend-pair tests. A pixel shader with a buffer load is prepared with a 128-byte push range and with none through one context, in both orders: without registration modules, with them at push offset 0 and at the fragment slot offset 128 that devices with graphics pipeline libraries use, and with a registration word limit that forces the fallback to plain modules. Each pair must build one program with reuse and two without, and each layout must match a compile of the same code made on its own source without a context: SPIR-V, binding layout, push range and push-data use, artifact fields and compiled shader information. The materialized result must also match an uncached Recompile. The context must not reuse a program translated at another code address or one built for another source at the same address, and it must release the kept program when it builds another one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0d7b4b4) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
The layout-pair check compared a subset of the prepared artifact: the fragment parameters only by count, and not the barycentric emulation, the runtime ABI version or the vertex interface fields. Its pixel fixture also had no interpolated inputs, so the fragment parameter list was empty on both sides. Compare every artifact field except the variant id, the fragment parameters element by element, and add a fifth configuration: registration modules at the fragment slot offset with two interpolated inputs, which must declare two fragment parameters in both layouts. With this, flipping the barycentric emulation flag, a fragment parameter's flat flag or the runtime ABI version on the reused path fails agc_shader_layout_pair, where the previous check passed all three. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 60e564a) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
The reused program hands out its compiled information through IrProgram::CompiledInfo() const&, while compileVariant still moves it out with TakeCompiledInfo(). The layout-pair fixtures are pixel shaders whose user-data base, scratch size and parameter export mask are all zero, so the comparison with isolated compiles could not tell whether the copy kept those fields: a copy that zeroed them still passed. Translate a compute program with a user-data base of 2 and 64 scratch dwords and require the copied and the moved information to agree on every field. Zeroing those fields in the copy now fails agc_shader_layout_pair and agc_shader_layout_pair_off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 49de394) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…copy Driver::draw copied every stage's compiled result (RecompileResult, with its binding, push-constant and attribute vectors) out of the shared result the capture materialized, once per stage per draw. The stages now point at the shared result. Only the CPU path of an indirect draw rewrites a stage (each record's patched user data is materialized again), so that path copies the stages it may rewrite first, on a cache hit or a miss. agc_driver_indirect_patched_stage draws through that path: a record that patches the user data word a vertex stage writes as its depth must draw with the record's value, not the register's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 73a808e) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…d pointer Retained SPIR-V is a span now, and SpirvTools::Validate takes a vector or a pointer and a size. (cherry picked from commit 759cc67) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…a pass (cherry picked from commit 2061625) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Each pixel used its own 16-byte slot across 512 pixels, so the per-invocation LDS array held 8 KiB for a test that only needs one slot per lane of a wave. 64 slots and the counter right after them keep the array at 320 dwords, which software rasterizers compile in a fraction of the time. (cherry picked from commit 3b8bf7e) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Retained SPIR-V is a span on main since boykopovar#4806. (cherry picked from commit bfca92e) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
(cherry picked from commit 00fe89c) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…ord count (cherry picked from commit 6d7b1d1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…zed coordinate filters Fork: the updated unnormalized S# note moves from docs/dev/debt/libSceAgcDriver.md to docs/dev/TechnicalDebt.md. GuestSamplerResource.cpp is shared with Metal: MetalSampler now receives equal min/mag filters and clamp-to-edge for X/Y clamp mode 0 on unnormalized S#s, which its pixel-sampler contract accepts, so no Metal change is needed. (cherry picked from commit e1d402c) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
…with APS5_STORE_AT_LABEL Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Fork: the debt note is updated in docs/dev/TechnicalDebt.md. Vulkan driver only: the label hook is in VulkanDevice::WriteLabelOnGpu; the Metal backend does not keep StorageTexture pending results. (cherry picked from commit d756f52) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Every address-based build copied the cached address space's imported ranges (about 9000 in Sword of the Sea gameplay) into its batch as pending reads, only for the copy HLE's reader check to scan them. The space now builds that list once, and a build that took the space whole notes it by reference (Recorder::NotePendingReadList); its own ranges follow as before. The space is immutable while its serial lives, the list equals the space's part of InPlaceReads in its order, and the batch scans plain reads and lists in note order, a list by bisection, so every PendingReadOverlaps and DescribePendingRead answer and reader kind stay the same. A capture trace or APS5_FLIP_READ_CHECK expands the list as before. Tests: lists noted by reference answer like the same ranges noted one by one (open and in-flight scans, kinds, a list noted twice, empty and null lists); the space's list is shared while the registry stands and rebuilt when a range is added or removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 48cdce9) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
TechnicalDebt.md already carried the unnormalized S# note that upstream e1d402c updates, so the updated note replaces it in place instead of being listed twice. The title named in the upstream note is left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Upstream 945b970 extends ImageAddressDimension with 2D-array loads and stores on 3D T#s, which the shared ResourceMaterializer now lowers as volume accesses. The test runs unchanged through the Metal driver semantics shim beside the other image addressing tests. ImageStoreArrayThroughVolume, ImageSampleUnnormalized and Uint8x4ColorTarget are not added: they use VulkanDevice members the shim does not provide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
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.
Upstream sync 10, slice C: AGC driver onto Metal. Range
d8888df9b..upstream/main, scopesagc,agc-driver,libSceAgc,libSceAgcDriver,bda(48 commits). 25 upstream commits are cherry-picked with-x, one each. Two fork commits follow: a debt-doc fix and a Metal test registration. One commit message that named a title was reworded (f6aa98b29). No Metal backend source changes:MetalDriver.mm,MetalDraw.mm,MetalPacketExecution.mmand the per-draw buffer recycling and surface reuse code are untouched.Ported
On the Metal/Rosetta path (shared
ColorTargetLayout.cpp,State.cpp,GuestSamplerResource.cpp, or the shader recompiler):f6aa98b29render into SW_64KB_Z_X (0x18) color targets (sharedColorTargetLayout). On Metal the shared decode maps the mode tokZ64KBX, whichMetalTexturealready detiles through its equation. The debt note goes intoTechnicalDebt.md. The message is reworded so it no longer names a title.945b97094accept 2D-array image loads and stores on 3D T#s (ResourceMaterializer,SpirvImageEmitter). Conflict resolved by keeping the fork's single-mip plane-bias 2D case from Upstream PR batch 1 U8a: Metal image-mode views #485 beside upstream's volume load and store cases. TheShaderMemorytest adds onlyverifyVolumeArrayLoadMode. Fork commitadaf6f315runs the extendedImageAddressDimensionunchanged on the Metal driver.c8662b6bcaccept alpha-to-coverage from a 32_AR MRT0 export, or with no MRT0 color target (sharedState.cpp). On Metal this only widens which draws the decode accepts. The Metal draw path does not passalphaToCoverageto the pixel stage, and this PR does not change that. The debt line is replaced in place inTechnicalDebt.md.e1d402c6csecondary LOD bias, and unnormalized S#s with clamp mode 0 or differing min/mag filters (sharedGuestSamplerResource).MetalSamplernow gets equal min/mag filters and clamp-to-edge, which its unnormalized-sampler checks accept, so it needs no change. The updated debt note replaces the existing one inTechnicalDebt.mdand is removed fromdebt/libSceAgcDriver.md. Fork commit8f37a56f3drops the duplicate and the title the upstream note named.Vulkan driver side, carried to stay close to upstream (not built on macOS):
17984f8c5no-collect epoch at a wait its own queue's stored label satisfiesd95634b70BDA table for writes inside writable imports. The test list dropsspaceImportRunTests, which comes from an unported commit.ac145e9beincremental pending-write snapshots. Onlyagc_pending_write_snapshotand its dispatches are registered.5cf0aa48d,e88b5c296,7e00edae2resource-key-miss trace (APS5_TRACE_RESOURCE_KEY_MISSES). Only theagc_driver_key_misstarget is added;RegisterKey.cppis not in the fork.b83755ac9constant dword fill. Adapted: the fork has neitherMatchZeroDwordFillnor the memory-value buffer fills, soMatchConstantDwordFillis added by itself and tried afterMatchDwordPatternFill. The Metal backend does not useBufferFill.cpp.ffc6c894e,53acbf0dfcoherent buffer heaps and budget placement test (test main: only the--buffer-budget-placementdispatch)0d7b4b4bc,60e564a31,49de39478registration-layout tests73a808e9adraw stages share their compiled result206162549DCC register clear fallback in the metadata pass. Onlyagc_metadata_passis registered.00fe89c53,6d7b1d11breserved resource keys (test main: only the resource-content-key dispatch)d756f525fAPS5_STORE_AT_LABEL. The hook is inVulkanDevice::WriteLabelOnGpu; Metal keeps noStorageTexturepending results. The USAGE paragraph is added, and the debt line is updated inTechnicalDebt.md.48cdce992an address space's in-place reads as a shared read list (BDA). Tests: onlyspaceReadListTestsand--read-list-only.759cc67ba,3b8bf7eab,bfca92e8atest fixupsSkipped
16f63d8ed(Upstream PR batch 1 U6: shader semantics correctness (ALU, LDS, export) #481),8d89265c7(Port upstream AGC driver shared slice (U5) #475).1402c6c1d(VK_EXT_device_fault),1d4c372e3(graphics library prebuild).76c0ba53e(BT.2100 PQ to SDR inPresentationPass). Metal presentation would need its own tone-map pass.5894feff7,4e136dd32(udmabuf / sparse dma-buf imports).52c71b837,c21842963(noPerformanceTrace/trace_digest);0286a767e(add/add conflict with the fork's ownSubmissionCapture, which Rosetta builds);ea91d6809(noWaterfallImagestest).80d8bd06ba72dcb93a, before the range):f7a2903edd04e983202eda9f893layerOriginal):f05086278,3eb19d9f2c8b3a3753,246d16a032d3c9b4b1,838c1ca96d34564be4dca6020daEvidence
arm64 guest replay config (
-DANYPS5_METAL_UTILITIES_ONLY=ON -DANYPS5_METAL_SHADER_BRIDGE=ON -DANYPS5_BUILD_METAL_SHADER_BRIDGE_TESTS=ON -DANYPS5_METAL_GUEST_REPLAY=ON): full build, then ctest without the GUIanyps5_metal_presentation_replay. 59/59 passed, including the newanyps5_metal_driver_semantics_imageaddressdimension.ImageStoreArrayThroughVolume,ImageSampleUnnormalizedandUint8x4ColorTargetwere tried on the Metal driver shim, but they failed to compile or link againstVulkanDevicemembers the shim lacks, so they are not registered.Rosetta x86_64 (
-DANYPS5_ROSETTA_LIBS=ON):rosetta_libs rosetta_engine metal_utility_tests rosetta_direct_graphics_testsbuilt, and ctestmetal_utility_tests|rosetta_direct_graphicspassed 2/2.Vulkan-device targets (
tests/Graphics.cpp,Recorder.cpp,BdaResources.cpp,BufferPool,tests/execution/*on Vulkan) are not built on macOS. Their hunks are carried but not compiled or run here.Game smoke (
tools/smoke.sh <build> 300 --map, eboot lock, private image clone), compared with the sync 9 main run:Both branch runs reached the 3D map and ran to the 300 s wall (exit 0 on SIGTERM), with 0 unresolved imports. The only unimplemented call is the same Ajm Opus mode as on main. The last captured frame of run 2 (flip 2371, 1920x1080) shows the 3D map: terrain, forests, rivers, hex borders, the founder unit panel, the first-city tooltip and the minimap. It also shows a large translucent blue rectangular block over the coast to the right of the city hex. That may be the 3D-map glitch being bisected on
fix/metal-map-glitch. No main frame was kept, so this PR does not compare it. The timings are asset-open times on a shared machine running other agents. They are not a performance comparison.No performance claims; nothing was measured for speed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj