Repository navigation
fix(agc): draw without a pixel program when SPI_SHADER_PGM_PS is unset - #469
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
Thanks, the null program for depth-only passes makes sense to me. Two things I'd change. First, the register fallbacks now apply to every draw: with a real pixel shader, a bank without SPI_PS_INPUT_ENA/ADDR or SPI_SHADER_COL_FORMAT now gets PERSP_CENTER and no exports invented for it, instead of the "missing register" refusal that |
|
Test note from PPSA21567 (Astro Bot), on Linux with #426, main 870bdd8 and local changes (not clean main):
I have not checked how the hardware decides that these draws run without a pixel shader while the PS address register still holds a value (for example a disabled PS stage in another register). Happy to dump the registers of one of these draws if that helps. |
|
Thanks @ThisIsAkill for testing it. Your run shows the first point from my earlier comment in practice: those draws keep a real pixel program, the absent SPI_PS_INPUT_ENA/ADDR turn into PERSP_CENTER only, and the recompiler then refuses the program ( @Pacuka, both points from my earlier comment still apply to the current head: the fallbacks and the relaxed |
|
Here is the register dump, from a run before this PR was applied (the driver's dump of a draw it refused with
Two facts from it:
|
|
Thanks @ThisIsAkill, that settles it, and I was wrong about the address: it's the register's own value, so these draws do have a pixel program. It reads no user data (RSRC2_PS is 0) and exports nothing (CB_DISABLE, and CB_TARGET_MASK, CB_SHADER_MASK, SPI_SHADER_COL_FORMAT and SPI_SHADER_Z_FORMAT are all 0). That fits the no-colour-writes condition, but this PR's null path only applies when PGM_LO_PS is 0, so it never covers these draws, and the register fallbacks then apply to a real program, which was my first point. @Pacuka, both points from my earlier comment still apply to the current head. For draws like these, one way that stays exact: accept absent SPI_PS_INPUT_ENA/ADDR only when the recompiled program reads none of the pixel input VGPRs before writing them, since the input layout can't change its result then, and keep refusing otherwise. Swapping such a program for the null one wouldn't be exact in general, because a program that kills pixels (alpha-tested shadows) changes the depth result. A disassembly of the first instructions at that PS address would show whether these draws read any inputs. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efuse its color writes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7fe7c1e to
a48a9ea
Compare
|
Thanks both. Reworked in a48a9ea (rebased on main):
The Astro Bot draws (nonzero PS that reads no inputs and exports nothing) are out of scope here; accepting absent |
|
Thanks @Pacuka, this addresses my first point. With a real pixel program an absent SPI_PS_INPUT_ENA/ADDR or SPI_SHADER_COL_FORMAT is refused again, both in Two small notes, neither blocking:
Merged with current main (and the other open PRs I'm checking today) it builds, and The draws @ThisIsAkill dumped stay refused as on main (they have a real program), but depth-only draws with no pixel program now run, so I'll run it through my PPSA21564 check before merging. |
|
Gated on PPSA21564: no visual or FPS change. |
Takes upstream's merged versions of our boykopovar#586 boykopovar#611 boykopovar#612 boykopovar#505 boykopovar#490 boykopovar#619 boykopovar#503 boykopovar#627 boykopovar#628 boykopovar#618 and drops astrobot's local copies, plus gate-batch-3 (boykopovar#469 boykopovar#500 boykopovar#504 boykopovar#509 boykopovar#510 boykopovar#514 boykopovar#525 boykopovar#526 boykopovar#528), round o/p (boykopovar#617 boykopovar#620 boykopovar#621 boykopovar#622 boykopovar#623 boykopovar#624 boykopovar#501 boykopovar#508 boykopovar#629 boykopovar#630 boykopovar#631). Conflicts: - SpirvAnalysis.hpp/.cpp, SpirvBufferAccess.cpp: upstream's boykopovar#586/boykopovar#612. The 64-bit LDS atomics keep the full array (f27d6e5 no longer needed). - SpirvMemoryInstructions.cpp: upstream's constant slot plus offset; astrobot's split-wave append/consume kept. - GuestTextureResource.cpp, TextureTiling.cpp and their tests: upstream's boykopovar#490/boykopovar#503 (astrobot had no other change there). - MaskedSelect.cpp test, ShaderMemory.cpp LDS test: upstream's. - State.cpp: upstream's boykopovar#505 export count and boykopovar#469 null pixel program; astrobot's depth export rejection and depth target model kept. - Pipeline.cpp: upstream's pipeline key; astrobot's depth attachment and blend check (a trailing unused attachment stays valid, as colorGapPipelineTests expects). - Draw.cpp, Recorder.cpp, ShaderResources.cpp: astrobot's (renderPassKey with depth, moved sample functions, residency maintenance), which already hold the merged boykopovar#505/boykopovar#628/boykopovar#490 changes. - ShaderInputState.cpp: both register sets. - State.hpp: the duplicate exportIndex member from the auto-merge removed. - CMakeLists.txt: astrobot's test list (a superset of upstream's). - tests/Graphics.cpp: upstream's CompactedExportTests replaces astrobot's inline copy; tests/Recorder.cpp: upstream's viewPastLastMipTests added.
What
A depth-only pass (a depth prepass, shadow maps) leaves the pixel program address
SPI_SHADER_PGM_LO/HI_PSat 0. Such a pass often never writesSPI_PS_INPUT_ENA/ADDRorSPI_SHADER_COL_FORMATeither. On hardware this is valid: the rasterizer still writes depth. The driver refused these draws twice:DrawRejectionreturned "missing register at DWORD 0x1b3" (or 0x1b4/0x1c5) for a bank without the pixel input registers.decodeDrawfailed with "graphics program does not belong to a registered shader", because address 0 lies below every registered shader.With this change:
RegisterShaderalso registers a built-in pixel program, a lones_endpgmwith a minimal header.decodeDrawuses it whenSPI_SHADER_PGM_LO/HI_PSare both 0. IfSPI_SHADER_PGM_RSRC2_PSwas never written, it reads no user data for it.PixelProgramUnset/NullPixelProgramRejection(shared byDrawRejectionanddecodeDraw) refuse a PS address of 0 whenCB_TARGET_MASK & CB_SHADER_MASKis nonzero, since the Vulkan draw would leave those attachments undefined. Depth export is already refused byDrawRejection.DecodePixelStageInforeads an absentSPI_PS_INPUT_ENA/ADDRasPERSP_CENTER_ENA(the smallest input set the hardware accepts) and an absentSPI_SHADER_COL_FORMATas no colour exports. With a real pixel program an absent register is still amissing registerrefusal, inDrawRejectionand in the decode.DecodeStatereadsSPI_SHADER_COL_FORMATonly when a target is written; the format cannot matter otherwise.In The Smurfs Dreams (UE4) about 7,000 draws per 100 s were refused this way, plus 4,400 for the missing registers. These are the depth passes of the title screen and the levels.
Draws that keep a real pixel program which reads no inputs and exports nothing (the Astro Bot case in the comments) are not covered; accepting absent
SPI_PS_INPUT_ENA/ADDRthere when the recompiled program reads no input VGPRs would be a separate PR.Tested
agc_driver_graphicscovers a real pixel program withoutSPI_PS_INPUT_ENA/ADDR/SPI_SHADER_COL_FORMAT(refused asmissing register), PS = 0 with colour writes (refused), and PS = 0 depth-only (accepted,PERSP_CENTER_ENA, no colour exports,DecodeStatewithoutCOL_FORMAT). I found no harness that runs packets throughdecodeDraw, so the null-program decision lives in the shared helpers the test drives. Fullctest: 182 of 183 pass; the only failure isagc_driver_pixel_helper_lanes, which also fails onmainon this GPU.APS5_TRACE_SKIPS=1, both refusals were gone over 110 s from boot through the menus into a level load, with no new failures and no GPU faults. The rework (null-program-only fallbacks, no colour writes) is covered by the unit tests above.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code