Repository navigation
Upstream sync 6: shared AGC driver fixes onto Metal (slice A, second chunk: sample locations, #186) - #446
Merged
Conversation
Hand port of upstream c9e48e5 ("support uniform custom MSAA sample locations"), ae6dfd9 / 33efe5a (the standard 8x pattern's last sample is at (7, -7)) and the PA_SC_AA_SAMPLE_LOCS draw-key range from ebf3611, onto the fork's MSAA model. - State.cpp decodes PA_SC_AA_SAMPLE_LOCS for a multisampled PA_SC_AA_CONFIG: a pattern that varies over the 2x2 pixel grid is refused, a uniform one is kept, flagged custom when it is not the standard 2x/4x/8x pattern. The fork's rasterSamples / attachment sample count model and its EQAA acceptance stay; a custom pattern on a pass whose attachments fix another sample count is refused. - A context that never wrote PA_SC_AA_SAMPLE_LOCS keeps the standard pattern (as before), so fixtures and titles that leave them unset do not start throwing. - Upstream refuses multisampling without MSAA_ENABLE (ebf3611); the fork accepted it and rasterized at the standard positions. It now rasterizes every sample at the pixel center, which is what clearing MSAA_ENABLE means, through the same programmable positions. - SampleLocations() gives the positions in [0, 1); the standard ones equal Metal's default sample positions. - Metal: ConfigureSamplePositions sets programmable sample positions on the draw's render pass for a custom pattern (refused when the device has none). Positions are pass state on Metal, so upstream's GPL pipeline keying (605741d, fb7615e) and Vulkan depth-format check (e28dcc0) have no Metal counterpart. - DrawKeyRegisters covers 0x2fe..0x30d, which the decoder now reads (the single-sample MSAA_ENABLE path already read them). Test: anyps5_metal_render_state CustomSampleLocations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream de651c6 made the Vulkan driver read the (offset, value) lists of SET_SH/CONTEXT/UCONFIG_REG_INDIRECT when a command buffer is submitted. The fork's Metal driver still read them on the queue worker, so a title that reuses the list memory before the GPU reaches the packet applied the rewritten registers, or threw on garbage offsets. - SubmissionCapture gains CaptureIndirectRegisterLists, which fills Submission::registerLists from the captured commands (errors name the packet and DWORD offset, as upstream's do). - MetalDriver::Submit and ExecuteRewindTail call it after ValidateSubmission, still under the guest-capture lock and borrowed ranges. - The Metal worker applies the captured list with Pm4::ExecuteIndirectRegisters; the packet no longer reads guest memory there, so it no longer waits for GPU work that writes the list. Test: anyps5_metal_pm4_compute_replay IndirectRegistersAtSubmit holds the worker at a WAIT_REG_MEM, rewrites the list to move the dispatch's output descriptor, then releases it; the dispatch writes the submit-time buffer. Same for a REWIND tail. Fails on main with "SET_SH_REG_INDIRECT used the list rewritten after Submit". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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.
Part of #415. Refs #418 (second chunk; some shared MSAA logic still remains, see "Remaining"). Closes #186.
Follows #442. The AGC driver's real upstream base in the fork is
a11c8f7f7. This chunk ports the shared-logic MSAA commits froma11c8f7f7..2ccbd376fthat the Metal build compiles. They are ported by hand, function by function, onto the fork's MSAA model, because cherry-picks would replace that model. It also does #186, which #418's review asked for in this scope.Ported
Custom MSAA sample locations: upstream
c9e48e5ae,ae6dfd907/33efe5ac5(8x sample 7 at (7, -7)), and the sample-location draw-key range fromebf361103Graphics/src/State.cpp). For a multisampledPA_SC_AA_CONFIG, the decoder now readsPA_SC_AA_SAMPLE_LOCS.SampleLocations(state)returns the positions in [0, 1), with upstream's signature.rasterSamplesandAttachmentSampleCount.texture2d_ms).ConfigureSamplePositionssets programmable sample positions on the draw's render pass for a custom pattern, and throws if the device has none.605741d39,fb7615e30) and its Vulkan depth-format check (e28dcc0c1,SAMPLE_LOCATIONS_COMPATIBLE_DEPTH) have no Metal counterpart.ebf361103). The fork accepted it and rasterized at the standard positions, which was wrong. It now rasterizes every sample at the pixel center, which is what clearing MSAA_ENABLE means, through the same programmable positions.DrawKeyRegistersnow covers0x2fe..0x30d. The fork's single-sample MSAA_ENABLE path already read those registers without them being keyed.#186:
SET_*_REG_INDIRECTread at submit time on Metal (upstreamde651c628did this for Vulkan)CaptureIndirectRegisterListssits in the fork's shared submission code (Execution/src/SubmissionCapture.cpp). It fillsSubmission::registerListsand names the packet and DWORD in its errors. It is not a copy of the Vulkan function.MetalDriver::SubmitandExecuteRewindTailcall it afterValidateSubmission, still under the guest-capture lock and borrowed ranges.Pm4::ExecuteIndirectRegisters. Because the packet no longer reads guest memory there, itsBeforeCpuReadwait is gone.Not taken
Upstream's CB resolve pass and multisampled CMASK model (
ebf361103resolve mode,eeefb0654,d109f3966,163947ef7). These need Metal-side features the fork does not have:texture2d_msinto CB1;The decode alone would only change which draws are refused. CB_COLOR_CONTROL mode 3 stays refused on Metal (
colorControlSupported). They are listed under "Remaining".Upstream refusing DCC over multisampled targets (
ebf361103). The fork ignores DCC/CMASK keys for resident multisampled targets by design.22d662edastencil reference export. It needs recompiler changes (StageIO, ShaderInfoCollector, emitter) and a Metal shader bridge[[stencil]]output. Those files are being changed by Metal shader bridge skips draws: "Subgroup builtins are not available" #443's work right now, so it is left for the shader slice.The 16 Vulkan-side commits that conflicted in Upstream sync 6: shared AGC driver fixes onto Metal (slice A, first chunk) #442. I re-trialled them on top of this branch:
ef218ef92 eaf5ca240 ff349a9a5 63ddeb09f dc0c2cf8c d31b13f49 fd98327ba. But most are tests or follow-ups for the 9 that still conflict on missinga11c8f7f7..2ccbd376fprerequisites:4de5726d3 b9b83cef2 1b4baaee2 b45232dda 29a843579 59db660f7 e785a902b 086f7d509 90d899d98.Remaining for #418
ebf361103,eeefb0654,d109f3966).a11c8f7f7..2ccbd376fVulkan, recompiler and test commits.22d662edastencil export (shader slice).Tests
anyps5_metal_render_state:CustomSampleLocations. It decodes guest registers and renders through the Metal backend.getDefaultSamplePositions.setSamplePositionsremoved, it fails ("samples at one custom position still gave partial coverage").anyps5_metal_pm4_compute_replay:IndirectRegistersAtSubmit, run both as a plain submission and as a REWIND tail.SET_SH_REG_INDIRECTpair list to move the dispatch's output descriptor, then releases the worker. The dispatch writes the submit-time buffer and leaves the other one untouched.-DANYPS5_METAL_UTILITIES_ONLY=ON -DANYPS5_METAL_SHADER_BRIDGE=ON -DANYPS5_BUILD_METAL_SHADER_BRIDGE_TESTS=ON -DANYPS5_METAL_GUEST_REPLAY=ON): full build,ctest --output-on-failure --timeout 30036/36 passed.-DANYPS5_ROSETTA_LIBS=ON):rosetta_libs rosetta_engine rosetta_launcher_tests direct_memory_darwin_tests metal_utility_tests rosetta_direct_graphics_tests rosetta_cpuid_tests rosetta_runtime_tests.ctest -R 'direct_memory_darwin|metal_utility_tests|rosetta_direct_graphics|rosetta_lib_binds|rosetta_runtime|rosetta_launcher|rosetta_cpuid': 9/9 passed.Game run (one, reference title)
tools/rosetta/run_title.py --wall 280with this branch's Rosetta build, underwith-lock eboot. The data image was a private APFS clone, mounted read-only (detached and deleted afterwards). Relink cache was a private empty one. Frame capture went to a scratch dir, and the captures were deleted afterwards.mainrun.AGC graphics:refusals, so none of the changed decode paths refused anything. TheSubgroup builtins are not availableskipped draws (Metal shader bridge skips draws: "Subgroup builtins are not available" #443) are still there; that code is unchanged here.DriverStoppedfromsceAgcSuspendPoint, exit 134). That code is unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj