Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
stuart-russell:fix/agc-context-reset-values
Nov 15, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
stuart-russell:fix/agc-context-reset-values

Conversation

@stuart-russell

Copy link
Copy Markdown
Contributor

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 (fix(agc): a zero color export format is not a color export #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

@stuart-russell
stuart-russell force-pushed the fix/agc-context-reset-values branch from e2e6599 to 0f6ecb3 Compare November 5, 2026 13:28
@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line agc libSceAgc* labels Nov 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @stuart-russell, thanks for this. I checked the new reset values against the amdgpu clear-state tables, and they match: CB_TARGET_MASK and CB_SHADER_MASK are 0xffffffff and PA_CL_VTE_CNTL is 0 (clearstate_gfx10.h:167-168 and :529, and the same in clearstate_gfx9.h). The colour-mask part looks right to me.

One problem with how a draw decodes PA_CL_VTE_CNTL = 0 (core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:1757-1758):

  • With all six viewport enables clear, the hardware applies no scale or offset, so the post-divide X/Y it rasterises are window coordinates. With VTX_W0_FMT clear it also takes W0 as 1/W.
  • The new branch gives Vulkan a viewport covering the render target. Vulkan always applies the viewport transform, so this maps NDC [-1, 1] onto the target, which treats the shader's positions as NDC. That is a different transform from the one the hardware applies for this value. Positions in pixels end up outside the clip volume, and positions in NDC fill the target where the hardware would put them in about two pixels at the origin.
  • The decaf-emu code cited in the description does use a render-area viewport for the disabled case, but only together with a shader-side pre-transform: xMul = 2 / width, xAdd = -1 and the same for Y, which brings window coordinates back to NDC before Vulkan clips (vulkan_viewscissor.cpp:31-58 and :94-113). Without that half, the viewport alone does not reproduce the disabled transform.
  • drawCovers (State.cpp:2416) then reports every PA_CL_VTE_CNTL = 0 draw as covering the target, whatever its positions are.

Could you either add the position pre-transform (and the 1/W handling) for this value, or keep the reset value at 0 but leave a draw with PA_CL_VTE_CNTL = 0 rejected for now, with the mask change on its own? If the title's loading screen depends on the current mapping, it would help to know which register values its draws use when they reach this path: they may be set by state the driver doesn't model yet, rather than coming from the reset value.

@JJenkx

JJenkx commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 0f6ecb3fcc, merged onto main 4180951e90 (df479c1eab, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, with ANYPS5_REQUIRE_VULKAN=1 and Vulkan validation layers enabled. The hosted Windows check does not run these tests on pull requests.

  • The 45 agc_driver_graphics_tests and guest_font_graphics_tests cases pass in 3 of 3 runs, none skipped. None created a Vulkan instance, so this covers the host-side reset-value handling, not a GPU run.

AI-assisted: yes.

@stuart-russell
stuart-russell force-pushed the fix/agc-context-reset-values branch from 0f6ecb3 to e5e7eac Compare November 5, 2026 16:11
@stuart-russell

Copy link
Copy Markdown
Contributor Author

The windows job failed on agc_gcn_color_target, not on the two AGC suites:

an FMASK decompress over the rows of a 4x GCN target its tile padding does not add was refused: AGC graphics: CB metadata pass over part of a color target

Cause: this branch made drawCovers treat PA_CL_VTE_CNTL == 0 as covering by zeroing the read viewport scale and offset before the GCN branch. That branch uses x/y scale and offset to work out the visible extent so a target whose tile padding adds rows still counts as covered; zeroing them made the visible extent 0, so the padding case fell back to the full target height and the scissor check refused it.

Fix in e5e7eace2a: the viewport registers are read normally again, and only the coverage decision gains viewportControl == 0u || …. The reset-value behaviour is unchanged — a draw with PA_CL_VTE_CNTL 0 still decodes a viewport covering its target and is accepted; the GCN tile-padding path keeps the registers it needs.

Reproduced locally: agc_gcn_color_target passes on main, fails on the previous head, passes on e5e7eace2a, along with agc_driver_pm4 and agc_driver_graphics (19/19) and the conventions check.

@TechLevelZero

Copy link
Copy Markdown
Contributor

❌ NVIDIA GPU test: failed

PR head e5e7eac merged onto main 080dbd0 · tested 2026-11-05 17:12 UTC · 42 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ❌ 2,893 passed · 6 failed (1 new: 1 pass on main with the PR's tests, 3 also fail on main, 2 unstable on main) · 52 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,951 of 4,077 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (977 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s

Failing tests

This PR changes test files, so each failing test was also built and run on main with only the PR's test changes applied. ✅ there means the failure comes from the PR's other changes; ❌ means the test fails on main too, so this run does not show the PR caused it.

Test With this PR Same test on main 080dbd0 (main + this PR's test changes only)
agc_driver_submit_progress ❌ failed ✅ passed
agc_driver_submit_progress: Failed (also failed when re-run alone), assertion and diagnostics
ctest: Failed

[write-watch] host imports resolve write protection: no (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 4 after the import); imported ranges stay watched
[write-watch] host imports resolve write protection: no (0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 4 after the import); imported ranges stay watched
submission lost its real GPU completion store
[Shaders/ShaderRegistry.cpp:901 ReportPreparedAtUse] Compute shader 0x5cdad6806100 was not registered; preparing its artifact at dispatch
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 2 of the last 10 main runs
agc_submit_progress: failed in 1 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (9 IDs in 593 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (593 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, and 585 more
VUID-VkShaderModuleCreateInfo-pCode-08737 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08739 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08741 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_prepared_exports
VUID-VkPipelineShaderStageCreateInfo-module-parameter (1 test): agc_driver_float16_unused_nan_payloads
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 (1 test): agc_driver_float16_unused_nan_payloads
Skipped (52)
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_device_capability: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_width_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display 
Reproduce
git fetch origin e5e7eace2ae9e8855f1642722da0ab77b97e2143 080dbd08c6f83be5a1768af7d3342d701bf34d21
git checkout 080dbd08c6f83be5a1768af7d3342d701bf34d21 && git merge --no-ff e5e7eace2ae9e8855f1642722da0ab77b97e2143
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1
# the failing tests, on this merge and on main:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc_driver_submit_progress)$' --parallel 1 -V

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/Execution/include/QueueState.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8246 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9335 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9712 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10049 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 10351 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15570 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17056 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17611 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19100 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19119 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@gabichuuuuu gabichuuuuu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran e5e7eace2a merged on main 302864d 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.

@oneandonlydean oneandonlydean self-assigned this Nov 8, 2026
@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 8, 2026
@milescoviello

Copy link
Copy Markdown
Contributor

Test runs for head e5e7eace2a against its merge base d23df92b38. I built agc_driver_graphics_tests, agc_driver_prepared_graphics_tests, agc_driver_prepared_unregistered_graphics_tests on each side and ran the matching tests 3 times each with ctest.

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

test merge base this head
agc_address_copy_cap 3 passed 3 passed
agc_address_copy_cap_mirror 3 passed 3 passed
agc_address_copy_cap_remembered 3 passed 3 passed
agc_address_space_unwatched_mirror_import 3 passed 3 passed
agc_command_batch_fence_failure 3 passed 3 passed
agc_compute_descriptor_layout_flags 3 passed 3 passed
agc_copy_input_kept_bytes 3 passed 3 passed
agc_depth_copy_kept_bytes 3 passed 3 passed
agc_descriptor_cache 3 passed 3 passed
agc_descriptor_cache_failure 3 passed 3 passed
agc_descriptor_pool_reset_failure 3 passed 3 passed
agc_driver_address_space_teardown 3 passed 3 passed
agc_driver_alpha_to_coverage_state 3 passed 3 passed
agc_driver_covered_centroid_state 3 passed 3 passed
agc_driver_depth_bounds_state 3 passed 3 passed
agc_driver_fault_only_template_records 3 passed 3 passed
agc_driver_fault_only_template_records_kept 3 passed 3 passed
agc_driver_fault_only_template_records_loop_guard 3 passed 3 passed
agc_driver_fault_only_template_records_loop_guard_kept 3 passed 3 passed
agc_driver_graphics 3 passed 3 passed
agc_driver_graphics_maps_fallback 3 passed 3 passed
agc_driver_linear_volume_nonresident 3 passed 3 passed
agc_driver_msaa_dcc_state 3 passed 3 passed
agc_driver_prepared_graphics 3 passed 3 passed
agc_driver_prepared_graphics_prebuild_0 3 passed 3 passed
agc_driver_prepared_graphics_prebuild_1 3 passed 3 passed
agc_driver_prepared_graphics_prebuild_unset 3 passed 3 passed
agc_driver_prepared_unregistered_graphics 3 passed 3 passed
agc_driver_sample_location_grid_fallback 3 passed 3 passed
agc_driver_sample_order_planning 3 passed 3 passed
agc_driver_undithered_alpha_to_coverage_state 3 passed 3 passed
agc_driver_unobserved_provoking_vertex 3 passed 3 passed
agc_driver_unused_viewport_depth 3 passed 3 passed
agc_graphics_profile_draw 3 passed 3 passed
agc_heap_mirror_reference_size 3 passed 3 passed
agc_heap_mirror_run_unwatch 3 passed 3 passed
agc_heap_mirror_run_unwatch_no_space_cache 3 passed 3 passed
agc_heap_mirror_unwatch 3 passed 3 passed
agc_heap_mirror_unwatch_no_space_cache 3 passed 3 passed
agc_heap_mirror_unwatched_import 3 passed 3 passed
agc_pipeline_journal 3 passed 3 passed
agc_pipeline_journal_long_paths 3 passed 3 passed
agc_pipeline_library_clear_waits_for_build 3 passed 3 passed
agc_pipeline_store_fixed_bound 3 passed 3 passed
agc_pipeline_store_growth 3 passed 3 passed
agc_pipeline_store_lazy_buffer_pool 3 passed 3 passed
agc_pipeline_store_replay_growth 3 passed 3 passed
agc_pipeline_store_touch 3 passed 3 passed
agc_sparse_buffer_holes 3 passed 3 passed
agc_sparse_heap_mirror_budget 3 passed 3 passed
agc_sparse_heap_mirror_unwatch 3 passed 3 passed
agc_sparse_heap_mirror_unwatch_no_space_cache 3 passed 3 passed

Windows: Windows 11 VM, GeForce GT 1030 (Pascal), NVIDIA 582.78, WinLibs GCC 15.2 UCRT, Release.

test merge base this head
agc_address_copy_cap 3 passed 3 passed
agc_address_copy_cap_mirror 3 passed 3 passed
agc_address_copy_cap_remembered 3 passed 3 passed
agc_address_space_unwatched_mirror_import 3 passed 3 passed
agc_command_batch_fence_failure 3 passed 3 passed
agc_compute_descriptor_layout_flags 3 passed 3 passed
agc_copy_input_kept_bytes 3 passed 3 passed
agc_depth_copy_kept_bytes 3 passed 3 passed
agc_descriptor_cache 3 passed 3 passed
agc_descriptor_pool_reset_failure 3 passed 3 passed
agc_driver_address_space_teardown 3 passed 3 passed
agc_driver_alpha_to_coverage_state 3 passed 3 passed
agc_driver_covered_centroid_state 3 passed 3 passed
agc_driver_depth_bounds_state 3 passed 3 passed
agc_driver_fault_only_template_records 3 passed 3 passed
agc_driver_fault_only_template_records_kept 3 passed 3 passed
agc_driver_fault_only_template_records_loop_guard 3 passed 3 passed
agc_driver_fault_only_template_records_loop_guard_kept 3 passed 3 passed
agc_driver_graphics 3 passed 3 passed
agc_driver_linear_volume_nonresident 3 passed 3 passed
agc_driver_msaa_dcc_state 3 passed 3 passed
agc_driver_prepared_graphics 3 passed 3 passed
agc_driver_prepared_graphics_prebuild_0 3 passed 3 passed
agc_driver_prepared_graphics_prebuild_1 3 passed 3 passed
agc_driver_prepared_graphics_prebuild_unset 3 passed 3 passed
agc_driver_prepared_unregistered_graphics 3 passed 3 passed
agc_driver_sample_location_grid_fallback 3 passed 3 passed
agc_driver_sample_order_planning 3 passed 3 passed
agc_driver_undithered_alpha_to_coverage_state 3 passed 3 passed
agc_driver_unobserved_provoking_vertex 3 passed 3 passed
agc_driver_unused_viewport_depth 3 passed 3 passed
agc_graphics_profile_draw 3 passed 3 passed
agc_heap_mirror_reference_size 3 passed 3 passed
agc_heap_mirror_run_unwatch 3 passed 3 passed
agc_heap_mirror_run_unwatch_no_space_cache 3 passed 3 passed
agc_heap_mirror_unwatch 3 passed 3 passed
agc_heap_mirror_unwatch_no_space_cache 3 passed 3 passed
agc_pipeline_journal 3 passed 3 passed
agc_pipeline_journal_extended_paths 3 passed 3 passed
agc_pipeline_journal_long_paths 3 passed 3 passed
agc_pipeline_library_clear_waits_for_build 3 passed 3 passed
agc_pipeline_store_fixed_bound 3 passed 3 passed
agc_pipeline_store_growth 3 passed 3 passed
agc_pipeline_store_lazy_buffer_pool 3 passed 3 passed
agc_pipeline_store_replay_growth 3 passed 3 passed
agc_pipeline_store_touch 3 passed 3 passed
agc_sparse_buffer_holes 3 passed 3 passed
agc_sparse_heap_mirror_budget 3 passed 3 passed
agc_sparse_heap_mirror_unwatch 3 passed 3 passed
agc_sparse_heap_mirror_unwatch_no_space_cache 3 passed 3 passed

Every test I ran passes on this head, apart from any skips listed.

AI-assisted: yes (Claude Code)

@ryanc2112

Copy link
Copy Markdown
Contributor

A GFX8 data point: AMD Radeon RX 570 (RADV POLARIS10), Mesa 26.2.5, SteamOS 3.8.28 (Arch distrobox), GCC 16.2.1, Release. Head e5e7eace2a merged onto main bbaa4bf253 (clean merge), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and ctest -V --no-tests=error. No log reports was not found but was requested by env var VK_INSTANCE_LAYERS.

agc_driver_pm4 and agc_driver_graphics (31 tests), 3 runs each: all 31 pass on all 3 runs on main and with this PR, with 0 VUID- errors.

The 1,499 AGC, shader, VideoOut and Vulkan tests, this PR on main, once each:

AI-assisted: yes (Claude Code)

@stuart-russell

Copy link
Copy Markdown
Contributor Author

Thanks — all three readings are right, and the two "from reading" points are intended rather than incidental.

  • Scale and offset are not read in the 0 branch because the register gates the viewport transform per axis: with PA_CL_VTE_CNTL 0 the hardware does not apply them, so a title that never writes them should not be refused for their contents. That is the whole point of the change — previously the draw was rejected before anything looked at the transform.
  • depthScale/depthOffset/the clamp bounds keep their defaults (1, 0, 0 to 1). Those defaults are exactly the identity transform with a [0, 1] depth clamp, which is what "no transform" means; there is no register-derived remap to compute, so leaving them is deliberate rather than an omission. If a title ever needs otherwise it will show up as a depth-range mismatch, and the branch is the place to revisit.
  • drawCovers, DrawRejection and DecodeState accepting the same two values is the invariant I wanted, and it is what the review comment on fix(agc): a zero color export format is not a color export #10779 asked for: the precheck must reject exactly what the decode would.

With your Turing laptop and Intel iGPU, @milescoviello's RTX 4070 Ti and @ryanc2112's RX 570 (RADV GFX8), the decode path now has coverage on five GPU families across three vendors, plus the Windows and MinGW runs already on the thread — and the control case (this PR's decode without the reset values) fails on each of them, which is the useful half.

@angrysandhill

Copy link
Copy Markdown
Contributor

This PR on an AMD GPU under Windows, with AMD's own driver: the 27 focused tests pass 3 of 3, and the full AGC suite matches main test for test.

Setup: Windows 10 Home 22H2 (10.0.19045), AMD Radeon RX 6750 XT, AMD Software Adrenalin 26.10.1 (driver 32.0.21045.16010), WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON. Head e5e7eace2a merged with --no-ff onto main c5488026ab (clean merge). ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU="AMD Radeon RX 6750 XT", no validation layer. The libSceAgcDriver.prx staged in build/tests was checked to match the fresh build before the runs.

Focused tests: ^(agc_driver_pm4.*|agc_driver_graphics)$, 27 tests (agc_driver_graphics, whose test this PR changes, and the 26 agc_driver_pm4* tests), one at a time: 27 of 27 pass on each of 3 runs.

Full suite: ^(agc_|windows_write_watch$), 1,583 tests, 4 at a time. Per test, the outcomes are identical to a run of main c5488026ab on this card earlier today: 1,565 passed and the same 17 skipped. One failed, agc_driver_sample_order_grid_reference, with the same message as on main ("the exact path did not render the checkerboard bit for bit like the reference"), which #9503 addresses.

agc_driver_submit_progress, the one new failure in the NVIDIA GPU test above ("submission lost its real GPU completion store"), passed here in that full run, as it did on main. That is one run on each side, without the validation layer that run used, so it doesn't settle whether the failure is specific to NVIDIA.

AI-assisted: yes.

@blawesom

Copy link
Copy Markdown
Contributor

Validation run — queue item 24 (PR #16053)

Environment

  • Machine: CachyOS, kernel 7.3.4-1-cachyos, Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RADV GFX1201) + AMD AI PRO R9700, /dev/kfd present
  • GPU selected via ANYPS5_GPU='AMD Radeon RX 9070 XT'
  • Validation layer: VK_LAYER_KHRONOS_validation (API 1.4.363) via VK_ADD_LAYER_PATH=/home/benj/scratch/vvl-layer

SHAs

  • Base (origin/main): a9f291040088cac6babfbe270c50f344a4f6f27d — reused read-only worktree /home/benj/scratch/wt5/base-main (clean, existing build/)
  • PR head: e5e7eace2ae9e8855f1642722da0ab77b97e2143 — "fix(agc): start the color masks and viewport control at their reset values" (single commit on stale base d23df92b380; origin/main is 10018 commits ahead of that base)
  • PR state at check: OPEN, headRefOid == queue SHA, not merged

Build

  • PR tree: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON → exit 0 (9 s); cmake --build build --parallel 12 (CMAKE_BUILD_PARALLEL_LEVEL=12) → exit 0, wall 280 s
  • Logs: q24-pr16053-configure.log, q24-pr16053-build.log

Focused tests (identical matched set in both trees, 22 tests)

Pattern (saved in q24-pattern.txt; name lists q24-names-base.txt / q24-names-pr.txt, diff-identical):
^(agc_driver_graphics|agc_driver_graphics_maps_fallback|agc_driver_unused_viewport_depth|agc_descriptor_pool_reset_failure|agc_context_state_size_tests|agc_driver_alpha_to_coverage_state|agc_driver_covered_centroid_state|agc_driver_depth_bounds_state|agc_driver_msaa_dcc_state|agc_driver_undithered_alpha_to_coverage_state|agc_driver_prepared_shaders_abi_deferred_undecodable_state|agc_driver_bitfield_mask|agc_driver_cmask_fast_clear|agc_driver_masked_global_store|agc_driver_pixel_valid_mask|agc_driver_quad_pixel_mask|agc_driver_sample_mask_depth_stencil|agc_driver_sample_mask_draw|agc_driver_sample_mask_multisample|agc_driver_alpha_to_coverage_sample_mask_export|agc_driver_two_sample_alpha_to_coverage_sample_mask_export|agc_recorder_cmask)$
Includes agc_driver_graphics, the test whose source (tests/Graphics.cpp, InitialContextTests) the PR modifies.

Command run in each tree (timeout 3600 each):

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
VK_ADD_LAYER_PATH=/home/benj/scratch/vvl-layer VK_LOADER_DEBUG=layer ANYPS5_GPU='AMD Radeon RX 9070 XT' \
ctest --test-dir build -R '<pattern>' -V

Results

Tree ctest exit wall tests passed
base-main (a9f29104) 0 12 s 22/22 Passed, 0 failed, 0 skipped
pr-16053 (e5e7eace) 0 19 s 22/22 Passed, 0 failed, 0 skipped

Per-test outcomes identical between trees (all 22 Passed in both; logs q24-tests-base.log, q24-tests-pr.log).

Layer checks (per AGENTS.md)

  • was not found but was requested by env var VK_INSTANCE_LAYERS: absent in both logs (0 occurrences)
  • Insert instance layer "VK_LAYER_KHRONOS_validation": present in both logs (14 occurrences each)

VUID / validation-ID diff

  • VUID- / SYNC-HAZARD- / bracketed IDs in base log: none; in PR log: none — ID sets identical (empty), so the change adds no new VUID- validation errors (there were zero validation errors/warnings in either run)
  • Validation Error/Validation Warning lines: 0 in both logs

Push

  • git push fork +e5e7eace2ae9e8855f1642722da0ab77b97e2143:refs/heads/validation/pr-16053 → refs/heads/validation/pr-16053 on blawesom/AnyPS5

Verdict

PASS — PR builds clean and the focused AGC color-mask/viewport/reset-state test set is 22/22 on both base and PR on Linux/AMD RX 9070 XT (RADV) with the Khronos validation layer active and no new validation IDs.

Limitations

  • Scoped to Linux + AMD RADV (RX 9070 XT); no NVIDIA/Windows/AGC-hardware coverage.
  • The PR branch base is stale (merge-base d23df92b380, 10018 commits behind origin/main); the comparison is PR head vs origin/main as queued, so differences from main's intervening history are not attributed here (none were observed in the matched set: identical pass sets and zero validation IDs in both logs).
  • Single run per tree (no repetition), so intermittent faults are not excluded.

…alues

CB_TARGET_MASK and CB_SHADER_MASK resets to all channels on every target, and PA_CL_VTE_CNTL resets to 0, where no viewport transform is enabled. A draw that never programs either therefore wrote no color and decoded a (-1,-1) 2x2 viewport from registers it never set, and every draw was discarded. Give such a draw a viewport covering its render target, accept 0 in the draw rejection and the coverage check, and keep 0x43f on the register-derived path.
@stuart-russell
stuart-russell force-pushed the fix/agc-context-reset-values branch from e5e7eac to bade673 Compare November 14, 2026 22:28
@stuart-russell

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (ee25ae607b), so the "10018 commits behind" note in the validation run no longer applies. No conflicts; the diff is unchanged.

Re-verified on the rebased head: agc_driver_pm4, agc_driver_graphics and agc_gcn_color_target pass (35 tests), conventions clean.

Thanks for the validation run — the zero-validation-ID result and the matched 22/22 across base and PR on RADV are exactly the evidence this needed, on top of the NVIDIA/Intel/RDNA2/GFX8 reports already on the thread.

@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 14, 2026
@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 15, 2026
@oneandonlydean
oneandonlydean merged commit 83d984d into boykopovar:main Nov 15, 2026
14 checks passed
@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 15, 2026
@JJenkx

JJenkx commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Matched regression evidence for Kao the Kangaroo (PPSA05595) on Linux RX6650XT:

  • Frozen main ef4b9389b63b71253b985112d3a7b99e68876ac8, with test-only fixtures at 38b5baea6f9e09a95d5c49a7c4ac2930fb5baa11: the menu and gameplay HUD are upside down and strongly green-tinted. This is visible in both native captures and the X11 game window.
  • Private diagnostic 89170621fa2dfdb80928b29804f8ca9e86fb00be changes only initial context register 0x206 back from 0 to the former 0x43f. It restores the menu's orientation and colors. This is a diagnostic, not a proposed reset-value fix.
  • The matched control and diagnostic use identical savedata manifests and the same 19,185-file compiler-cache seed. The control reproduces the corruption with that warmed seed, exits normally after 204.1 s, and all six source/bank/asset/cache/save/cleanup guards pass. Yesterday's main 6764133b357a9a399327fa9596568ea2b089847d rendered this exact checkpoint upright with the expected purple scene.
  • The diagnostic then aborts after Continue (56.5 s): guest sampler descriptor disables degamma with an sRGB texture, which is not implemented. Gameplay restoration and a complete fix are not established. No performance claim.

Raw-orientation menu comparison · matched source/cache pins and diagnostic patch.

The existing AGC public default table contains 0x206 = 0x43f; AMD's gfx10 clear-state table uses zero. These describe different initialization contexts, so the visible improvement alone does not establish the correct PS5 CLEAR_STATE behavior. Also, the cited Decaf implementation pairs its full-target disabled viewport with shader-side coordinate conversion.

For the separate sampler blocker I measured local gfx1032 hardware: RGBA8 sRGB format130 with sampler word0 bit31 set equals UNORM format56 sampling bit-for-bit in 64/64 lanes, for both point and bilinear filtering; two fixed repeats of all eight modes agree. Plain sRGB differs from UNORM in all64 lanes; the UNORM numeric control has maximum absolute error below3e-8. Hardware inputs, results and replay script. This is local RDNA2 evidence, not a PS5 hardware-equivalence claim. No sampler refusal has been removed.

Follow-up: #20728 implements direct sampled-image SKIP_DEGAMMA through compatible UNORM views. Expanded native gfx1032 measurements cover all seven sRGB families, point/bilinear and FORCE precedence (70 modes, two stable repeats each). Matched Linux qualification gives main five passing gates/two expected SKIP failures and change seven passes, with six realGPU cases per arm and zero skips/VUIDs. This addresses the sampler behavior exposed by the private viewport diagnostic; the viewport-default regression remains separate and no title unblock is claimed.

Additional integration check: current main 178944e753f964bf6aaa4e0b6ca4301923d13934 + #20548 (f8db0aa9ca56) + #20728 (baf8ee9a2301), private head 5cc76d2c4bd3, without a viewport-reset override (0x206 remains zero). Full SDK/relinker and ten focused integration gates pass, with eight validation-layer/device selections, no skips/VUIDs. Kao reaches its HUD but the reviewed native frame remains upside down and strongly green-tinted. The harness stops injecting input after HUD and closes normally at327.3s, exit0; all six isolation/cleanup guards pass and no native process remains.

This is an integration-only observation, not separate causal attribution to either PR or a title-unblock claim. The combination has not resolved the rendering regression. Source pins, logs and reduced raw-orientation native capture.

@ghost

ghost commented Nov 15, 2026

Copy link
Copy Markdown

A second title with the same regression: GTA V (PPSA04264 01.005.000) on Windows.

Host: Windows 11 Pro 26300, Ryzen 7 5800X3D, RTX 5070 Ti (NVIDIA 621.01), WinLibs GCC 15.2.0 r7 Release, relinked with --windows. Inputs scripted with tools/pad_input.py (title, landing menu, Story, new game), screenshots through APS5_SCREENSHOT_TRIGGER.

build HDR output (default) APS5_FORCE_SDR=1
e5dba50ccb (before this PR) — prologue renders upright
ef4b9389b6 (main with this PR) picture stays on the "Ludendorff, North Yankton" title card while audio and the game continue text and HUD upside down, scene in horizontal bands
ef4b9389b6 with only {0x206, 0} → {0x206, 0x43f} in InitialContextRegisters (QueueState.hpp) prologue gameplay renders upright and advances ("Go to the guard.") upright as well

So the title draws with the initial PA_CL_VTE_CNTL and expects 0x43f, the value in libSceAgc's public defaults table (RegisterDefaultsData.hpp, {0x0206, 0x0000043f}). With 0, the full-target viewport drops the title's negative Y scale. Like the Kao report above, this is a diagnostic, not a proposed fix: PPSA30528 still needs some handling of a title that never programs the register.

AI-assisted: yes

HQasper pushed a commit to HQasper/AnyPS5 that referenced this pull request Nov 17, 2026
Since the reset values change (boykopovar#16053) the queue start and CLEAR_STATE
set PA_CL_VTE_CNTL to 0, which the decoder reads as positions without a
viewport transform: the draw gets a viewport over its whole render
target and a depth range of 0..1, ignoring the title's z scale and
offset. Red Dead Redemption (PPSA30528) never programs the register
after CLEAR_STATE, so its reversed-depth viewport lost its z mapping and
far surfaces drew over near ones (faces through hats, walls see-through).
With 0x43f restored on the same build its frame matches the earlier
builds again; restoring the color masks alone did not change it.

A title that writes 0 itself still gets the covering viewport, and the
color masks keep their all-channel reset value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oneandonlydean added a commit that referenced this pull request Nov 18, 2026
…rol was never written (#23165)

Since #16053 a draw whose PA_CL_VTE_CNTL is still 0 gets a viewport covering its render target. A title that programs the viewport scale and offset registers but never writes the control lost its transform that way, and with a negative Y scale its whole image was drawn upside down (PPSA04263). Take the covering viewport only while the first viewport's six transform words are still at their initial values, and use the programmed transform otherwise, in the state decode and in the coverage check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.