Skip to content

feat(agc): select viewports from vertex and mesh viewport index exports - #19373

Merged
oneandonlydean merged 8 commits into
boykopovar:mainfrom
c1b3r-p3d1a:feat/agc-viewport-index
Nov 16, 2026
Merged

oneandonlydean merged 8 commits into
boykopovar:mainfrom
c1b3r-p3d1a:feat/agc-viewport-index

Conversation

@c1b3r-p3d1a

@c1b3r-p3d1a c1b3r-p3d1a commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

PA_CL_VS_OUT_CNTL.USE_VTX_VIEWPORT_INDX (bit 19) was ignored with a warning, so every draw landed in viewport 0. With this change, vertex and mesh draws select one of 16 viewports per vertex:

  • Decode (State.cpp): when bit 19 is set, viewports 1 to 15 are read from PA_CL_VPORT_XSCALE_i..ZOFFSET_i (0x10f + 6i) with the same collapsed/usable rules as viewport 0. Their scissors are the screen, window and generic scissors intersected with PA_SC_VPORT_SCISSOR_i (0x94 + 2i) when PA_SC_MODE_CNTL_0.VPORT_SCISSOR_ENABLE is set. A missing, non-finite or reserved-bit viewport becomes an empty one that draws nothing; it does not throw, because titles leave unused slots unwritten. The draw's single scissor becomes the union, and depth-clear pinning, unused-depth normalisation and depth-bounds emulation apply to every viewport.
  • Index range: the index is the 4-bit field 19:16, so it is 0 to 15, and a draw that keeps it always declares all 16 viewports (ApplyViewportIndex requires it). No index is out of range, so nothing is clamped.
  • Vulkan: multiViewport is enabled when maxViewports >= 16. Pipelines take viewportCount/scissorCount from the state (it is part of the pipeline key and the draw-register key), and vkCmdSetViewport/vkCmdSetScissor set all 16.
  • Draw key (State.hpp): DrawKeyRegisters covers PA_SC_VPORT_SCISSOR_0..15 (0x094, 0x20 words) and PA_CL_VPORT_*_0..15 (0x10f, 0x60 words), so with the register draw key a draw that changes only one of viewports 1 to 15 misses the cache instead of reusing the old viewports.
  • Pipeline journal (PipelineJournal.cpp): CanonicalPipelineState keeps the viewport count, the recipe codec writes it (a count over 15 does not decode), the journal format is 19 (main is at 18) and the State size guard is 1008. Viewports and scissors are dynamic state, so the count is the only part of them a pipeline is built from.
  • Recompiler: the vertex shader writes ViewportIndex through ShaderViewportIndexLayerEXT when the device has VK_EXT_shader_viewport_index_layer, otherwise through the SPIR-V 1.5 capability. The mesh shader writes a per-primitive ViewportIndex block (PerPrimitiveEXT, MultiViewport) from the provoking vertex, the same way Layer is handled. The index is bits 19:16 of the misc vector's z, as Mesa's radeonsi and RADV pack it on GFX9+; that extraction was already present.
  • Kept as before, with the existing one-time warning: tessellation, rect-list and barycentric-patch routings, devices without multiViewport, and vertex draws on devices without VK_EXT_shader_viewport_index_layer (which would otherwise fail shader validation), ignore the index and draw into viewport 0. A depth range outside [0, 1] on a multi-viewport draw throws without VK_EXT_depth_range_unrestricted, because the remap is single-viewport. Only PA_SC_VPORT_ZMIN/ZMAX_0 is read. All of this is in the new debt entry.

No open PR implements multi-viewport. #15548 and #17611 touch the same files but only use ShaderViewportIndexLayerEXT for layer output in their compute emulation.

Overlap: #16752 rewrites the vkCmdSetViewport/vkCmdSetScissor calls in Pipeline::Continue/ContinueBackFaces that setViewports replaces here, so whichever merges second has to move setViewports onto its CommandState. I moved the DrawDecode.cpp and ShaderValidation.cpp hunks off the lines #16025, #17022 and #17911 change; a merge simulation against them is clean.

Tested

Head b35560753e on main 92b550a7c4, no title. It merges cleanly with main e22c5fb941.

This head (draw key ranges and the viewportIndexLayer gate), Windows 11 (26300), AMD Radeon RX 7700 XT, AMD driver 32.0.32015.7029:

  • agc_driver_viewport_index now records every register the multi-viewport decode reads through the register facade, requires that it read viewports 1 and 15 (0x96, 0xb3, 0x115, 0x16e), that DrawKeyCovers holds every one of them, and that 0x16f is not covered. It also checks that a vertex draw on a multiViewport device without VK_EXT_shader_viewport_index_layer falls back to viewport 0. The pin at tests/Graphics.cpp:638 still holds.
  • Mutation checks, each makes the test fail: the scissor range back to 2 words, the transform range back to 6, the transform range one word short (0x5f), one word too wide (0x61), and dropping the viewportIndexLayer condition.
  • With the Khronos validation layer 1.4.368 (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_REQUIRE_VULKAN=1), agc_driver_viewport_index passes 3 of 3 runs with the vertex and mesh draws; each log shows the layer inserted and no VUID- messages.
  • Full agc_driver|shader suite (1268 tests), every test executable rebuilt: 1258 pass. Eight f16 checks (agc_driver_f16_conversion_float_mode, float16_misc, float16_modifiers, float16_rounding, fp16_overflow, ldexp_f16_inline_constants, sdwa_ldexp_f16, vop2_modifier_forms) and agc_driver_sample_order_grid_reference fail. They test shader arithmetic and sample positions this PR does not touch, and they failed the same way on main in my earlier baseline run; I did not rerun main for this head. agc_driver_dumped_constant_capture failed in the suite and in 1 of 9 runs alone (8 passed), so it is intermittent.

Previous head 3f211973f3:

  • agc_driver_viewport_index:
    • Decoder checks: viewports 1, 5 and 15 follow their own PA_CL_VPORT registers and PA_SC_VPORT_SCISSOR, the other slots are empty, 16 scissors and their union, stripping without multiViewport or on tessellation, a draw keeping the index with fewer than 16 viewports is rejected, a reserved-bit scissor gives an empty viewport, and the depth remap rejection.
    • Journal checks: the canonical state keeps 16 viewports (1 for a single-viewport draw), the recipe round-trips byte for byte, and a recipe with 17 viewports does not decode.
    • GPU draws through the vertex and the mesh path into a 32x16 target split into 16 strips, each viewport with its own scissor height: every vertex selects viewport 1, 0, 2, 7, then 15, and the test checks every texel.
  • Mutation checks, each makes the test fail: dropping the count from the canonical state, writing 0 for it in the recipe, accepting 16 extra viewports on decode, removing the 16-viewport requirement, passing only scissor 0 to Vulkan, reading the wrong PA_SC_VPORT_SCISSOR register, and reading the index from bit 17.
  • Windows 11 (26300), AMD Radeon 680M, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R <pattern> -V, Khronos validation layer 1.4.363.1:
    • On this branch, agc_driver_viewport_index (vertex and mesh draws), agc_driver_mesh_provoking_layer and agc_driver_layered_array_color_draw pass. Each log shows Insert instance layer "VK_LAYER_KHRONOS_validation", there is no was not found but was requested, and there are no VUID- messages.
    • On main, the two existing tests run the same way, also with no VUID- messages.
    • agc_driver_viewport_index passes 3 of 3 runs, 0.4 s each.
    • Full agc_driver|shader suite (1267 tests): 1266 pass. agc_driver_sample_order_grid_reference fails, and fails the same way on main on this GPU. agc_driver_graphics failed once under -j 8 on a partially resident depth plane check and passes 3 of 3 runs alone.
  • Linux, Ubuntu 24.04 (WSL2), GCC 13.3.0, llvmpipe (Mesa 25.2.8): the full build compiles, including the State size guard in PipelineJournal.cpp. agc_driver_viewport_index passes with the vertex draws; its mesh draws skip because llvmpipe has no mesh compiler for these programs. agc_driver_pipeline_journal, agc_pipeline_journal, agc_driver_graphics and agc_driver_layered_array_color_draw pass; agc_driver_mesh_provoking_layer skips for the same reason. No validation layer on this Linux setup.
  • Not run: an NVIDIA GPU (I have none), and a Linux run on a GPU with mesh shaders.
  • python3 tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py could not confirm overlaps, so I compared the PRs that share files by hand (see What).

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 7700 XT, AMD driver 32.0.32015.7029, Windows 11 (this head); AMD Radeon 680M, AMD driver 32.0.21030.12001, Windows 11 (previous head); llvmpipe (Mesa 25.2.8), Ubuntu 24.04 on WSL2
  • AI-assisted: yes

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Heads up — on a clean build on Linux (GCC 13.3.0) this doesn't compile:

core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp:50:29: error: static assertion failed: State changed: update CanonicalPipelineState and the recipe codec
   50 | static_assert(sizeof(State) == 952, "State changed: update CanonicalPipelineState and the recipe codec");

The new State members in State.hpp — viewportExports, and the two std::vectors extraViewports and viewportScissors — change sizeof(State), so the == 952 tripwire in PipelineJournal.cpp fires. It guards CanonicalPipelineState and the recipe codec that serialize State for the pipeline journal; the two vectors in particular can't be byte-copied the way the existing POD members are, so the codec (and the assert's expected size) need updating for the new fields.

Confirmed with ninja -t clean + full rebuild at 9663c76440; main builds PipelineJournal.cpp fine. Found while building the PR for a cross-HW run of agc_driver_viewport_index on our AMD GPUs (Vega/RDNA2/RDNA3) — glad to post those once it builds.

AI-assisted: yes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

The design reads well: bit 19 of PA_CL_VS_OUT_CNTL gates the viewport index, it is part of the decode, pipeline and library keys, viewports and scissors are dynamic, and without multiViewport it falls back to viewport 0 with a one-time warning. Three things before I can pass it:

  1. This head does not build on Linux, as tablefrogpillow reported. PipelineJournal.cpp:50 has static_assert(sizeof(State) == 952, "State changed: update CanonicalPipelineState and the recipe codec"), and the PR adds viewportExports and two std::vectors to State without touching that file. The message is the real ask, not just the number: the journal codec writes State field by field and has no viewport fields, so a replayed recipe would build a pipeline with viewportCount 1 while the draw sets N viewports. Please add the viewport fields to CanonicalPipelineState and the recipe codec (and bump the journal FileFormat if the layout changes), then fix the assert.
  2. The viewport index is not clamped to the viewport count or to maxViewports. An out-of-range index is undefined in Vulkan, and nothing here says what the console does. Please clamp it, or state in the debt entry what happens and that it is unmeasured.
  3. The GPU test only draws into viewport 1 and viewport 0. Please add indices above 1 and distinct per-viewport scissors, since the scissor array is part of what this adds. After a new head, please post Linux and NVIDIA runs.

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 13, 2026
@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 9663c76440, merged onto main 35e4948bbd. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

agc_driver_viewport_index:

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1 (merge f0b638eaed): passed in 3 of 3 runs. The binary matched the hash recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • CPU, Vulkan hidden (merge 94f65d28e7): skipped (it needs a device), 0 failed.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

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
PR 19697 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp L1646
PR 20153 core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp L50-51
PR 20518 core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp L50-52, L59
PR 20845 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L1858-1885

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 1368 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 4847 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5609 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRegisterKey.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6553 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7275 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
PR 7449 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7643 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7682 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8592 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9289 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9563 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 10351 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 10359 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10442 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 10492 docs/dev/debt/libSceAgcDriver.md
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 10652 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10743 docs/dev/debt/libSceAgcDriver.md
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11442 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 11452 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11483 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12828 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12904 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
docs/dev/debt/libSceAgcDriver.md
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 13963 docs/dev/debt/libSceAgcDriver.md
PR 14032 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14217 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 14944 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15136 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15296 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 15456 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15499 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 15529 docs/dev/debt/libSceAgcDriver.md
PR 15548 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15621 docs/dev/debt/libSceAgcDriver.md
PR 16260 docs/dev/debt/libSceAgcDriver.md
PR 16831 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 17056 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 17611 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
docs/dev/debt/libSceAgcDriver.md
PR 17915 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 17956 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
docs/dev/debt/libSceAgcDriver.md
PR 18173 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 18515 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
docs/dev/debt/libSceAgcDriver.md
PR 18530 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp
core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp
PR 19100 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19181 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 19445 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 19722 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20030 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 20084 docs/dev/debt/libSceAgcDriver.md
PR 20111 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20187 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 20248 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

c1b3r-p3d1a and others added 2 commits November 13, 2026 15:50
PA_CL_VS_OUT_CNTL.USE_VTX_VIEWPORT_INDX was ignored with a warning, so
every draw landed in viewport 0. Decode viewports 1..15 and their
PA_SC_VPORT_SCISSOR rectangles when the bit is set, pass all sixteen to
Vulkan on devices with multiViewport, and write ViewportIndex from the
vertex shader (VK_EXT_shader_viewport_index_layer) and per primitive
from the mesh shader. Other routings and devices keep the old behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re viewports

CanonicalPipelineState dropped the extra viewports, so the pipeline store
and the journal keyed a sixteen-viewport draw like a single-viewport one.
Keep the count in the canonical state, encode it in the recipe, reject
more than fifteen extra viewports on decode, bump the journal format to
18 and update the State size guard to 1008 bytes.

A kept viewport index requires all sixteen viewports, since the 4-bit
index can name any of them. The test now decodes viewports 5 and 15 with
their own scissors, round-trips the recipe, and draws through indices
0, 1, 2, 7 and 15 into per-viewport strips with distinct scissors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@c1b3r-p3d1a
c1b3r-p3d1a force-pushed the feat/agc-viewport-index branch from 9663c76 to 3f21197 Compare November 13, 2026 15:09
@c1b3r-p3d1a

Copy link
Copy Markdown
Contributor Author

@oneandonlydean @tablefrogpillow thanks, all three are addressed in 3f211973f3 (second commit), rebased on main 92b550a7c4.

1. Journal codec and the size guard. The assert was hiding a real bug: CanonicalPipelineState dropped extraViewports, and the pipeline store keys on the canonical state, so a 16-viewport draw and a single-viewport draw could share a pipeline built with viewportCount 1.

  • CanonicalPipelineState now keeps the viewport count, and the recipe codec writes it. A recipe with more than 15 extra viewports does not decode.
  • FileFormat is 18, and the guard is sizeof(State) == 1008. I measured that on Ubuntu 24.04 with GCC 13.3, where main measures 952. The old value reproduces your error at PipelineJournal.cpp:50:29, and the full Linux build now compiles.
  • The viewport and scissor values are dynamic state (vkCmdSetViewport/vkCmdSetScissor at record time), so the count is the only part of them a pipeline is built from. viewportExports reaches the pipeline through the shader identity, the same way layerExports does.

2. Index range. The index is the 4-bit field 19:16 (OpBitFieldUExtract(misc.z, 16, 4)), so it is always 0 to 15. Every pipeline that keeps it declares all 16 viewports, and multiViewport is only enabled with maxViewports >= 16, so an out-of-range index cannot reach Vulkan. Instead of a clamp that could never fire, ApplyViewportIndex now requires all 16 viewports and scissors. The debt entry says this, and that what the console draws for a slot the title left unwritten is unmeasured.

3. Test. The decoder checks viewports 5 and 15 with their own PA_SC_VPORT_SCISSOR values, and the journal recipe round-trips and rejects 17 viewports. The GPU draws now split the target into 16 strips, each with its own scissor height, and draw through indices 1, 0, 2, 7 and 15 on the vertex and mesh paths. Seven planted bugs each make it fail; the list is in Tested.

Runs (details in the PR body):

  • Windows 11, AMD Radeon 680M, validation layer 1.4.363.1: passes with no VUID- messages. 1266 of 1267 agc_driver|shader tests pass, and the remaining failure also fails on main.
  • Linux (Ubuntu 24.04 on WSL2, GCC 13.3, llvmpipe): builds; the vertex draws pass and the mesh draws skip.

I have no NVIDIA GPU, so that run is still missing. @tablefrogpillow, your Vega/RDNA2/RDNA3 Linux runs would be very welcome now that it builds.

AI-assisted: yes.

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Rebuild at 3f211973f3 now compiles on Linux (GCC 13.3) — the PipelineJournal.cpp static_assert(sizeof(State) == 952) break is resolved. Ran the test on three AMD generations (RADV, Mesa 26.2.6), validation layer 1.4.363 (no VUID-):

GPU agc_driver_viewport_index
Vega (VEGA10, gfx900, GCN5) 3/3 pass, 0 VUID
RDNA2 (RAPHAEL, gfx1036) 3/3 pass, 0 VUID
RDNA3 (NAVI31, gfx1100) 3/3 pass, 0 VUID

Per-vertex viewport/scissor selection via PA_CL_VS_OUT_CNTL.USE_VTX_VIEWPORT_INDX produces correct results across GCN5, RDNA2 and RDNA3. (A pass confirmation — a negative control that reverts the production files doesn't compile, since the test uses the new viewport-selection path.)

AI-assisted: yes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@c1b3r-p3d1a the journal count, the 16 viewport declaration and the extra test cases look good to me, and the RADV runs on this head are clean. One thing blocks it:

The decode now reads the scissors and transforms of viewports 1 to 15 (0x96 + 2 * index and 0x10f + 6 * index in State.cpp), but DrawKeyRegisters in Graphics/include/State.hpp still covers only viewport 0 ({RegisterBank::Context, 0x094, 2} and {RegisterBank::Context, 0x10f, 6}). With the register draw key on, a draw that changes only viewport 3 hits a cached recipe and keeps the old viewports. The new test calls DecodeState directly, so it does not see this.

Could you:

  1. widen those two ranges to {RegisterBank::Context, 0x094, 0x20} and {RegisterBank::Context, 0x10f, 0x60} (the pin at tests/Graphics.cpp:638 still holds), and
  2. add a read log check to ViewportIndex.cpp like the one at tests/Graphics.cpp:637, so every register the multi viewport decode reads must pass DrawKeyCovers.

Optional while you are there: the vertex arm of ApplyViewportIndex checks only multiViewport. On a device without VK_EXT_shader_viewport_index_layer that draw would fail shader validation instead of staying on viewport 0, so && context.viewportIndexLayer there would be safer.

The decode reads PA_SC_VPORT_SCISSOR_1..15 and PA_CL_VPORT_*_1..15, but
DrawKeyRegisters covered only viewport 0, so with the register draw key
a draw that changed only viewport 3 reused the cached recipe and kept the
old viewports. Widen the two ranges to all 16 viewports and check in the
viewport test that every register the decode reads passes DrawKeyCovers.

Vertex draws now keep the viewport index only with
VK_EXT_shader_viewport_index_layer; without it they fall back to
viewport 0 instead of failing shader validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@c1b3r-p3d1a

Copy link
Copy Markdown
Contributor Author

@oneandonlydean addressed in b35560753e:

  1. DrawKeyRegisters now has {RegisterBank::Context, 0x094, 0x20} and {RegisterBank::Context, 0x10f, 0x60}. The pin at tests/Graphics.cpp:638 still holds.
  2. ViewportIndex.cpp records the multi-viewport decode through the register facade. It requires every read to pass DrawKeyCovers, requires that viewports 1 and 15 were read (0x96, 0xb3, 0x115, 0x16e), and requires that 0x16f is not covered. Each of these fails the test: either range at its old width, 0x10f one word short, or one word too wide.
  3. The optional point is done too: the vertex arm now needs context.viewportIndexLayer. Without it the draw falls back to viewport 0, and the test checks that.

On Windows 11 with an AMD RX 7700 XT and validation layer 1.4.368, agc_driver_viewport_index passes 3 of 3 runs with no VUID- messages. The full suite results are in Tested. I still have no NVIDIA or Linux GPU run for this head.

@tablefrogpillow

Copy link
Copy Markdown
Contributor

Re-verified on the updated head b35560753e, which widens the DrawKeyRegisters ranges to cover viewports 1–15 and adds the DrawKeyCovers read-log check to ViewportIndex.cpp. Still clean on all three AMD generations (RADV, Mesa 26.2.6), validation layer 1.4.363:

GPU agc_driver_viewport_index
Vega (VEGA10, GCN5) 3/3 pass, 0 VUID
RDNA2 (RAPHAEL, gfx1036) 3/3 pass, 0 VUID
RDNA3 (NAVI31, gfx1100) 3/3 pass, 0 VUID

The widened register draw key and the new read-log assertion hold on GCN5, RDNA2 and RDNA3; 0 VUID- in every run.

AI-assisted: yes.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
c1b3r-p3d1a and others added 2 commits November 14, 2026 11:05
# Conflicts:
#	core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp
#	core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@c1b3r-p3d1a

Copy link
Copy Markdown
Contributor Author

Merged main (2cebbe43ee) into this branch to clear the conflict (e55363873d), plus one test commit (9fb9bb367a).

Conflict. main moved Pipeline::Continue and the back-face pass onto CommandState, which skips a vkCmdSetViewport/vkCmdSetScissor when the cached value is unchanged. Calling the old direct vkCmdSetViewport(0, N, ...) next to that cache would leave it stale: after a 16-viewport draw, a single-viewport draw that wants the cached viewport 0 back would be skipped.

  • setViewports now takes the CommandState. With one viewport it calls SetViewport/SetScissor as main does.
  • With more than one, the new CommandState::SetViewports writes the whole array and records viewport 0 and scissor 0 as the cached values.

Tested (Windows 11, WinLibs GCC 15.2, RX 7700 XT, Release, staged .prx refreshed):

  • agc_driver_viewport_index, agc_driver_graphics, agc_driver_depth_bias_per_face*, agc_driver_pipeline*, agc_driver_pipelined*: 46 of 47 passed. agc_driver_pipelined_clock_copy was Not Run: its executable is not built in my tree. It is unrelated to this change.
  • commandStateTests has a new case: a viewport array, then the same viewport 0 (no emit), then a different one (emitted). If SetViewports does not update the cached viewport, that case fails.
  • tools/check_conventions.py --base origin/main passed.

AI-assisted: yes.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@c1b3r-p3d1a the merge of main dropped a needed edit. PipelineJournal.cpp:59 has FileFormat = 18u on this head, and main is already at 18 (the compute-pipeline-table-size change took it from 17). This PR still writes a new record field (extraViewports, a U32 after the existing state) and the State size assert moves from 952 to 1008, so a journal written by main at format 18 has no such word and would be read wrongly by this head, which accepts the same version.

Please set FileFormat to 19u. Nothing else in the tests names the number, so that one line should be enough; rebuild agc_pipeline_journal after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@c1b3r-p3d1a

c1b3r-p3d1a commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@oneandonlydean thanks, you're right: both sides had moved 17 to 18, so the merge kept 18 with a different record layout. c74e348678 sets FileFormat to 19, and the PR description now says 19.

Rebuilt and ran agc_pipeline_journal, agc_pipeline_journal_long_paths, agc_pipeline_journal_replay_priority, agc_pipeline_journal_extended_paths, agc_driver_pipeline_journal, agc_driver_pipeline_journal_undecodable_module and agc_driver_viewport_index: all 7 passed (Windows, RX 7700 XT, WinLibs GCC 15.2, staged .prx refreshed). check_conventions.py --base origin/main passes.

AI-assisted: yes.

@NathanFahey23

Copy link
Copy Markdown
Contributor

Head c74e348678 merges onto main b885c40a67 without a conflict (a0cef0eff9), but the merge no longer compiles:

core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:1975:75: error: 'areaFree' was not declared in this scope
 1975 |             const bool vCollapsed = (vxs == 0 || vys == 0) && vxs >= 0 && areaFree && std::isfinite(vxo) && ...

main changed the scope underneath this PR: bade67338c (#16053, "start the color masks and viewport control at their reset values") moved the viewport-0 transform read, including const bool areaFree = ... and collapsed, inside a block (now State.cpp:1869 on main). This PR's per-viewport loop still uses areaFree after that block, where it is no longer in scope. Hoisting areaFree out of the block, or computing it again for the extra viewports, should fix it; I have not tried either.

Setup: Windows 11 Home 10.0.26300, WinLibs GCC 15.2.0, Release, git merge --no-ff of the head onto main as the CI build jobs do. Only this one object failed; nothing was run.

AI-assisted: yes

@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

NVIDIA run with the Khronos validation layer, since the description lists none and the Linux runs above are on RADV.

Setup: Arch Linux, kernel 7.3.4, GCC 16.2.1 Release, NVIDIA GeForce RTX 4090 (10de:2684), driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 66f058c2ac merged with --no-ff onto main e4caa07950 (e649cde6a8, clean merge).

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R '^(agc_driver_(viewport_index|mesh_provoking_layer|layered_array_color_draw|pipeline_journal|pipeline_journal_undecodable_module|graphics)|agc_pipeline_journal|agc_pipeline_journal_long_paths)$' -V
main e4caa07950 this PR
Result 7/7 passed 8/8 passed
agc_driver_viewport_index does not exist on main passed (viewport index tests passed: the vertex and mesh paths draw into the viewport their vertices select)
Insert instance layer "VK_LAYER_KHRONOS_validation" 27 28
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

agc_driver_mesh_provoking_layer, agc_driver_layered_array_color_draw, agc_driver_graphics and the four pipeline journal tests pass on both sides. Both logs show Selected GPU name=NVIDIA GeForce RTX 4090. agc_driver_pipeline_journal takes 3.4 s on both sides (3 runs each).

No new VUID- errors; all focused tests pass on Ada, including the mesh path.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit c27193c into boykopovar:main Nov 16, 2026
16 checks passed
chitters2004 added a commit to chitters2004/AnyPS5 that referenced this pull request Nov 17, 2026
…re-derive the limits

The census counted one 256-draw batch, so whether earlier draws' pool
slots and draw-use records were free again depended on how far the GPU
had got, and the count moved with machine load. Each measured submit now
holds 8 leading and 32 measured draws, the driver waits for the GPU to go
idle after every submit, and a run of the same submits with only the
leading draws is subtracted, so per-submit setup cancels and every
measured draw starts from the same completed state. The every-draw call
site counts are exact across idle and loaded runs; bytes move by up to
316 per draw when a pool grows once.

The limits were this pull request's own constants against an older main
and a different measurement. They are re-derived from Linux fork CI run
44098566795 (three runs plain, six pipelined), the census being
Linux-only because the Windows driver allocates through its DLL's own
operator new: the highest allocations per draw plus 0.5, the highest
bytes per draw plus 400, which absorbs one pool growth while the count
limits still catch any new allocation, and the every-draw counts exact.

Measured on the same method, main since this branch's last base adds 24
bytes to every draw (DrawTail keeps userPatches, boykopovar#19267) and 16 to an
index copy from image memory (Context in Buffer, boykopovar#20368, boykopovar#19373,
boykopovar#18842); allocation counts are unchanged.

CI-Tests: ^agc_driver_draw_allocations|^agc_driver_indirect_draw_pending_producer$
CI-Jobs: linux-gate, windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011mLh2bE18haVtnPYp4NK3J
chitters2004 added a commit to chitters2004/AnyPS5 that referenced this pull request Nov 17, 2026
…re-derive the limits

The census counted one 256-draw batch, so whether earlier draws' pool
slots and draw-use records were free again depended on how far the GPU
had got, and the count moved with machine load. Each measured submit now
holds 8 leading and 32 measured draws, the driver waits for the GPU to go
idle after every submit, and a run of the same submits with only the
leading draws is subtracted, so per-submit setup cancels and every
measured draw starts from the same completed state. The every-draw call
site counts are exact across idle and loaded runs; bytes move by up to
316 per draw when a pool grows once.

The limits were this pull request's own constants against an older main
and a different measurement. They are re-derived from Linux fork CI run
44098566795 (three runs plain, six pipelined), the census being
Linux-only because the Windows driver allocates through its DLL's own
operator new: the highest allocations per draw plus 0.5, the highest
bytes per draw plus 400, which absorbs one pool growth while the count
limits still catch any new allocation, and the every-draw counts exact.

Measured on the same method, main since this branch's last base adds 24
bytes to every draw (DrawTail keeps userPatches, boykopovar#19267) and 16 to an
index copy from image memory (Context in Buffer, boykopovar#20368, boykopovar#19373,
boykopovar#18842); allocation counts are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants