fix(shader): pass pass-through pixel inputs through rect-list draws #22052

Merged
milescoviello merged 1 commit from upstream-pr/22052 into main 2026-11-19 09:19:46 +00:00
milescoviello commented 2026-11-17 03:08:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-17T03:08:55Z.


What

Update 11-18: since #20827 merged, Borderlands 4 and MXGP 26 no longer reach this refusal on main (7a46b9fef): their draws now log only "preparing it at draw", and both run past their old stops without this PR (BL4, MXGP). The refusal itself is unchanged on main, so this change still matters for any draw that reaches it, such as PPSA28099 (edubox, below). The BL4 and MXGP results under Tested are from before #20827.

BuildRectListShaders refused every pixel input with custom (pass-through) interpolation (SPI_PS_INPUT_CNTL OFFSET bit 5 with FLAT_SHADE, 0x420) with Rect-list SPIR-V: custom per-vertex interpolation is unsupported. A rect-list draw whose pixel shader reads one ends the title. On main this is how MXGP 26 (PPSA30839) and Borderlands 4 (PPSA01494) stop (see Tested). Forspoken (PPSA03984) defers 11 pixel shaders at pipeline creation for the same reason.

f5ae0b8106 kept the refusal for these inputs because "their fourth vertex has no value of its own". The generated stages already give each kind of read what it needs:

  • Read only at P0 (flat + custom, after host interpolation): the input is flat, and the control stage passes the first vertex's value to all four corners. That is the rectangle's vertex 0 over the whole rectangle. The pipeline still refuses the last provoking vertex for these inputs (Pipeline.cpp), so lastVertexControl never serves them.
  • Read per vertex with emulated barycentrics: the input goes through emulation.perVertex. Every corner carries the rectangle's three vertices, and the barycentrics are relative to them, so the reads see the three original vertices beyond the diagonal too.
  • Read per vertex natively (VK_KHR_fragment_shader_barycentric, as on NVIDIA and RADV): the input is passed like an explicitly interpolated one. The fragment shader sees the corners of the generated triangles, the fourth being the linear extrapolation of the other three. Any affine combination of the three values with the barycentrics the shader reads lands on the rectangle's plane, and that is what interpolation computes. A shader that uses one vertex's value on its own can see a different corner on one of the two triangles; that is the debt entry below.

What this changes

  • The require(!input.custom, ...) in BuildRectListShaders is removed. Custom inputs take the existing flat, emulated and native paths unchanged.
  • APS5_NO_FRAGMENT_SHADER_BARYCENTRIC (new, VulkanDevice.cpp, listed in docs/dev/ENVIRONMENT.md) leaves VK_KHR_fragment_shader_barycentric unused, as on a device without it. agc_driver_prepared_shaders --abi-deferred-rectangle-pairs used the removed refusal as its pair that the pipeline ABI cannot build. It now reads an unexported parameter per vertex and sets the switch, so the emulated path refuses it (an emulated per-vertex parameter is not exported by the vertex shader) on every device. The switch can also put a title on the emulated path to compare the two.
  • Debt fragment: native per-vertex inputs of rect-list draws (shader, Functional).

Tested

Linux (Ubuntu 26.04.1), GCC 15.2, Release, RTX 4070 Ti (NVIDIA 615.71.09).

  • agc_driver_pixel_barycentric_emulation, new rect-list pass-through cases, checked pixel by pixel over the whole rectangle including past its diagonal:
    • emulated, P10/P20/P0 of x and of y: the three vertices' raw values;
    • read only at P0: the first vertex's (x, y);
    • native per-vertex: P0 + I(P1 − P0) + J(P2 − P0) built from the raw values equals the interpolated value.
  • agc_driver_graphics rectListTests: a pass-through input read per vertex builds the same control and evaluation SPIR-V as an explicitly interpolated one.
  • agc_driver_prepared_shaders --abi-deferred-rectangle-pairs defers its pair once with the builder's reason, as before.
  • Negative control: main's RectListShaders.cpp with the new tests fails both (Rect-list SPIR-V: custom per-vertex interpolation is unsupported).
  • 38 ctest entries matching the prepared-shader, pixel-barycentric, graphics, provoking-vertex, prepared-publication and rect-list tests pass, and the three changed ones pass 3 times each on the final code.
  • Title A/B, release libs, scripted presses on :0, 360 s per run: main 8332b52dbf against this branch 3c1d4b7863 (main plus this commit).
title main 8332b52dbf (1 run) this branch 3c1d4b7863 (2 runs)
Borderlands 4 (PPSA01494) stops at 53 s on the refusal, right after the Borderlands logo animation runs the full 362 s both times (2,062 and 2,701 presents) with no driver failures: the middleware logo screen draws, then the dark screen that follows it
MXGP 26 (PPSA30839), APS5_NET_DISCONNECTED=1 stops at 13 s on the refusal, before its first frame dump runs the full 361-362 s both times (1,139 and 1,602 presents) with no driver failures, to the MyNacon welcome screen (it waits for a held Square)
  • Earlier main runs stopped the same way: BL4 at 81 s on 459f4f8c22, MXGP at 24 s on 133feb30f0.

  • MXGP's screens are upside down on this branch, as its loading screen is on main before the stop. That is the #16053 start-value regression #20827 addresses, and it is unrelated to this change. For MXGP, #20827 alone ran 180 s to the gamma-calibration menu without reaching a refused draw; why the start values change that is not known.

  • BL4 with #20827 as well (added 11-16, 8:40 PM PT):

    • With this branch and #20827 merged onto main b412486d3e (47aed6fbad), BL4 reaches its first-run Accessibility screen fully drawn in 2 of 3 runs; the other ended at UE's RenderThread watchdog during the logo (196 s).
    • With this branch alone, the same screen draws only faint outlines (4 runs, 362-902 s). So the missing UI is #16053's start values, which #20827 restores.
    • #20827 alone does not get BL4 past the stop: in its run, BL4 hung during the logo (174 s) before reaching the middleware screen.
    • Frames: release bl4-22052-20827-ab.
  • Contact sheets: release rectlist-passthrough-ab-8332b52dbf.

  • 3c1d4b7863 is this PR's code before the debt fragment was added; the pushed head differs from it only in docs/dev/debt/changes.

  • maskym's Windows + NVIDIA run of 58250e9185 merged into main e069a7562f (Windows 11, i7-12700K, RTX 2070 SUPER, WinLibs GCC 15.2.0, Release, Khronos validation layer 1.4.366): the agc, guest_video_out, video_out and pad_sdl tests pass 2050 of 2054 on both main and this PR with the same set of VUID- messages, the tests this PR adds or changes pass, and the three failures also fail on main there.

  • git merge-tree against main is clean. #17022 (rect-list layer forwarding) merges with this branch without conflicts.

  • tools/check_conventions.py passes on the branch and this body. tools/debt_fold.py --check reports nothing for this fragment. main (edb21febfa) itself fails the check on two LibreSSL3 fragments that change the same entry (libressl3-20171-inventory.md, feat-libressl3-evp-pkey-new-mac-key-v2.md); with that pair set aside, the check passes.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: PPSA28099, validated in-game on this head by edubox (https://github.com/boykopovar/AnyPS5/pull/22052#issuecomment-6958490963). PPSA01494 and PPSA30839 got past this stop on main 8332b52dbf with this PR (see Tested), but since #20827 they no longer reach it on main.
  • GPUs tested: NVIDIA RTX 4070 Ti (615.71.09), Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5349782574 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22052). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-17T03:08:55Z. --- ### What **Update 11-18:** since #20827 merged, Borderlands 4 and MXGP 26 no longer reach this refusal on `main` (7a46b9fef): their draws now log only "preparing it at draw", and both run past their old stops without this PR ([BL4](https://github.com/boykopovar/AnyPS5/discussions/16803#discussioncomment-19726315), [MXGP](https://github.com/boykopovar/AnyPS5/discussions/9725#discussioncomment-19726056)). The refusal itself is unchanged on `main`, so this change still matters for any draw that reaches it, such as PPSA28099 (edubox, below). The BL4 and MXGP results under Tested are from before #20827. `BuildRectListShaders` refused every pixel input with custom (pass-through) interpolation (`SPI_PS_INPUT_CNTL` `OFFSET` bit 5 with `FLAT_SHADE`, `0x420`) with `Rect-list SPIR-V: custom per-vertex interpolation is unsupported`. A rect-list draw whose pixel shader reads one ends the title. On `main` this is how MXGP 26 (PPSA30839) and Borderlands 4 (PPSA01494) stop (see Tested). Forspoken (PPSA03984) defers 11 pixel shaders at pipeline creation for the same reason. f5ae0b8106 kept the refusal for these inputs because "their fourth vertex has no value of its own". The generated stages already give each kind of read what it needs: - **Read only at P0** (`flat` + `custom`, after host interpolation): the input is flat, and the control stage passes the first vertex's value to all four corners. That is the rectangle's vertex 0 over the whole rectangle. The pipeline still refuses the last provoking vertex for these inputs (`Pipeline.cpp`), so `lastVertexControl` never serves them. - **Read per vertex with emulated barycentrics**: the input goes through `emulation.perVertex`. Every corner carries the rectangle's three vertices, and the barycentrics are relative to them, so the reads see the three original vertices beyond the diagonal too. - **Read per vertex natively** (VK_KHR_fragment_shader_barycentric, as on NVIDIA and RADV): the input is passed like an explicitly interpolated one. The fragment shader sees the corners of the generated triangles, the fourth being the linear extrapolation of the other three. Any affine combination of the three values with the barycentrics the shader reads lands on the rectangle's plane, and that is what interpolation computes. A shader that uses one vertex's value on its own can see a different corner on one of the two triangles; that is the debt entry below. **What this changes** - The `require(!input.custom, ...)` in `BuildRectListShaders` is removed. Custom inputs take the existing flat, emulated and native paths unchanged. - `APS5_NO_FRAGMENT_SHADER_BARYCENTRIC` (new, `VulkanDevice.cpp`, listed in `docs/dev/ENVIRONMENT.md`) leaves VK_KHR_fragment_shader_barycentric unused, as on a device without it. `agc_driver_prepared_shaders --abi-deferred-rectangle-pairs` used the removed refusal as its pair that the pipeline ABI cannot build. It now reads an unexported parameter per vertex and sets the switch, so the emulated path refuses it (`an emulated per-vertex parameter is not exported by the vertex shader`) on every device. The switch can also put a title on the emulated path to compare the two. - Debt fragment: native per-vertex inputs of rect-list draws (shader, Functional). ### Tested Linux (Ubuntu 26.04.1), GCC 15.2, Release, RTX 4070 Ti (NVIDIA 615.71.09). - `agc_driver_pixel_barycentric_emulation`, new rect-list pass-through cases, checked pixel by pixel over the whole rectangle including past its diagonal: - emulated, P10/P20/P0 of x and of y: the three vertices' raw values; - read only at P0: the first vertex's (x, y); - native per-vertex: P0 + I(P1 − P0) + J(P2 − P0) built from the raw values equals the interpolated value. - `agc_driver_graphics` `rectListTests`: a pass-through input read per vertex builds the same control and evaluation SPIR-V as an explicitly interpolated one. - `agc_driver_prepared_shaders --abi-deferred-rectangle-pairs` defers its pair once with the builder's reason, as before. - Negative control: `main`'s `RectListShaders.cpp` with the new tests fails both (`Rect-list SPIR-V: custom per-vertex interpolation is unsupported`). - 38 ctest entries matching the prepared-shader, pixel-barycentric, graphics, provoking-vertex, prepared-publication and rect-list tests pass, and the three changed ones pass 3 times each on the final code. - Title A/B, release libs, scripted presses on `:0`, 360 s per run: `main` 8332b52dbf against this branch 3c1d4b7863 (`main` plus this commit). | title | `main` 8332b52dbf (1 run) | this branch 3c1d4b7863 (2 runs) | |---|---|---| | Borderlands 4 (PPSA01494) | stops at 53 s on the refusal, right after the Borderlands logo animation | runs the full 362 s both times (2,062 and 2,701 presents) with no driver failures: the middleware logo screen draws, then the dark screen that follows it | | MXGP 26 (PPSA30839), `APS5_NET_DISCONNECTED=1` | stops at 13 s on the refusal, before its first frame dump | runs the full 361-362 s both times (1,139 and 1,602 presents) with no driver failures, to the MyNacon welcome screen (it waits for a held Square) | - Earlier `main` runs stopped the same way: BL4 at 81 s on 459f4f8c22, MXGP at 24 s on 133feb30f0. - MXGP's screens are upside down on this branch, as its loading screen is on `main` before the stop. That is the #16053 start-value regression #20827 addresses, and it is unrelated to this change. For MXGP, #20827 alone ran 180 s to the gamma-calibration menu without reaching a refused draw; why the start values change that is not known. - **BL4 with #20827 as well (added 11-16, 8:40 PM PT):** - With this branch and #20827 merged onto `main` b412486d3e (47aed6fbad), BL4 reaches its first-run Accessibility screen fully drawn in 2 of 3 runs; the other ended at UE's RenderThread watchdog during the logo (196 s). - With this branch alone, the same screen draws only faint outlines (4 runs, 362-902 s). So the missing UI is #16053's start values, which #20827 restores. - #20827 alone does not get BL4 past the stop: in its run, BL4 hung during the logo (174 s) before reaching the middleware screen. - Frames: [release bl4-22052-20827-ab](https://github.com/milescoviello/AnyPS5/releases/tag/bl4-22052-20827-ab). - Contact sheets: [release rectlist-passthrough-ab-8332b52dbf](https://github.com/milescoviello/AnyPS5/releases/tag/rectlist-passthrough-ab-8332b52dbf). - 3c1d4b7863 is this PR's code before the debt fragment was added; the pushed head differs from it only in `docs/dev/debt/changes`. - maskym's [Windows + NVIDIA run](https://github.com/boykopovar/AnyPS5/pull/22052#issuecomment-6979408423) of `58250e9185` merged into `main` `e069a7562f` (Windows 11, i7-12700K, RTX 2070 SUPER, WinLibs GCC 15.2.0, Release, Khronos validation layer 1.4.366): the `agc`, `guest_video_out`, `video_out` and `pad_sdl` tests pass 2050 of 2054 on both `main` and this PR with the same set of `VUID-` messages, the tests this PR adds or changes pass, and the three failures also fail on `main` there. - `git merge-tree` against `main` is clean. #17022 (rect-list layer forwarding) merges with this branch without conflicts. - `tools/check_conventions.py` passes on the branch and this body. `tools/debt_fold.py --check` reports nothing for this fragment. `main` (edb21febfa) itself fails the check on two LibreSSL3 fragments that change the same entry (`libressl3-20171-inventory.md`, `feat-libressl3-evp-pkey-new-mac-key-v2.md`); with that pair set aside, the check passes. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: PPSA28099, validated in-game on this head by edubox (https://github.com/boykopovar/AnyPS5/pull/22052#issuecomment-6958490963). PPSA01494 and PPSA30839 got past this stop on `main` 8332b52dbf with this PR (see Tested), but since #20827 they no longer reach it on `main`. - [x] GPUs tested: NVIDIA RTX 4070 Ti (615.71.09), Linux - [x] AI-assisted: yes
MarcZX10 commented 2026-11-19 05:15:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T05:15:11Z.

Review: COMMENTED


Reviewed — comments

The core change removes the rect-list shader builder’s unconditional refusal of custom pixel inputs, and the inspected code supports the claimed pass-through paths; native per-vertex behavior remains documented as unverified on console hardware.

What I ran

No commands or tests were run. I inspected the prepared diff at head 58250e9185665251797bc3718dc5da494c9ce07e and read the full text of the changed files marked included in the manifest, plus relevant ranges in the two excluded files. I did not read a ruling file or use repo_read.py.

Results

Check Result Note
Diff and manifest review passed Seven changed files identified
Build and tests not run Results in the description are author reported
Full-file coverage not run Two changed files were excluded

Findings

Blocking

None identified in the code inspected.

Non-blocking

None.

Not verified

The full contents of core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp and core/libs/prx/libSceAgcDriver/tests/Graphics.cpp were excluded from the prepared review folder; only the changed Vulkan feature-selection line and changed graphics-test range were read. The behavior of native per-vertex inputs on console hardware was not measured. Reported tests, title runs, and Windows results were not independently run or confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969676432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22052#pullrequestreview-5969676432). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T05:15:11Z. **Review:** COMMENTED --- # Reviewed — comments The core change removes the rect-list shader builder’s unconditional refusal of custom pixel inputs, and the inspected code supports the claimed pass-through paths; native per-vertex behavior remains documented as unverified on console hardware. ## What I ran No commands or tests were run. I inspected the prepared diff at head `58250e9185665251797bc3718dc5da494c9ce07e` and read the full text of the changed files marked included in the manifest, plus relevant ranges in the two excluded files. I did not read a ruling file or use repo_read.py. ## Results | Check | Result | Note | |---|---|---| | Diff and manifest review | passed | Seven changed files identified | | Build and tests | not run | Results in the description are author reported | | Full-file coverage | not run | Two changed files were excluded | ## Findings ### Blocking None identified in the code inspected. ### Non-blocking None. ## Not verified The full contents of `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` and `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` were excluded from the prepared review folder; only the changed Vulkan feature-selection line and changed graphics-test range were read. The behavior of native per-vertex inputs on console hardware was not measured. Reported tests, title runs, and Windows results were not independently run or confirmed. ## To get this to a good state Nothing is required.
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!22052
No description provided.