fix(agc): start the color masks and viewport control at their reset values #16053

Merged
stuart-russell merged 1 commit from upstream-pr/16053 into main 2026-11-15 10:49:27 +00:00
stuart-russell commented 2026-11-05 13:28:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by stuart-russell on 2026-11-05T13:28:02Z.


What

CB_TARGET_MASK (0x8e) and CB_SHADER_MASK (0x8f) reset to 0xffffffff, and PA_CL_VTE_CNTL (0x206) resets to 0. A title that never programs them got the driver's former zeros instead: the masks meant nothing was written, and PA_CL_VTE_CNTL 0 threw, or, once accepted, decoded a viewport of (-1,-1) 2x2 from registers the title never wrote, so every draw was discarded.

  • Start both masks at 0xffffffff. CLEAR_STATE restores the same values through InitialContextRegisters.
  • Start PA_CL_VTE_CNTL at 0 and give a draw with that value a viewport covering its render target. 0x43f keeps the register-derived viewport, and any other value still throws.
  • Accept 0 in drawCovers and in the draw rejection.

Follow-up to #10779, which is merged.

References

  • The Linux radeon driver initialises its cb_target_mask and cb_shader_mask tracking to 0xFFFFFFFF (drivers/gpu/drm/radeon/r600_cs.c, r600_cs_track_init), the hardware reset value for both masks.
  • PA_CL_VTE_CNTL enables the per-axis viewport scale and offset; 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).
  • Measurement: with the previous values the title's first draws decoded a viewport of (-1,-1) 2x2 and every draw was rejected; with these values the same trace decodes a full-target viewport and its color targets.

Tested

agc_driver_pm4 (18 tests) and agc_driver_graphics pass, and tools/check_conventions.py --base origin/main passes, on d23df92b38.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_driver_(pm4|graphics)' -V passes with no VUID- lines and without the "was not found but was requested by env var VK_INSTANCE_LAYERS" message. This machine has no Vulkan device, so that run covers the decode path only.

A Windows build of the same values (MinGW cross-build, NVIDIA RTX 3070, driver 32.0.15.9186, Windows 11) ran PPSA30528 to its loading screen with audio; the run without them produced a black window. That run predates this rebase.

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 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 (#10779, the zero export format rule this needs, is merged)
  • Fixes: none
  • Unblocks: PPSA30528 (renders its loading screen; text decoding and a compute sync problem remain, tracked separately)
  • GPUs tested: NVIDIA RTX 3070 (driver 32.0.15.9186) on Windows 11 for the title run; the branch's Linux test machine has no Vulkan device
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5172345321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16053). Originally posted by [stuart-russell](https://github.com/stuart-russell) on 2026-11-05T13:28:02Z. --- ### What `CB_TARGET_MASK` (0x8e) and `CB_SHADER_MASK` (0x8f) reset to `0xffffffff`, and `PA_CL_VTE_CNTL` (0x206) resets to 0. A title that never programs them got the driver's former zeros instead: the masks meant nothing was written, and `PA_CL_VTE_CNTL` 0 threw, or, once accepted, decoded a viewport of (-1,-1) 2x2 from registers the title never wrote, so every draw was discarded. - Start both masks at `0xffffffff`. `CLEAR_STATE` restores the same values through `InitialContextRegisters`. - Start `PA_CL_VTE_CNTL` at 0 and give a draw with that value a viewport covering its render target. `0x43f` keeps the register-derived viewport, and any other value still throws. - Accept 0 in `drawCovers` and in the draw rejection. Follow-up to #10779, which is merged. ### References - The Linux radeon driver initialises its `cb_target_mask` and `cb_shader_mask` tracking to `0xFFFFFFFF` (`drivers/gpu/drm/radeon/r600_cs.c`, `r600_cs_track_init`), the hardware reset value for both masks. - `PA_CL_VTE_CNTL` enables the per-axis viewport scale and offset; 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`). - Measurement: with the previous values the title's first draws decoded a viewport of (-1,-1) 2x2 and every draw was rejected; with these values the same trace decodes a full-target viewport and its color targets. ### Tested `agc_driver_pm4` (18 tests) and `agc_driver_graphics` pass, and `tools/check_conventions.py --base origin/main` passes, on `d23df92b38`. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_driver_(pm4|graphics)' -V` passes with no `VUID-` lines and without the "was not found but was requested by env var VK_INSTANCE_LAYERS" message. This machine has no Vulkan device, so that run covers the decode path only. A Windows build of the same values (MinGW cross-build, NVIDIA RTX 3070, driver 32.0.15.9186, Windows 11) ran PPSA30528 to its loading screen with audio; the run without them produced a black window. That run predates this rebase. ### 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) - [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 (#10779, the zero export format rule this needs, is merged) - [x] Fixes: none - [x] Unblocks: PPSA30528 (renders its loading screen; text decoding and a compute sync problem remain, tracked separately) - [x] GPUs tested: NVIDIA RTX 3070 (driver 32.0.15.9186) on Windows 11 for the title run; the branch's Linux test machine has no Vulkan device - [x] AI-assisted: yes
gabichuuuuu commented 2026-11-08 15:18:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T15:18:14Z.

Review: COMMENTED


Ran e5e7eace2a merged on main 302864d48c on Windows 11 x64 (WinLibs GCC 15.2), ctest -R '^agc_driver_graphics$' -V, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1, on both an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx) selected:

main main + only this PR's Graphics.cpp diff change, 2 runs each
NVIDIA passed failed passed
Intel passed failed passed
  • Without the QueueState.hpp/State.cpp changes, the updated test stops at "the initial viewport control is not its reset value". With them, it passes every time.
  • agc_driver_graphics runs against MockVulkan, so this covers the decode path (as on the description's machine) on two more hosts, not a draw on a real device. I didn't run agc_driver_pm4.

From reading:

  • The PA_CL_VTE_CNTL 0 branch skips the scale/offset registers entirely, so a title that leaves them unwritten no longer reaches the "unsupported viewport transform" refusal.
  • depthScale, depthOffset and the depth clamp bounds aren't set in that branch, so they keep State's defaults (scale 1, offset 0, clamp 0 to 1).
  • drawCovers and DrawRejection accept the same two values as DecodeState, so the three can't disagree.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5818419029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16053#pullrequestreview-5818419029). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T15:18:14Z. **Review:** COMMENTED --- Ran `e5e7eace2a` merged on `main` 302864d48c on Windows 11 x64 (WinLibs GCC 15.2), `ctest -R '^agc_driver_graphics$' -V`, with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`, on both an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx) selected: | | `main` | `main` + only this PR's `Graphics.cpp` diff | change, 2 runs each | |---|---|---|---| | NVIDIA | passed | failed | passed | | Intel | passed | failed | passed | - Without the `QueueState.hpp`/`State.cpp` changes, the updated test stops at "the initial viewport control is not its reset value". With them, it passes every time. - `agc_driver_graphics` runs against `MockVulkan`, so this covers the decode path (as on the description's machine) on two more hosts, not a draw on a real device. I didn't run `agc_driver_pm4`. From reading: - The `PA_CL_VTE_CNTL` 0 branch skips the scale/offset registers entirely, so a title that leaves them unwritten no longer reaches the "unsupported viewport transform" refusal. - `depthScale`, `depthOffset` and the depth clamp bounds aren't set in that branch, so they keep `State`'s defaults (scale 1, offset 0, clamp 0 to 1). - `drawCovers` and `DrawRejection` accept the same two values as `DecodeState`, so the three can't disagree. AI-assisted: yes.
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!16053
No description provided.