fix(agc): start the context at its reset state for color targets and viewports #10420
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10420"
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 stuart-russell on 2026-10-23T23:40:32Z.
What
Start the AGC context at the values the hardware resets it to, so a title that never programs part of the state gets the state the console would.
CB_TARGET_MASK(0x8e) andCB_SHADER_MASK(0x8f) start at0xffffffff, the gfx10 clear-state reset values; aCLEAR_STATEpacket still applies the zeros the AGC default tables hold.PA_CL_VTE_CNTL(0x206) starts at 0, the reset value, where every viewport transform is disabled; a draw with that value gets a viewport covering its render target.0x43fkeeps the register-derived viewport, and any other value still throws. The interface check also accepts 0 indrawCoversand the draw rejection.SPI_SHADER_COL_FORMAT(0x1c5) entry of 0 (SPI_SHADER_ZERO) leaves its export without a color attachment instead of throwing.SPI_SHADER_POS_FORMAT(0x1c3) entry of 0 discards the primitive (no position export), which is recorded in the pipeline key and the journal, with the journalFileFormatbumped.0xffffffffregister offset in aSET_*_REGpacket or an indirect register list writes no register; the rest of the packet or list proceeds.VGT_SHADER_STAGES_ENwith every stage enable clear draws on the vertex path instead of throwing.DecodePixelStageInfotakes the input count from the shader header and throws on per-primitive inputs.DB_RENDER_CONTROL: the copy, resummarize and decompress bits change no modeled state when no depth or stencil plane is bound, and reserved bits 14 to 31 are ignored.APS5_TRACE_QUEUEreports queue order, the present result, a dispatch's shape and the presented display buffer; a recorder batch that outlives its fence reports its serial, fence status and the timeline value.References
cb_target_maskandcb_shader_maskat0xFFFFFFFFwhen it initialises its register tracking (drivers/gpu/drm/radeon/r600_cs.c,r600_cs_track_init), which is the hardware reset value for the masks.PA_CL_VTE_CNTLgates the viewport transform per axis; decaf-emu models the disabled case as the unscaled NDC path (src/libgpu/src/vulkan/vulkan_viewscissor.cpp), and xenia reads the same enables to derive its draw extent (src/xenia/gpu/draw_extent_estimator.cc).0x43fis the value that enables X, Y and Z scale and offset and leaves the XY format bit clear, which is the register-derived viewport this driver already builds.0x4000, so a0xffffffffoffset names no register; the title's trace contains such packets (recorded before the change, they threw).Tested
agc_driver_pm4andagc_driver_graphics(18 tests) pass, andtools/check_conventions.py --base origin/mainpasses, on the rebased tree.A Windows build of these changes (MinGW cross-build, NVIDIA RTX 3070, driver 32.0.15.9186, Windows 11) ran PPSA30528, which previously produced a black window, to its loading screen with audio. That run was made before the rebase onto the current
main; the merged tree has not been re-run against a title yet.VK_LAYER_KHRONOS_validationis not installed on the Linux test machine (/usr/share/vulkan/explicit_layer.dis absent), so theANYPS5_REQUIRE_VULKAN=1comparison onmainand on this branch has not been run yet.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T23:41:16Z.
Review: CHANGES_REQUESTED
I found one hot-path issue in the shader-use instrumentation. The rest of the broad state-reset changes need the pending AGC build/test checks before a full review.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T01:06:47Z.
Review: CHANGES_REQUESTED
Thanks for the work and the write-up. This needs splitting and a few fixes before it can be merged.
CB_TARGET_MASK/CB_SHADER_MASK/PA_CL_VTE_CNTL, zero export formats, the0xffffffffregister sentinel, rasterizer discard, legacy vertex routing, pixel input counts from the shader header,DB_RENDER_CONTROL, pipeline cache after device loss, present synchronisation, and the PM4-ring/trace diagnostics. Please send each behaviour change as its own PR with its own test and its own reference.rasterizerDiscardwhenSPI_SHADER_POS_FORMATis 0 (Graphics/src/State.cpp:1491, new pipeline/journal key fields,FileFormatbump), legacy vertex routing now accepted (State.cpp:1169),DecodePixelStageInfotaking the input count from the shader header and throwing on per-primitive inputs (Graphics/src/ShaderInputState.cpp:110-127), and the DeviceFault retry loop (DeviceFault.hpp:58).VulkanDevice.cpp:3636,:3763): the blit andvkQueuePresentKHRbeing on one queue does not order the presentation engine's read of the image after the blit. Present must wait on a semaphore signalled by the submit. Please keep it, or show why it is safe on every driver.std::getenv("APS5_TRACE_QUEUE")is called on every dispatch (Dispatch.cpp:440), present (VulkanDevice.cpp:3641,:3768); make themstatic const boollike the neighbouring ones. The ~1.4 KB[discard-trace]format string inDrawCapture.cpp:33and the 256-entry shader-use ring taking a mutex on every draw (SubmissionRing.cpp:310) are debugging aids and should not ship in this fix. MarcZX10's change request on the shader-use instrumentation is still open.Recorder.cpp:4090printssubmissionstwice in the same message.CB_TARGET_MASK/CB_SHADER_MASKreset to0xffffffff, whatPA_CL_VTE_CNTL == 0means for a draw, and what the0xfffffffflist entry does on hardware: cite the reference (KytyPS5/prosper/gfx10 docs) or a measurement in the PR, and add the matching lines todocs/dev/debt/libSceAgcDriver.mdfor what stays inferred.mainand on the change withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and a comparison showing no newVUID-errors. "GPUs tested: n/a" is not right for this PR. The title run was before the rebase; please name the title/PPSA and re-run it on the current tree.You are welcome to reopen/resubmit the pieces with these addressed.
Pull request closed