fix(agc): draw without a pixel program when SPI_SHADER_PGM_PS is unset #469

Merged
Pacuka merged 2 commits from upstream-pr/469 into main 2026-10-05 08:36:35 +00:00
Pacuka commented 2026-10-03 16:19:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-03T16:19:53Z.


What

A depth-only pass (a depth prepass, shadow maps) leaves the pixel program address SPI_SHADER_PGM_LO/HI_PS at 0. Such a pass often never writes SPI_PS_INPUT_ENA/ADDR or SPI_SHADER_COL_FORMAT either. On hardware this is valid: the rasterizer still writes depth. The driver refused these draws twice:

  • DrawRejection returned "missing register at DWORD 0x1b3" (or 0x1b4/0x1c5) for a bank without the pixel input registers.
  • decodeDraw failed with "graphics program does not belong to a registered shader", because address 0 lies below every registered shader.

With this change:

  • RegisterShader also registers a built-in pixel program, a lone s_endpgm with a minimal header. decodeDraw uses it when SPI_SHADER_PGM_LO/HI_PS are both 0. If SPI_SHADER_PGM_RSRC2_PS was never written, it reads no user data for it.
  • The null path only takes draws that write no colour: PixelProgramUnset / NullPixelProgramRejection (shared by DrawRejection and decodeDraw) refuse a PS address of 0 when CB_TARGET_MASK & CB_SHADER_MASK is nonzero, since the Vulkan draw would leave those attachments undefined. Depth export is already refused by DrawRejection.
  • Only for the null program, DecodePixelStageInfo reads an absent SPI_PS_INPUT_ENA/ADDR as PERSP_CENTER_ENA (the smallest input set the hardware accepts) and an absent SPI_SHADER_COL_FORMAT as no colour exports. With a real pixel program an absent register is still a missing register refusal, in DrawRejection and in the decode.
  • DecodeState reads SPI_SHADER_COL_FORMAT only 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/ADDR there when the recompiled program reads no input VGPRs would be a separate PR.

Tested

  • Linux (CachyOS, RX 6650 XT): agc_driver_graphics covers a real pixel program without SPI_PS_INPUT_ENA/ADDR/SPI_SHADER_COL_FORMAT (refused as missing register), PS = 0 with colour writes (refused), and PS = 0 depth-only (accepted, PERSP_CENTER_ENA, no colour exports, DecodeState without COL_FORMAT). I found no harness that runs packets through decodeDraw, so the null-program decision lives in the shared helpers the test drives. Full ctest: 182 of 183 pass; the only failure is agc_driver_pixel_helper_lanes, which also fails on main on this GPU.
  • The Smurfs Dreams (first revision): with 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

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4727957510 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-03T16:19:53Z. --- ### What A depth-only pass (a depth prepass, shadow maps) leaves the pixel program address `SPI_SHADER_PGM_LO/HI_PS` at 0. Such a pass often never writes `SPI_PS_INPUT_ENA`/`ADDR` or `SPI_SHADER_COL_FORMAT` either. On hardware this is valid: the rasterizer still writes depth. The driver refused these draws twice: - `DrawRejection` returned "missing register at DWORD 0x1b3" (or 0x1b4/0x1c5) for a bank without the pixel input registers. - `decodeDraw` failed with "graphics program does not belong to a registered shader", because address 0 lies below every registered shader. With this change: - `RegisterShader` also registers a built-in pixel program, a lone `s_endpgm` with a minimal header. `decodeDraw` uses it when `SPI_SHADER_PGM_LO/HI_PS` are both 0. If `SPI_SHADER_PGM_RSRC2_PS` was never written, it reads no user data for it. - The null path only takes draws that write no colour: `PixelProgramUnset` / `NullPixelProgramRejection` (shared by `DrawRejection` and `decodeDraw`) refuse a PS address of 0 when `CB_TARGET_MASK & CB_SHADER_MASK` is nonzero, since the Vulkan draw would leave those attachments undefined. Depth export is already refused by `DrawRejection`. - Only for the null program, `DecodePixelStageInfo` reads an absent `SPI_PS_INPUT_ENA`/`ADDR` as `PERSP_CENTER_ENA` (the smallest input set the hardware accepts) and an absent `SPI_SHADER_COL_FORMAT` as no colour exports. With a real pixel program an absent register is still a `missing register` refusal, in `DrawRejection` and in the decode. - `DecodeState` reads `SPI_SHADER_COL_FORMAT` only 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/ADDR` there when the recompiled program reads no input VGPRs would be a separate PR. ### Tested - Linux (CachyOS, RX 6650 XT): `agc_driver_graphics` covers a real pixel program without `SPI_PS_INPUT_ENA`/`ADDR`/`SPI_SHADER_COL_FORMAT` (refused as `missing register`), PS = 0 with colour writes (refused), and PS = 0 depth-only (accepted, `PERSP_CENTER_ENA`, no colour exports, `DecodeState` without `COL_FORMAT`). I found no harness that runs packets through `decodeDraw`, so the null-program decision lives in the shared helpers the test drives. Full `ctest`: 182 of 183 pass; the only failure is `agc_driver_pixel_helper_lanes`, which also fails on `main` on this GPU. - The Smurfs Dreams (first revision): with `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 - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-03 19:51:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-03T19:51:38Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#295 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L518-519, L778-780
#375 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L518-519, L778-780
#423 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L518-519, L778-780
#473 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L109
#494 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp L24-27
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5972887535 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5972887535). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-03T19:51:38Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #295 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L518-519](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L518-L519), [L778-780](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L778-L780) | | | | #375 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L518-519](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L518-L519), [L778-780](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L778-L780) | | | | #423 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L518-519](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L518-L519), [L778-780](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L778-L780) | | | | #473 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` [L109](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L109) | | | | #494 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp` [L24-27](https://github.com/boykopovar/AnyPS5/blob/698c23d81e6301f8377206434b68706514bc54e3/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp#L24-L27) | | |
oneandonlydean commented 2026-10-04 05:45:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:45:59Z.


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 DrawRejection gave. Could the fallbacks (and the relaxed DrawRejection check) apply only when the program is the built-in null one? Second, the null program is taken whenever the PS address is 0, even if the draw has colour writes enabled (CB_TARGET_MASK & CB_SHADER_MASK). In that case the Vulkan draw leaves the colour attachments undefined, since the fragment shader never writes them. Requiring no colour writes for the null path (and refusing otherwise) keeps it exact and still covers depth prepasses and shadow maps; depth export is already refused by DrawRejection, so that side is covered. A small test that drives decodeDraw with PGM_LO_PS = 0 would also help, if a harness can be found.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5977041495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5977041495). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T05:45:59Z. --- 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 `DrawRejection` gave. Could the fallbacks (and the relaxed `DrawRejection` check) apply only when the program is the built-in null one? Second, the null program is taken whenever the PS address is 0, even if the draw has colour writes enabled (CB_TARGET_MASK & CB_SHADER_MASK). In that case the Vulkan draw leaves the colour attachments undefined, since the fragment shader never writes them. Requiring no colour writes for the null path (and refusing otherwise) keeps it exact and still covers depth prepasses and shadow maps; depth export is already refused by `DrawRejection`, so that side is covered. A small test that drives `decodeDraw` with PGM_LO_PS = 0 would also help, if a harness can be found.
ThisIsAkill commented 2026-10-04 07:02:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-04T07:02:52Z.


Test note from PPSA21567 (Astro Bot), on Linux with #426, main 870bdd81 and local changes (not clean main):

  • Before this PR, the title's only remaining skip was missing register at DWORD 0x1b3 on depth-only draws (no color target: a 1536x1536 shadow pass and a 2432x1368 depth prepass).
  • With this PR, that skip is gone, but those draws now fail recompilation: ShaderRecompiler::Recompile: shader info collection failed: interpolation parameter reference is out of range, 1105 reports in a 9-minute run.
  • The reason seems to be that in these draws SPI_SHADER_PGM_LO/HI_PS is not 0. A local trace shows pixel program addresses 0x500893a00 (a real registered program) and 0x5600a9ce4000 (which looks like a stale or unrelated value). So the null-program path is not taken: the draw keeps a real pixel program, and the absent SPI_PS_INPUT_ENA/ADDR read as PERSP_CENTER_ENA only, which that program's interpolation does not fit.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5977537401 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5977537401). Originally posted by [ThisIsAkill](https://github.com/ThisIsAkill) on 2026-10-04T07:02:52Z. --- Test note from PPSA21567 (Astro Bot), on Linux with #426, main 870bdd81 and local changes (not clean main): - Before this PR, the title's only remaining skip was `missing register at DWORD 0x1b3` on depth-only draws (no color target: a 1536x1536 shadow pass and a 2432x1368 depth prepass). - With this PR, that skip is gone, but those draws now fail recompilation: `ShaderRecompiler::Recompile: shader info collection failed: interpolation parameter reference is out of range`, 1105 reports in a 9-minute run. - The reason seems to be that in these draws `SPI_SHADER_PGM_LO/HI_PS` is **not** 0. A local trace shows pixel program addresses 0x500893a00 (a real registered program) and 0x5600a9ce4000 (which looks like a stale or unrelated value). So the null-program path is not taken: the draw keeps a real pixel program, and the absent `SPI_PS_INPUT_ENA`/`ADDR` read as `PERSP_CENTER_ENA` only, which that program's interpolation does not fit. 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.
oneandonlydean commented 2026-10-04 07:39:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T07:39:56Z.


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 (interpolation parameter reference is out of range). So the clear missing register refusal becomes a recompile failure on every such draw, and a program that happened to read only PERSP_CENTER would draw with invented inputs instead of failing. One thing about the trace: 0x5600a9ce4000 is not a guest address, so it may be the PR's own NullPixelCode after the substitution in decodeDraw rather than a stale register value. If so, the draws with PS = 0 are handled and only the ones at 0x500893a00 fail.

@Pacuka, both points from my earlier comment still apply to the current head: the fallbacks and the relaxed DrawRejection check should only apply to the built-in null program, and the null path should require no colour writes (CB_TARGET_MASK & CB_SHADER_MASK). The failing draws in that note have a nonzero PGM_LO_PS, so this PR can't cover them as it stands; running them without SPI_PS_INPUT_ENA/ADDR would need evidence of what the hardware does with that pixel program. A register dump of one of those draws, as ThisIsAkill offered (CB_COLOR_CONTROL, CB_TARGET_MASK, CB_SHADER_MASK, DB_SHADER_CONTROL, SPI_SHADER_Z_FORMAT, SPI_PS_IN_CONTROL and SPI_SHADER_PGM_LO/HI_PS), would be a good start.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5977779535 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5977779535). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T07:39:56Z. --- 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 (`interpolation parameter reference is out of range`). So the clear `missing register` refusal becomes a recompile failure on every such draw, and a program that happened to read only PERSP_CENTER would draw with invented inputs instead of failing. One thing about the trace: 0x5600a9ce4000 is not a guest address, so it may be the PR's own `NullPixelCode` after the substitution in `decodeDraw` rather than a stale register value. If so, the draws with PS = 0 are handled and only the ones at 0x500893a00 fail. @Pacuka, both points from my earlier comment still apply to the current head: the fallbacks and the relaxed `DrawRejection` check should only apply to the built-in null program, and the null path should require no colour writes (CB_TARGET_MASK & CB_SHADER_MASK). The failing draws in that note have a nonzero PGM_LO_PS, so this PR can't cover them as it stands; running them without SPI_PS_INPUT_ENA/ADDR would need evidence of what the hardware does with that pixel program. A register dump of one of those draws, as ThisIsAkill offered (CB_COLOR_CONTROL, CB_TARGET_MASK, CB_SHADER_MASK, DB_SHADER_CONTROL, SPI_SHADER_Z_FORMAT, SPI_PS_IN_CONTROL and SPI_SHADER_PGM_LO/HI_PS), would be a good start.
ThisIsAkill commented 2026-10-04 09:02:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThisIsAkill on 2026-10-04T09:02:18Z.


Here is the register dump, from a run before this PR was applied (the driver's dump of a draw it refused with missing register at DWORD 0x1b3, PPSA21567):

Register Value
SPI_SHADER_PGM_LO_PS / HI_PS (SH 0x008 / 0x009) 0xdf16f800 / 0x00000055 -> address 0x55df16f80000
SPI_SHADER_PGM_RSRC1_PS / RSRC2_PS (SH 0x00a / 0x00b) 0x022c0000 / 0x00000000
CB_COLOR_CONTROL (0x202) 0x00cc0000 (MODE 0 = CB_DISABLE, ROP3 0xcc)
CB_TARGET_MASK (0x08e) 0x00000000
CB_SHADER_MASK (0x08f) 0x00000000
DB_SHADER_CONTROL (0x203) 0x00000000
SPI_SHADER_Z_FORMAT (0x1c4) 0x00000000
SPI_PS_IN_CONTROL (0x1b6) 0x00000000
SPI_SHADER_COL_FORMAT (0x1c5) 0x00000000
SPI_PS_INPUT_ENA / ADDR (0x1b3 / 0x1b4) absent

Two facts from it:

  • The odd address is the register's own content, not the PR's NullPixelCode. This dump predates the PR, and SPI_SHADER_PGM_LO/HI_PS themselves give 0x55df16f80000. The 0x5600a9ce4000 in my earlier note is the same kind of value from another run (ASLR). In this relinked native process, 0x55... addresses lie in the executable's own image or heap, not in registered guest shader memory. I haven't checked what is at that address.
  • The draw writes no colour: CB_COLOR_CONTROL MODE is CB_DISABLE, and CB_TARGET_MASK, CB_SHADER_MASK and SPI_SHADER_COL_FORMAT are all 0. So it fits the "no colour writes" condition for the null path, but the PS address is nonzero.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5978339865 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5978339865). Originally posted by [ThisIsAkill](https://github.com/ThisIsAkill) on 2026-10-04T09:02:18Z. --- Here is the register dump, from a run before this PR was applied (the driver's dump of a draw it refused with `missing register at DWORD 0x1b3`, PPSA21567): | Register | Value | |---|---| | `SPI_SHADER_PGM_LO_PS` / `HI_PS` (SH 0x008 / 0x009) | `0xdf16f800` / `0x00000055` -> address `0x55df16f80000` | | `SPI_SHADER_PGM_RSRC1_PS` / `RSRC2_PS` (SH 0x00a / 0x00b) | `0x022c0000` / `0x00000000` | | `CB_COLOR_CONTROL` (0x202) | `0x00cc0000` (MODE 0 = `CB_DISABLE`, ROP3 0xcc) | | `CB_TARGET_MASK` (0x08e) | `0x00000000` | | `CB_SHADER_MASK` (0x08f) | `0x00000000` | | `DB_SHADER_CONTROL` (0x203) | `0x00000000` | | `SPI_SHADER_Z_FORMAT` (0x1c4) | `0x00000000` | | `SPI_PS_IN_CONTROL` (0x1b6) | `0x00000000` | | `SPI_SHADER_COL_FORMAT` (0x1c5) | `0x00000000` | | `SPI_PS_INPUT_ENA` / `ADDR` (0x1b3 / 0x1b4) | absent | Two facts from it: - **The odd address is the register's own content, not the PR's `NullPixelCode`.** This dump predates the PR, and `SPI_SHADER_PGM_LO/HI_PS` themselves give `0x55df16f80000`. The `0x5600a9ce4000` in my earlier note is the same kind of value from another run (ASLR). In this relinked native process, `0x55...` addresses lie in the executable's own image or heap, not in registered guest shader memory. I haven't checked what is at that address. - **The draw writes no colour:** `CB_COLOR_CONTROL` MODE is `CB_DISABLE`, and `CB_TARGET_MASK`, `CB_SHADER_MASK` and `SPI_SHADER_COL_FORMAT` are all 0. So it fits the "no colour writes" condition for the null path, but the PS address is nonzero.
oneandonlydean commented 2026-10-04 09:52:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T09:52:27Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5978695239 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5978695239). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T09:52:27Z. --- 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.
Pacuka commented 2026-10-04 18:57:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-04T18:57:52Z.


Thanks both. Reworked in a48a9eab (rebased on main):

  • The SPI_PS_INPUT_ENA/ADDR and SPI_SHADER_COL_FORMAT fallbacks now apply only to the built-in null program (DecodePixelStageInfo(..., nullProgram)); with a real pixel program an absent register is a missing register refusal again, and DrawRejection keeps that check.
  • The null path requires no colour writes: PixelProgramUnset / NullPixelProgramRejection (shared by DrawRejection and decodeDraw) refuse a PS address of 0 when CB_TARGET_MASK & CB_SHADER_MASK is nonzero ("a draw without a pixel program writes color").
  • DecodeState reads SPI_SHADER_COL_FORMAT only when a target is written, since the format cannot matter otherwise.
  • Tests cover a real program without the registers (refused), PS = 0 with colour writes (refused), and PS = 0 depth-only (accepted, PERSP_CENTER, no exports, no COL_FORMAT needed). I didn't find a harness that runs packets through decodeDraw, so the decision lives in the shared helpers the test drives.

The Astro Bot draws (nonzero PS that reads no inputs and exports nothing) are out of scope here; accepting absent SPI_PS_INPUT_ENA/ADDR when the recompiled program reads no input VGPRs would be a separate PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5983305102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5983305102). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-04T18:57:52Z. --- Thanks both. Reworked in a48a9eab (rebased on main): - The `SPI_PS_INPUT_ENA/ADDR` and `SPI_SHADER_COL_FORMAT` fallbacks now apply only to the built-in null program (`DecodePixelStageInfo(..., nullProgram)`); with a real pixel program an absent register is a `missing register` refusal again, and `DrawRejection` keeps that check. - The null path requires no colour writes: `PixelProgramUnset` / `NullPixelProgramRejection` (shared by `DrawRejection` and `decodeDraw`) refuse a PS address of 0 when `CB_TARGET_MASK & CB_SHADER_MASK` is nonzero ("a draw without a pixel program writes color"). - `DecodeState` reads `SPI_SHADER_COL_FORMAT` only when a target is written, since the format cannot matter otherwise. - Tests cover a real program without the registers (refused), PS = 0 with colour writes (refused), and PS = 0 depth-only (accepted, PERSP_CENTER, no exports, no `COL_FORMAT` needed). I didn't find a harness that runs packets through `decodeDraw`, so the decision lives in the shared helpers the test drives. The Astro Bot draws (nonzero PS that reads no inputs and exports nothing) are out of scope here; accepting absent `SPI_PS_INPUT_ENA/ADDR` when the recompiled program reads no input VGPRs would be a separate PR.
oneandonlydean commented 2026-10-04 22:38:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:38:06Z.


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 DrawRejection and in DecodePixelStageInfo, and the PERSP_CENTER default is now limited to the built-in null program. The null path also refuses colour writes (CB_TARGET_MASK & CB_SHADER_MASK), which was the other condition for swapping in a program that exports nothing. The tests cover the three cases.

Two small notes, neither blocking:

  • DecodeState now reads SPI_SHADER_COL_FORMAT only when a target is written, but DrawRejection still refuses a real program whose COL_FORMAT is absent even when no target is written. Both refuse safely, so this only matters if you want the two to agree; the comment above DrawRejection ("a register a rule needs that is absent is no verdict here") also no longer holds for the three registers it now checks.
  • This conflicts with #473 in ShaderRegistry.cpp (both edit RegisterShader), so whichever lands second needs a small rebase.

Merged with current main (and the other open PRs I'm checking today) it builds, and agc_driver_graphics passes, including your three new cases.

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5985219782 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5985219782). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T22:38:06Z. --- 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 `DrawRejection` and in `DecodePixelStageInfo`, and the PERSP_CENTER default is now limited to the built-in null program. The null path also refuses colour writes (`CB_TARGET_MASK & CB_SHADER_MASK`), which was the other condition for swapping in a program that exports nothing. The tests cover the three cases. Two small notes, neither blocking: - `DecodeState` now reads SPI_SHADER_COL_FORMAT only when a target is written, but `DrawRejection` still refuses a real program whose COL_FORMAT is absent even when no target is written. Both refuse safely, so this only matters if you want the two to agree; the comment above `DrawRejection` ("a register a rule needs that is absent is no verdict here") also no longer holds for the three registers it now checks. - This conflicts with #473 in `ShaderRegistry.cpp` (both edit `RegisterShader`), so whichever lands second needs a small rebase. Merged with current main (and the other open PRs I'm checking today) it builds, and `agc_driver_graphics` passes, including your three new cases. 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.
oneandonlydean commented 2026-10-05 08:31:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T08:31:14Z.


Gated on PPSA21564: no visual or FPS change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5990920466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/469#issuecomment-5990920466). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-05T08:31:14Z. --- Gated on PPSA21564: no visual or FPS change.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!469
No description provided.