Repository navigation
feat(agc): select viewports from vertex and mesh viewport index exports - #19373
Conversation
|
Heads up — on a clean build on Linux (GCC 13.3.0) this doesn't compile: The new Confirmed with AI-assisted: yes. |
|
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:
|
|
Windows check of head
AI-assisted: yes. |
|
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.
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.
|
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>
9663c76 to
3f21197
Compare
|
@oneandonlydean @tablefrogpillow thanks, all three are addressed in 1. Journal codec and the size guard. The assert was hiding a real bug:
2. Index range. The index is the 4-bit field 19:16 ( 3. Test. The decoder checks viewports 5 and 15 with their own Runs (details in the PR body):
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. |
|
Rebuild at
Per-vertex viewport/scissor selection via AI-assisted: yes. |
|
@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 ( Could you:
Optional while you are there: the vertex arm of |
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>
|
@oneandonlydean addressed in
On Windows 11 with an AMD RX 7700 XT and validation layer 1.4.368, |
|
Re-verified on the updated head
The widened register draw key and the new read-log assertion hold on GCN5, RDNA2 and RDNA3; 0 AI-assisted: yes. |
# 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>
|
Merged Conflict.
Tested (Windows 11, WinLibs GCC 15.2, RX 7700 XT, Release, staged
AI-assisted: yes. |
|
@c1b3r-p3d1a the merge of main dropped a needed edit. Please set |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean thanks, you're right: both sides had moved 17 to 18, so the merge kept 18 with a different record layout. Rebuilt and ran AI-assisted: yes. |
|
Head
Setup: Windows 11 Home 10.0.26300, WinLibs GCC 15.2.0, Release, AI-assisted: yes |
|
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
No new AI-assisted: yes (Claude Code) |
…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
…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.
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:State.cpp): when bit 19 is set, viewports 1 to 15 are read fromPA_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 withPA_SC_VPORT_SCISSOR_i(0x94 + 2i) whenPA_SC_MODE_CNTL_0.VPORT_SCISSOR_ENABLEis 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.ApplyViewportIndexrequires it). No index is out of range, so nothing is clamped.multiViewportis enabled whenmaxViewports >= 16. Pipelines takeviewportCount/scissorCountfrom the state (it is part of the pipeline key and the draw-register key), andvkCmdSetViewport/vkCmdSetScissorset all 16.State.hpp):DrawKeyRegisterscoversPA_SC_VPORT_SCISSOR_0..15(0x094, 0x20 words) andPA_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.PipelineJournal.cpp):CanonicalPipelineStatekeeps 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 theStatesize guard is 1008. Viewports and scissors are dynamic state, so the count is the only part of them a pipeline is built from.ViewportIndexthroughShaderViewportIndexLayerEXTwhen the device hasVK_EXT_shader_viewport_index_layer, otherwise through the SPIR-V 1.5 capability. The mesh shader writes a per-primitiveViewportIndexblock (PerPrimitiveEXT,MultiViewport) from the provoking vertex, the same wayLayeris 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.multiViewport, and vertex draws on devices withoutVK_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 withoutVK_EXT_depth_range_unrestricted, because the remap is single-viewport. OnlyPA_SC_VPORT_ZMIN/ZMAX_0is 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
ShaderViewportIndexLayerEXTfor layer output in their compute emulation.Overlap: #16752 rewrites the
vkCmdSetViewport/vkCmdSetScissorcalls inPipeline::Continue/ContinueBackFacesthatsetViewportsreplaces here, so whichever merges second has to movesetViewportsonto itsCommandState. I moved theDrawDecode.cppandShaderValidation.cpphunks off the lines #16025, #17022 and #17911 change; a merge simulation against them is clean.Tested
Head
b35560753eonmain92b550a7c4, no title. It merges cleanly withmaine22c5fb941.This head (draw key ranges and the
viewportIndexLayergate), Windows 11 (26300), AMD Radeon RX 7700 XT, AMD driver 32.0.32015.7029:agc_driver_viewport_indexnow records every register the multi-viewport decode reads through the register facade, requires that it read viewports 1 and 15 (0x96,0xb3,0x115,0x16e), thatDrawKeyCoversholds every one of them, and that0x16fis not covered. It also checks that a vertex draw on amultiViewportdevice withoutVK_EXT_shader_viewport_index_layerfalls back to viewport 0. The pin attests/Graphics.cpp:638still holds.viewportIndexLayercondition.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1),agc_driver_viewport_indexpasses 3 of 3 runs with the vertex and mesh draws; each log shows the layer inserted and noVUID-messages.agc_driver|shadersuite (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) andagc_driver_sample_order_grid_referencefail. They test shader arithmetic and sample positions this PR does not touch, and they failed the same way onmainin my earlier baseline run; I did not rerunmainfor this head.agc_driver_dumped_constant_capturefailed in the suite and in 1 of 9 runs alone (8 passed), so it is intermittent.Previous head
3f211973f3:agc_driver_viewport_index:PA_CL_VPORTregisters andPA_SC_VPORT_SCISSOR, the other slots are empty, 16 scissors and their union, stripping withoutmultiViewportor 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.PA_SC_VPORT_SCISSORregister, and reading the index from bit 17.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:agc_driver_viewport_index(vertex and mesh draws),agc_driver_mesh_provoking_layerandagc_driver_layered_array_color_drawpass. Each log showsInsert instance layer "VK_LAYER_KHRONOS_validation", there is nowas not found but was requested, and there are noVUID-messages.main, the two existing tests run the same way, also with noVUID-messages.agc_driver_viewport_indexpasses 3 of 3 runs, 0.4 s each.agc_driver|shadersuite (1267 tests): 1266 pass.agc_driver_sample_order_grid_referencefails, and fails the same way onmainon this GPU.agc_driver_graphicsfailed once under-j 8on a partially resident depth plane check and passes 3 of 3 runs alone.Statesize guard inPipelineJournal.cpp.agc_driver_viewport_indexpasses 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_graphicsandagc_driver_layered_array_color_drawpass;agc_driver_mesh_provoking_layerskips for the same reason. No validation layer on this Linux setup.python3 tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pycould not confirm overlaps, so I compared the PRs that share files by hand (see What).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)