fix(agc): start the sample location registers at their clear-state value #4949
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4949"
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?
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T06:01:32Z.
What
A draw with
PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES> 0 whose context never wrotePA_SC_AA_SAMPLE_LOCS_PIXEL_*(context0x2fe-0x30d) was rejected withmissing register in context bank at DWORD 0x2fe (766).decodeSampleLocationsreads the registers withread(), and they were not in the initial context. The same happened on theMSAA_ENABLEsingle-sample path, which reads them withread()beforesingleSampleMsaaRejection. Resident Evil 4 (PPSA07411) stops with this error after two frames.The sixteen registers now start at 0, both initially and after
CLEAR_STATE, in the same way earlier fixes addedPA_SU_POLY_OFFSET_CLAMP,SPI_PS_INPUT_ENA/ADDRandSPI_PS_INPUT_CNTLto the initial context. The value comes from:sceAgcGetRegisterDefaults2,RegisterDefaultsData.hpp). Every public table that holds context registers (V0, V4, V5, V7-V11) sets0x2fe-0x30dto 0. The same tables supplyPA_SU_VTX_CNTL = 0x2dandPA_SC_CONSERVATIVE_RASTERIZATION_CNTL = 0x6000, which the initial context already uses. amdgpu's GFX10 values for those two registers (0x5 and 0x100000) are different, so these tables are the console's own source.clearstate_gfx10.h,gfx10_SECT_CONTEXT_def_8from0xa2f5. All sixteen registers are 0 there.gfx_v10_0_cp_gfx_startloads that table beforeCLEAR_STATE.gc_10_3_0_default.h,mmPA_SC_AA_SAMPLE_LOCS_PIXEL_*_DEFAULT = 0.The Mesa and PAL drivers write the registers themselves and never read the unwritten value, so they don't settle it. RADV calls
radv_emit_default_sample_locations(radv_device.c) whenever no custom locations are bound. radeonsi'ssi_emit_sample_locations(si_state_msaa.c) writes the pattern for each sample count, including 0 for 1x. PAL'sMsaaState::WriteSamplePositionswrites the client's quad pattern on everyCmdSetMsaaQuadSamplePattern. Their 1x pattern is also 0, which means the pixel center.With 0, every sample sits at the pixel center. That is not the standard pattern for 2, 4 or 8 samples, so such a draw decodes as custom sample locations at the center (
customSampleLocations, all locations 0). A single-sample scan into a multisampled target already decodes this way. As for any custom pattern, the draw needsVK_EXT_sample_locationsfor its sample count. Without it, the draw throws the existingcustom sample locations require VK_EXT_sample_locationserror.The run log doesn't contain the value of
PA_SC_AA_CONFIGor of the failing draw's registers. The draw sets its context withSET_CONTEXT_REG_INDIRECT, and the register lists are in guest memory. The only draw in the failing submission (queue 0x0, serial 8) isDRAW_INDIRECTwithVGT_DRAW_INITIATOR = 2(auto-index, not indexed). The error reaches the title throughDriver::CheckFailurefromsceAgcCreateInterpolantMapping→ResolveGraphicsAbi. Whether the title draws further is not known: this PR was not run on the title.Tested
Windows Server 2025, MinGW (winlibs), NVIDIA RTX 3060.
agc_driver_graphics: the newUnwrittenSampleLocationTestsstart from a fresh queue state with the draw's registers written on top and no sample-location registers. They check:0x622ae6ae) still decode as standard.0x22eea66a) still decode to the same coordinates.CLEAR_STATEresets the registers to 0.more than eight samples, and a mismatched exposed count still throwsexposing fewer samples, both with unwritten registers.MSAA_ENABLEon a single-sample target with unwritten registers decodes.On
mainthe test fails. With the initial-context assertion disabled, the decode fails with the title's message,AGC graphics: missing register in context bank at DWORD 0x2fe (766). With the fix, it passes.Also passing:
agc_driver,agc_driver_pm4,agc_driver_pm4_failure,agc_driver_msaa_enable_single_sample,agc_driver_alpha_to_coverage,agc_driver_draw_cache_reuse,agc_driver_draw_cache_reuse_off,agc_driver_depth_fast_clear_submit,agc_driver_prepared_graphics,agc_driver_prepared_unregistered_graphics.Not run on the title.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T06:21:22Z.
Tested with a title: Resident Evil 4 (PPSA07411) on Windows Server 2025, RTX 3060.
mainat7e181fcc3: the title renders 2 frames and aborts after 22 s withAGC graphics: missing register in context bank at DWORD 0x2fe (766).Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T06:35:12Z.
Correction to my previous comment: "renders" overstated it. In a 10-minute run with this PR the title presents frames at 59.95 FPS without any error, but every captured frame is black: it is stalled on what looks like a file-loading wait, which is unrelated to sample locations and which I am looking into separately. What this PR changes for the title is only that the
missing register in context bank at DWORD 0x2feabort is gone.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T10:32:16Z.
Conflicts with main in
core/libs/prx/libSceAgcDriver/tests/Graphics.cppafter #4584; please rebase. The full build on f982c7e0 failed only on a test main has since fixed.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T14:00:50Z.
Another data point for the title in the description: in three of my saved runs of PPSA07411 (2026-10-12, before this change) the title stops with
AGC graphics: missing register in context bank at DWORD 0x2fe (766), the same register and the same message. I have not run it with this PR applied, so I cannot say whether it gets further than that point.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T15:10:43Z.
I rebased onto
main91ed4ce62. The only conflict was the test list inmain()oftests/Graphics.cpp, where I kept main'sclipDistanceTests()andframebufferLayerTests()and then this PR'sUnwrittenSampleLocationTests().agc_driver_graphicspasses, and it fails again when theQueueState.hppline is removed.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T15:13:28Z.
Resident Evil Village (PPSA01556, 01.210.000) stops on the same line on
main, at its first presented frame, about 20 s in. Its register state is in #2776: the same single-sampleMSAA_ENABLEbranch as RE4, with all sixteen location registers unwritten. Setup: Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 3070 Laptop.With this PR's
QueueState.hppchange onmainb478fbbb1, the title gets past that frame. In seven runs of 90 to 300 s there was no0x2festop and no other presentation failure while the game created its PSO cache: 3,003 shaders in 300 s from a cold cache. I applied only that one line, because the PR's test intests/Graphics.cppnow conflicts withmain.