feat(agc): draw tessellation followed by an NGG geometry stage #6612

Merged
milescoviello merged 7 commits from upstream-pr/6612 into main 2026-10-27 01:56:18 +00:00
milescoviello commented 2026-10-15 22:54:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T22:54:03Z.


What

Crimson Desert (PPSA25286, 01.000.568) stops on main 12 to 14 s in, while it resolves the shader ABIs of its first graphics stages:

terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: VGT_SHADER_STAGES_EN=0x60212d: combined tessellation and geometry is unsupported by the reference path

Its tessellated draws feed an NGG geometry stage. From a throwaway print of the first one:

Register Value Meaning
VGT_SHADER_STAGES_EN 0x60212d LS_EN, HS_EN, ES_EN = DS, GS_EN, PRIMGEN_EN, HS_W32, GS_W32
SPI_SHADER_PGM_LO_LS (0x148) registered type 3 one program holding the local and the hull half; nothing at SPI_SHADER_PGM_LO_HS
SPI_SHADER_PGM_LO_ES (0xc8) registered type 2 merged domain and geometry program
VGT_LS_HS_CONFIG / VGT_TF_PARAM 0x1043f / 0x4004a 4 control points in and out, quad domain, fractional-odd
VGT_ESGS_RING_ITEMSIZE / VGT_GS_MAX_VERT_OUT / GE_MAX_OUTPUT_PER_SUBGROUP 4 / 6 / 192 a 4-dword item per vertex; up to a 6-vertex strip per triangle

main refuses the combination, and with that refusal lifted it would refuse wave32 tessellation next. The enum already has ShaderPath::TessellationGeometry, unused until now. This PR draws that path.

How

The geometry half needs the subgroup: its threads share LDS, use s_barrier and allocate their output with GS_ALLOC_REQ, which only the mesh path runs. A Vulkan geometry shader can't run it per triangle, and a mesh shader can't follow the tessellator. So the draw takes two passes:

  1. The tessellation pipeline, with rasterizer discard. The domain role compiles only the program's vertex half: the code up to the target of its first s_cbranch_execz, which skips the vertex threads' part. Its ESGS LDS writes (thread index × item size) become domain outputs. A generated geometry shader (BuildTessellationCaptureGeometryShader) appends each tessellated triangle's three items to a device-local buffer and keeps the mesh draw arguments in a small header: one group per primitivesPerGroup triangles, and three indices per triangle.
  2. The mesh path draws the same program as a mesh shader, with no vertex threads in s3. Its entry copies the group's captured items into LDS where the vertex half would have written them, then runs the geometry half unchanged. It is drawn with vkCmdDrawMeshTasksIndirectEXT from the header, after a geometry-shader-write to indirect/mesh-read barrier, in a new render pass.

The hull side:

  • Stacked on #6679. The first commit here is #6679's, which runs a registered type-3 merged hull (0x148 holding both halves, nothing at 0x108). Draw decode takes that merged hull on this path too. This PR used to split the program into a local role and a hull role. That split can't keep the local part's VGPRs live across the barrier, and it required the hull user-data address, which 007 First Light leaves unset (SleglJan's run). So it's gone, and #6679's approach handles both titles.
  • Crimson Desert's merged hull passes 16-bit values through LDS, and #6679 accepts only 32-bit LDS accesses in tessellation stages. This PR adds 16-bit LDS reads and writes there, as a read-modify-write of the 32-bit attribute word. For #6679's ControlShared records, the read of a write uses the lane's own record, and the bounds checks use the 2-byte end.
  • HS_W32 and GS_W32 are accepted: local and hull programs compile with the hull wave size, domain and mesh programs with the geometry one.

The compile modes follow from fields the request already serializes (a mesh configuration on a domain program, a tessellation configuration on a mesh program). The request format doesn't change beyond #6679's version 37; the cache key gains a word for each new mode.

The approximations are in the technical debt files: triangles reach the geometry half in the order the capture claims them, at most 2^20 per draw, the geometry half's primitive ID is the captured triangle's index, and instanced draws throw.

Tested

Capture draw after an ordinary draw in one batch (004f49875e, after @oneandonlydean's review): the capture pass now keys its render pass by rasterizer discard, so it can't continue an open pass that has attachments. A new agc_driver_tessellation_geometry case records an ordinary tessellation draw and then a tessellation-geometry draw into the same resident target with no wait between, and compares the image with the ordinary draw alone.

  • Khronos layer 1.4.363 over the 12 tessellation and journal tests: with the new case and without the key change (a371244bf8), VUID-vkCmdDrawIndexed-colorAttachmentCount-06179 x2. With the change, no VUID- messages; 12 of 12 pass on both.

  • The 12 tests pass 3 of 3 on Linux. On the Windows 11 VM (GT 1030, WinLibs GCC 15.2.0 r7), the merge base passes 11 of 11 3 of 3 and this head 12 of 12 3 of 3.

  • Current head 1168a21b8c, rebased onto main 2dc85609fc, which changed Draw(): it takes a DrawTraceContext (#5431) and the driver's Draw.cpp gained <algorithm>. drawTessellationGeometry now takes the draw's trace context and passes it to both of its inner draws, so traced tessellation-geometry draws keep their trace; the include conflict keeps main's <algorithm> and this branch's <map>. The journal format stays 12 (main is at 10), and the guards stay 904 / 160 (main's 832 / 112 plus this branch's fields), confirmed by the build. The 12 tests below pass 3 of 3 on this head. On the Windows 11 VM (GT 1030, WinLibs GCC 15.2.0 r7), the merge base passes 11 of 11 and this head 12 of 12, 3 runs each, with agc_driver_tessellation_geometry skipped there (no mesh shaders).

  • 75a06af9a9, rebased onto main c035bd5b7 after b76ab1f6c0 (one-fragment multisampled colour targets) grew State to 832 bytes there; the only conflict was the journal's size guard, which is now 904 (832 plus this branch's 72), with ShaderStages at 160. The 12 tests below pass 3 of 3 on this head.

  • d175c08f94, rebased onto main d0e7fe7beb after #9348 took journal format 10; the only conflict was that line, and this branch keeps its provisional 12 (#8365 takes 11) until it is set to main+1 at landing. The 12 tests below pass 3 of 3 on this head.

  • b6f3131b54, rebased onto main c9b75825f3 after #8999, which conflicted in Draw(): main now opens it with DepthCopySourceScope, and this branch's early return for tessellation followed by a geometry stage comes right after that scope, so it covers those draws too. The 12 tests below pass 3 of 3 on this head.

  • ce4748f0fa: e6db936606 plus a fix from @oneandonlydean's review. ImpliesNot returned at a negated condition, so a predicate !!a (a complemented own-lane ballot bit of !a after lane-bit lowering) never proved !a false, alone or in either order of a conjunction; each check now falls through when it doesn't prove the negation. Three new agc_tessellation_lowering cases build that hull read and must lower at its address; with main's ImpliesNot all three are refused 3 of 3 (not a whole number of control points), and with the fix the 12 tests below pass 3 of 3.

  • e6db936606 was rebased onto main d098eca3d6, which conflicted in TessellationLowering.cpp: main added ImpliesNot, which covers what this branch's Excludes did (a predicate that implies a condition's negation) and also a negated condition, so the branch calls ImpliesNot at its two sites and drops Excludes. The journal commit takes format 12. main is at 9, and 10 is also used by #6959, #8212 and #10420 and 11 by #8365, so this bump can't merge silently with any of theirs. Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, 615.71.09): the tessellation, pipeline journal, agc_driver_graphics and pixel LDS tests (12) pass 3 of 3.

  • Previous head ae86a022f6, on main 11d6efa06c: the same 12 passed 3 of 3 on Linux, and on f28839f3c5 on the Windows 11 VM (GT 1030, 582.66, WinLibs GCC 15.2.0 r7), with agc_driver_tessellation_geometry skipped there (no mesh shaders).

Earlier heads: Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.

  • agc_driver_tessellation_geometry (new, GPU). It draws Tessellation.cpp's three patches (levels 1, 0 and 5) through the plain tessellation path, then through the new path, with a merged domain and geometry program. That program writes the same position and colour as an 8-dword item, and its geometry half (the mesh fixture's NGG program reading items instead of indices) emits each triangle unchanged. The two images must be equal in every pixel, unculled and back-face culled, for wave64 and wave32 stages. The same comparison runs again into a resident tiled target, where both draws are recorded into the open batch (the path titles take), byte for byte. A last part registers a type-3 merged hull and the merged domain program and resolves their graphics ABI, which compiles all four roles through draw decode, once at wave64 and once with HS_W32 (as Crimson Desert sets it). A throwaway check that throws when a wave32 merged hull is compiled fails only with the HS_W32 registration.
  • agc_driver_tessellation: two variants of #6679's merged hull program use 16-bit LDS accesses with the same values, so the patches must draw exactly as with the 32-bit program. @SleglJan's case splits the local part's x-position write into ds_write_b16_d16_hi (high half first) and ds_write_b16. The second half's read-modify-write must then keep the first, and the value is read back through the control point's own record. It fails if that read uses control point 0's record, or if it merges into 0 instead of the record's current word. The other case splits a 32-bit read of the level into ds_read_u16 and ds_read_u16_d16_hi. My first version split only a write that is never read back, which SleglJan found didn't check the write side. With #6679 alone, the cases fail with only 32-bit LDS reads and writes are supported in tessellation stages at pc 0x84.
  • agc_driver_graphics: 0x60212d decodes as TessellationGeometry with the expected subgroup (10 triangles of 30 vertices, 192 threads, wave32 hull and domain) and only registers the draw key covers. 0x0260210d decodes as wave32 tessellation. PRIMGEN_PASSTHRU or a missing PRIMGEN_EN with GS_EN is refused.
  • Red/green: the new and changed tests in agc_driver_tessellation_geometry and agc_driver_graphics use the new state fields and the capture shader, so they don't build on main or on #6679. The new Tessellation.cpp case fails on #6679 as above. All three pass 3 of 3 with this PR.
  • Rebased 10-23 onto main b7a451d62b (head 8783ad1e29), after #6801 merged, as @oneandonlydean asked. The journal format is 9, and sizeof(State) is 896 on the rebased tree, confirmed by the build's static_assert. ShaderStages stays 160. The recipe codec and canonical state carry #6801's point fields and this PR's rasterizer discard. ShaderRegistry.cpp keeps #6801's ApplyPointSize and this PR's StageMeshConfiguration, and ShaderInputInfoBuilder.cpp keeps both new flags. The 17 tests matching ^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry pass 3 of 3. With the Khronos validation layer (1.4.363), main passes 16 of 16 and this head 17 of 17, with no VUID. On the Windows 11 VM (GT 1030, R580), the 18 matching tests pass 3 of 3 on this head, agc_driver_tessellation_geometry included.
  • Rebased 10-22 again, onto main f6075c2f4a (head a785b13a95), after #7948 grew State from 784 to 800 bytes. The one conflict was the size check in PipelineJournal.cpp; it is now 872, main's 800 plus this PR's 72, and ShaderStages stays 160. The build confirms both. On that head (Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, 615.71.09), the 17 tests matching ^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry pass 3 of 3. Under the Khronos 1.4.363 layer, the same set passes on main (16, without this PR's test) and on this head (17), with no VUID- message on either side. The journal format stays 7 here; #8115 and #8365 also take 7, so whichever lands later renumbers.
  • Rebased 10-22 onto main cc0078595d (head 6aa4f7cc7f). #8992 split Graphics::Draw into a prepare and a record step. drawTessellationGeometry now sits just before the new Draw, and the hand-off to it is at the top of that function. It still draws both passes through Draw, and the Draw.cpp change is otherwise line for line the same. The journal format stays 7 and sizeof(State) stays 856. The 17 tests matching ^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry pass 3 of 3, agc_driver_tessellation_geometry among them.
  • Rebased 10-21 onto main 275e896797 (head dfc290f4ae). #7869 took journal format 6 for its polygon modes, so the journal commit now takes 7. Pipeline.cpp keeps main's polygonMode lines, with this PR's rasterizerDiscardEnable after them. sizeof(State) stays 856. The 8 tests matching tess|Tess|hull|Hull|pipeline_journal|^agc_driver_graphics$ pass 2 of 2.
  • Restacked 10-19 (evening) onto #6679's head 30541537b6 (main 3aa4448ed3), head 09356fedba. #6941 merged with request version 38, so #6679 now reads its merged-hull flag from 39, and this PR reads it from there with the rest of #6679 (it adds no version of its own). Four conflicts came from main's mesh barycentric change (#6941). In CacheKey.hpp, appendMesh keeps #6941's pixel key and barycentric layout, and this PR's domain-stage ESGS key and tessellation tag. The tag comes before the barycentric block, which can return early. In ShaderValidation.cpp, both added extension clauses stay, along with #6941's per-primitive checks and this PR's position check under rasterizer discard. In Draw.cpp, the tessellation geometry stage is inserted before #6941's barycentric pairing. In DrawCapture.cpp, this PR's push limit and mesh configuration take #6941's barycentric argument. The 16 tests matching ^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry pass 3 of 3. Under the LunarG SDK's 1.4.363 layer, ^agc_driver_graphics$|tessellation|journal|mesh|geometry gives no validation messages on #6679's head (14 tests) or on this head (15).
  • Restacked 10-19 (later) onto #6679's rebased head 83a04aba09 (main 0fbfd91e5e), head 77d218a50a. #6679 now writes request version 38 and resolves both conflicts adriadam10 listed: #6931's indirect record words and the serializer fixtures. This PR's three commits apply on it without a conflict. The 635 broad-set tests pass on main, and 636 of 636 with this PR. The tessellation, journal and serializer tests pass 3 of 3. Under the LunarG SDK's 1.4.363 layer, tess|journal reports nothing on main or on this head.
  • Head 22587edfa0: the LunarG SDK's 1.4.363 layer found VUID-vkCmdDrawIndexed-colorAttachmentCount-06179 ×12 in the capture pass. A discarding pipeline has no fragment output state, so it has no color attachments, while the pass began rendering with the draw's targets. Pipeline::Begin now begins a discarding pass with no attachments. Under 1.4.363, tess|journal reports nothing on main f72c7aacfa or on this head. The 631 broad-set tests pass, and the tessellation, journal and serializer tests pass 3 of 3.
  • Khronos validation, as CONTRIBUTING.md now asks (Ubuntu's 1.3.275 layer through VK_LAYER_PATH, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V, RTX 4070 Ti, tess|journal). Neither log reports the layer missing. On 235f5130c0 it found two errors this PR added, 9 each, in agc_driver_tessellation_geometry: VUID-VkGraphicsPipelineCreateInfo-pStages-06894 and VUID-RuntimeSpirv-OpEntryPoint-08743. The capture pass discards its primitives but still carried the pixel program, which reads a location the capture geometry stage doesn't write. Head 7570d583d6 leaves the pixel program out of that pass: it has four stages, and ValidateShaders expects four and checks no color exports for it. The pixel program still runs in the mesh pass that draws the captured triangles. Now main f72c7aacfa and this PR report only VkDeviceCreateInfo-pNext-pNext and VkGraphicsPipelineCreateInfo-pLibraries-06681, which this older layer gives for every device-creating test, and nothing new. The 631 broad-set tests pass, and the tessellation, journal and serializer tests pass 3 of 3.
  • Rebased 10-19 onto main f72c7aacfa (head 235f5130c0), with #6679's commit still first, as @adriadam10 asked. The one conflict was main's bool quadList (#6529) next to this PR's rasterizerDiscard and tessellationCapture in State.hpp, and both are kept. sizeof(State) stays 856, because the bool fits in padding, so the journal guards are unchanged. Quad-list draws are never journaled: Draw.cpp clears recipeOut for them, and the recorder returns NotRecordable. So the codec doesn't carry quadList, and a decoded recipe's false is what it was recorded with. The 630 tests in the broad driver/recompiler/journal set pass on f72c7aacfa, and 631 of 631 with this PR. The tessellation, journal and serializer tests pass 3 of 3.
  • Restacked 10-19 (later) onto #6679's head 3b69fde441, head 847628a460. #4650 (depth remap) and #6503 (f32 flush-to-zero, request version 36) landed under #6679 in the meantime, and #6679 now writes request version 37. StagePushLimit now also takes the depth remap limit, in main's order: mesh, tessellation before rasterization, depth remap, then the slot. The push-constant validation keeps both the depth-remap push and the tessellation capture terms. The journal guards name the new State (856 bytes) and ShaderStages (160 bytes) sizes, and the journal format becomes 6, since #5656 took 5 on main. The AGC, shader, request, journal and tessellation set passes 614 of 615, against 613 of 614 on 3b69fde441 alone; the one failure on both is agc_driver_bda_device (#7584). The 6 tessellation, serializer and journal tests pass 3 of 3.
  • Restacked 10-19 onto #6679's head 4e7fa2be55 (on main 324e0e48e0), head 9825024871; it merges with main 7bc7905978 cleanly. Two conflicts, both from main: in ShaderRegistry.cpp the stage loop now computes the push offset, then the deferral check, then decodes the vertex stage inside its try, and this PR's StageWaveSize and StageMeshConfiguration replace the fixed wave size and stages.mesh there; in Draw.cpp this PR's || captured sits beside main's KeepMultisampleTarget loop. The AGC, shader, request, journal and tessellation set passes 609 of 610, against 608 of 609 on 4e7fa2be55 alone; the one failure on both is agc_driver_bda_device (#7584). The 6 tessellation, serializer and journal tests pass 3 of 3.
  • Restacked 10-17 onto #6679's 01947dd9b6 (head c2464855be), which merges with main 17cfb1f4cb cleanly: the 6 tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3, and the AGC area suite passes 897 of 898. The one failure is agc_driver_store_over_untracked, which also fails under -j6 here without this PR and passes alone.
  • Rebased onto main 3e3e8b9050 (723155ed20; #6679's commit still first). #7374 now sets the provoking vertex of geometry programs from PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST where DecodeShaderStages builds the MeshConfiguration. This PR builds it in the shared meshConfiguration, so that computation moved there, and the tessellation geometry path gets it too. ctest -R ^agc_: 710/710 pass, including the two provoking vertex tests.
  • Restacked 10-16 onto #6679's 36529f17d (its merged hull flag now from request version 32), rebased onto main 4524944: the 7 tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3, and the 502 area tests pass except main's agc_driver_graphics (#6792) and agc_driver_store_over_untracked.
  • Before that, rebased onto main 82ddae75b (10-16). #5884's line-strip output (outputPrimitiveSize) now goes through the shared meshConfiguration in State.cpp, which the tessellation-geometry path also uses; #5804's terminate-invocation checks and this PR's capture rules both stay in ShaderValidation.cpp. #5875's pipeline journal guards State and ShaderStages, so e4c4725f4 adds the hull wave size, the geometry stage after tessellation, the merged hull flag and rasterizer discard to its codec and canonical state, with journal format 4. A pipeline drawn with a tessellation capture validates against that draw's capture buffers, so it isn't journaled. ctest (^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv|^agc_shader|bda|journal, 502 tests, with #6789's one-line test fix applied so agc_driver_graphics runs to the end): 501 pass. agc_driver_tessellation, agc_driver_tessellation_geometry, agc_driver_graphics, agc_driver_prepared_graphics and the journal tests pass 3 of 3; a recipe with these fields must decode with them. agc_driver_store_over_untracked fails the same way on main; #6385 addresses it. #6679 then read its merged hull flag under request version 31, which main uses for #5884; SleglJan moved it to version 32 (36529f17d). (On an earlier head, jotitadev found an agc_driver_prepared_graphics failure that my stale binary had hidden. That code is now #6679's, and the test passes.)

Crimson Desert, scripted pad input:

Build Result
main 5d9dcc42d stops 14 s in on the refusal above
the head before the restack (0eeb8159b) gets past it, and stops 123 s in on a registered NGG passthrough vertex program: SPIR-V emission failed: ... opcode=Barrier reason=s_barrier in a vertex program that accesses LDS or GDS or writes memory is not implemented
de9f0f71c with #6613 and #6178 (for memory) runs to the 240 s limit with no stop

The title is still building shaders and pipelines then and hasn't issued a draw, so it hasn't drawn the new path yet. With #6706 as well, which makes its large compute pipelines about 3x faster to create, it reaches its first draw at 597 s and stops there on AGC graphics: fragment shader must export float4 colors to its attachments, which is a separate change. In a 905 s run (the previous head with #6613 and #6178), the shaders finish after about 7 minutes. After that, eleven compute pipelines of 110,000 to 870,000 SPIR-V words take 2 to 137 s each to create on NVIDIA, about 570 s in all, and the first draw still hasn't come. That's a separate problem, which I'm looking at. The rendering is checked by the tests above only.

On the previous head (0eeb8159b), jotitadev ran it on an RTX 3070 (595.99.02) and on lavapipe (Mesa 26.0.3), Ubuntu 26.04, and confirmed the area tests there.

SleglJan reviewed the merged hull parts of de9f0f71c on an RTX 3080 (NVIDIA 615.78.08, CachyOS). ctest -R 'tess|hull|prepared_graphics|shader_memory|request' passed 10 of 10, and agc_driver_tessellation and agc_driver_tessellation_geometry passed 3 of 3 each.

On de9f0f71c:

  • lavapipe (llvmpipe, LLVM 20.1.2): the 30 tests matching ^agc_driver_(prepared|graphics$|tessellation|ngg|mesh|vertex|registered) pass or skip, and tools/check_skips.py --job linux accepts the 6 skips. agc_driver_tessellation now runs its merged hull cases there, because #6679 runs the merged hull at one lane per invocation. agc_driver_tessellation_geometry still skips, since the capture needs subgroup operations in tessellation stages.
  • Intel VM (Arrow Lake iGPU, Mesa 26.1.6 ANV, Debian 13): agc_driver_tessellation and agc_driver_tessellation_geometry pass 3 of 3 with no skips.

@LeandroLP23 ran it on Windows 11 with an AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001) (comment), in one build of main 6efb7261b with this PR and six other pull requests: agc_driver_tessellation, agc_driver_tessellation_geometry, agc_driver_graphics, agc_driver_prepared_graphics and agc_driver_store_over_untracked pass 3 runs of 3.
@JJenkx ran this head, rebased unchanged onto main 25c1aa1e79, on an AMD Radeon RX 6650 XT (RADV NAVI23, Linux) with Khronos validation (comment). They used a Mesa 26.2.5 build with two nir_opt_varyings.c fixes, because system RADV already segfaults while linking main's tessellation test pipelines. The nine groups both builds share pass 3 of 3 on main, and the same groups plus agc_driver_tessellation_geometry pass 3 of 3 with this PR, with no VUID. Cocoon (PPSA08766) stops at about 82 s on both builds. On this PR it stops at the routing guard, since its VGT_SHADER_STAGES_EN 0x2135 sets ES_EN to 2 where this path takes 1.

@klosixgaming-arch ran Cocoon on Windows with this PR merged onto current main (comment): it builds, and the title still stops after about 80 s at this PR's guard on VGT_SHADER_STAGES_EN=0x2135. That value has LS and HS on with ES_EN = 2, a routing this PR does not take (it takes ES_EN = 1, the domain shader in the ES stage); see the note to JJenkx.

  • Capture capacity (b478c407a7, after @oneandonlydean's review): every domain now gets 2 · level² slots per patch, where triangle patches had level², too few from level 5 on (3n²/2 triangles). A new agc_driver_tessellation_geometry case draws the level-5 triangle patch alone at VGT_HOS_MAX_TESS_LEVEL 5 and must match the tessellation path's image. With the old sizing it fails 3 of 3 (a dropped triangle). With the fix it passes 3 of 3, as does agc_driver_tessellation.

Not checked on a console.

Other open PRs touch neighbouring lines in the same files (for example #6176 in ConstantFolder.cpp, #6188 in DrawCapture.cpp, #6215 in Draw.cpp). None of them draws this path; whichever lands second needs a small 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 (#6679, which this built on, is merged)
  • Unblocks: #6613, for Crimson Desert
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99, Ubuntu 24.04; Intel Arrow Lake iGPU, Mesa 26.1.6 ANV, Debian 13 (tests only); lavapipe, Ubuntu 24.04 (tests only); NVIDIA GeForce RTX 3070 and lavapipe on Ubuntu 26.04 (jotitadev, previous head, tests only); AMD Radeon 860M, driver 32.0.13058.8001, Windows 11 (tests, by @LeandroLP23); AMD Radeon RX 6650 XT, RADV (Mesa 26.2.5 with two nir_opt_varyings fixes), Linux (tests, by @JJenkx)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4880893664 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-15T22:54:03Z. --- ### What Crimson Desert (PPSA25286, 01.000.568) stops on `main` 12 to 14 s in, while it resolves the shader ABIs of its first graphics stages: ``` terminate called after throwing an instance of 'std::runtime_error' what(): AGC graphics: VGT_SHADER_STAGES_EN=0x60212d: combined tessellation and geometry is unsupported by the reference path ``` Its tessellated draws feed an NGG geometry stage. From a throwaway print of the first one: | Register | Value | Meaning | |---|---|---| | `VGT_SHADER_STAGES_EN` | `0x60212d` | LS_EN, HS_EN, ES_EN = DS, GS_EN, PRIMGEN_EN, HS_W32, GS_W32 | | `SPI_SHADER_PGM_LO_LS` (0x148) | registered type 3 | one program holding the local and the hull half; nothing at `SPI_SHADER_PGM_LO_HS` | | `SPI_SHADER_PGM_LO_ES` (0xc8) | registered type 2 | merged domain and geometry program | | `VGT_LS_HS_CONFIG` / `VGT_TF_PARAM` | `0x1043f` / `0x4004a` | 4 control points in and out, quad domain, fractional-odd | | `VGT_ESGS_RING_ITEMSIZE` / `VGT_GS_MAX_VERT_OUT` / `GE_MAX_OUTPUT_PER_SUBGROUP` | 4 / 6 / 192 | a 4-dword item per vertex; up to a 6-vertex strip per triangle | `main` refuses the combination, and with that refusal lifted it would refuse wave32 tessellation next. The enum already has `ShaderPath::TessellationGeometry`, unused until now. This PR draws that path. ### How The geometry half needs the subgroup: its threads share LDS, use `s_barrier` and allocate their output with `GS_ALLOC_REQ`, which only the mesh path runs. A Vulkan geometry shader can't run it per triangle, and a mesh shader can't follow the tessellator. So the draw takes two passes: 1. The tessellation pipeline, with rasterizer discard. The domain role compiles only the program's vertex half: the code up to the target of its first `s_cbranch_execz`, which skips the vertex threads' part. Its ESGS LDS writes (thread index × item size) become domain outputs. A generated geometry shader (`BuildTessellationCaptureGeometryShader`) appends each tessellated triangle's three items to a device-local buffer and keeps the mesh draw arguments in a small header: one group per `primitivesPerGroup` triangles, and three indices per triangle. 2. The mesh path draws the same program as a mesh shader, with no vertex threads in `s3`. Its entry copies the group's captured items into LDS where the vertex half would have written them, then runs the geometry half unchanged. It is drawn with `vkCmdDrawMeshTasksIndirectEXT` from the header, after a geometry-shader-write to indirect/mesh-read barrier, in a new render pass. The hull side: - **Stacked on #6679.** The first commit here is #6679's, which runs a registered type-3 merged hull (0x148 holding both halves, nothing at 0x108). Draw decode takes that merged hull on this path too. This PR used to split the program into a local role and a hull role. That split can't keep the local part's VGPRs live across the barrier, and it required the hull user-data address, which 007 First Light leaves unset ([SleglJan's run](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6207986120)). So it's gone, and #6679's approach handles both titles. - Crimson Desert's merged hull passes 16-bit values through LDS, and #6679 accepts only 32-bit LDS accesses in tessellation stages. This PR adds 16-bit LDS reads and writes there, as a read-modify-write of the 32-bit attribute word. For #6679's `ControlShared` records, the read of a write uses the lane's own record, and the bounds checks use the 2-byte end. - `HS_W32` and `GS_W32` are accepted: local and hull programs compile with the hull wave size, domain and mesh programs with the geometry one. The compile modes follow from fields the request already serializes (a mesh configuration on a domain program, a tessellation configuration on a mesh program). The request format doesn't change beyond #6679's version 37; the cache key gains a word for each new mode. The approximations are in the technical debt files: triangles reach the geometry half in the order the capture claims them, at most 2^20 per draw, the geometry half's primitive ID is the captured triangle's index, and instanced draws throw. ### Tested **Capture draw after an ordinary draw in one batch** (004f49875e, after @oneandonlydean's review): the capture pass now keys its render pass by rasterizer discard, so it can't continue an open pass that has attachments. A new `agc_driver_tessellation_geometry` case records an ordinary tessellation draw and then a tessellation-geometry draw into the same resident target with no wait between, and compares the image with the ordinary draw alone. - Khronos layer 1.4.363 over the 12 tessellation and journal tests: with the new case and without the key change (a371244bf8), `VUID-vkCmdDrawIndexed-colorAttachmentCount-06179` x2. With the change, no `VUID-` messages; 12 of 12 pass on both. - The 12 tests pass 3 of 3 on Linux. On the Windows 11 VM (GT 1030, WinLibs GCC 15.2.0 r7), the merge base passes 11 of 11 3 of 3 and this head 12 of 12 3 of 3. - **Current head** `1168a21b8c`, rebased onto `main` 2dc85609fc, which changed `Draw()`: it takes a `DrawTraceContext` (#5431) and the driver's `Draw.cpp` gained `<algorithm>`. `drawTessellationGeometry` now takes the draw's trace context and passes it to both of its inner draws, so traced tessellation-geometry draws keep their trace; the include conflict keeps `main`'s `<algorithm>` and this branch's `<map>`. The journal format stays 12 (`main` is at 10), and the guards stay 904 / 160 (`main`'s 832 / 112 plus this branch's fields), confirmed by the build. The 12 tests below pass 3 of 3 on this head. On the Windows 11 VM (GT 1030, WinLibs GCC 15.2.0 r7), the merge base passes 11 of 11 and this head 12 of 12, 3 runs each, with `agc_driver_tessellation_geometry` skipped there (no mesh shaders). - **`75a06af9a9`**, rebased onto `main` c035bd5b7 after b76ab1f6c0 (one-fragment multisampled colour targets) grew `State` to 832 bytes there; the only conflict was the journal's size guard, which is now 904 (832 plus this branch's 72), with `ShaderStages` at 160. The 12 tests below pass 3 of 3 on this head. - **`d175c08f94`**, rebased onto `main` d0e7fe7beb after #9348 took journal format 10; the only conflict was that line, and this branch keeps its provisional 12 (#8365 takes 11) until it is set to `main`+1 at landing. The 12 tests below pass 3 of 3 on this head. - **`b6f3131b54`**, rebased onto `main` c9b75825f3 after #8999, which conflicted in `Draw()`: `main` now opens it with `DepthCopySourceScope`, and this branch's early return for tessellation followed by a geometry stage comes right after that scope, so it covers those draws too. The 12 tests below pass 3 of 3 on this head. - **`ce4748f0fa`**: `e6db936606` plus a fix from @oneandonlydean's review. `ImpliesNot` returned at a negated condition, so a predicate `!!a` (a complemented own-lane ballot bit of `!a` after lane-bit lowering) never proved `!a` false, alone or in either order of a conjunction; each check now falls through when it doesn't prove the negation. Three new `agc_tessellation_lowering` cases build that hull read and must lower at its address; with `main`'s `ImpliesNot` all three are refused 3 of 3 (`not a whole number of control points`), and with the fix the 12 tests below pass 3 of 3. - `e6db936606` was rebased onto `main` d098eca3d6, which conflicted in `TessellationLowering.cpp`: `main` added `ImpliesNot`, which covers what this branch's `Excludes` did (a predicate that implies a condition's negation) and also a negated condition, so the branch calls `ImpliesNot` at its two sites and drops `Excludes`. The journal commit takes format 12. `main` is at 9, and 10 is also used by #6959, #8212 and #10420 and 11 by #8365, so this bump can't merge silently with any of theirs. Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, 615.71.09): the tessellation, pipeline journal, `agc_driver_graphics` and pixel LDS tests (12) pass 3 of 3. - **Previous head** `ae86a022f6`, on `main` 11d6efa06c: the same 12 passed 3 of 3 on Linux, and on `f28839f3c5` on the Windows 11 VM (GT 1030, 582.66, WinLibs GCC 15.2.0 r7), with `agc_driver_tessellation_geometry` skipped there (no mesh shaders). Earlier heads: Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99. - `agc_driver_tessellation_geometry` (new, GPU). It draws `Tessellation.cpp`'s three patches (levels 1, 0 and 5) through the plain tessellation path, then through the new path, with a merged domain and geometry program. That program writes the same position and colour as an 8-dword item, and its geometry half (the mesh fixture's NGG program reading items instead of indices) emits each triangle unchanged. The two images must be equal in every pixel, unculled and back-face culled, for wave64 and wave32 stages. The same comparison runs again into a resident tiled target, where both draws are recorded into the open batch (the path titles take), byte for byte. A last part registers a type-3 merged hull and the merged domain program and resolves their graphics ABI, which compiles all four roles through draw decode, once at wave64 and once with `HS_W32` (as Crimson Desert sets it). A throwaway check that throws when a wave32 merged hull is compiled fails only with the `HS_W32` registration. - `agc_driver_tessellation`: two variants of #6679's merged hull program use 16-bit LDS accesses with the same values, so the patches must draw exactly as with the 32-bit program. [@SleglJan's case](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208700520) splits the local part's x-position write into `ds_write_b16_d16_hi` (high half first) and `ds_write_b16`. The second half's read-modify-write must then keep the first, and the value is read back through the control point's own record. It fails if that read uses control point 0's record, or if it merges into 0 instead of the record's current word. The other case splits a 32-bit read of the level into `ds_read_u16` and `ds_read_u16_d16_hi`. My first version split only a write that is never read back, which SleglJan found didn't check the write side. With #6679 alone, the cases fail with `only 32-bit LDS reads and writes are supported in tessellation stages at pc 0x84`. - `agc_driver_graphics`: `0x60212d` decodes as TessellationGeometry with the expected subgroup (10 triangles of 30 vertices, 192 threads, wave32 hull and domain) and only registers the draw key covers. `0x0260210d` decodes as wave32 tessellation. PRIMGEN_PASSTHRU or a missing PRIMGEN_EN with GS_EN is refused. - Red/green: the new and changed tests in `agc_driver_tessellation_geometry` and `agc_driver_graphics` use the new state fields and the capture shader, so they don't build on `main` or on #6679. The new `Tessellation.cpp` case fails on #6679 as above. All three pass 3 of 3 with this PR. - Rebased 10-23 onto `main` b7a451d62b (head `8783ad1e29`), after #6801 merged, as @oneandonlydean asked. The journal format is 9, and `sizeof(State)` is 896 on the rebased tree, confirmed by the build's `static_assert`. `ShaderStages` stays 160. The recipe codec and canonical state carry #6801's point fields and this PR's rasterizer discard. `ShaderRegistry.cpp` keeps #6801's `ApplyPointSize` and this PR's `StageMeshConfiguration`, and `ShaderInputInfoBuilder.cpp` keeps both new flags. The 17 tests matching `^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry` pass 3 of 3. With the Khronos validation layer (1.4.363), `main` passes 16 of 16 and this head 17 of 17, with no VUID. On the Windows 11 VM (GT 1030, R580), the 18 matching tests pass 3 of 3 on this head, `agc_driver_tessellation_geometry` included. - Rebased 10-22 again, onto `main` f6075c2f4a (head `a785b13a95`), after #7948 grew `State` from 784 to 800 bytes. The one conflict was the size check in `PipelineJournal.cpp`; it is now 872, `main`'s 800 plus this PR's 72, and `ShaderStages` stays 160. The build confirms both. On that head (Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, 615.71.09), the 17 tests matching `^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry` pass 3 of 3. Under the Khronos 1.4.363 layer, the same set passes on `main` (16, without this PR's test) and on this head (17), with no `VUID-` message on either side. The journal format stays 7 here; #8115 and #8365 also take 7, so whichever lands later renumbers. - Rebased 10-22 onto `main` cc0078595d (head `6aa4f7cc7f`). #8992 split `Graphics::Draw` into a prepare and a record step. `drawTessellationGeometry` now sits just before the new `Draw`, and the hand-off to it is at the top of that function. It still draws both passes through `Draw`, and the `Draw.cpp` change is otherwise line for line the same. The journal format stays 7 and `sizeof(State)` stays 856. The 17 tests matching `^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry` pass 3 of 3, `agc_driver_tessellation_geometry` among them. - Rebased 10-21 onto `main` 275e896797 (head dfc290f4ae). #7869 took journal format 6 for its polygon modes, so the journal commit now takes 7. `Pipeline.cpp` keeps `main`'s `polygonMode` lines, with this PR's `rasterizerDiscardEnable` after them. `sizeof(State)` stays 856. The 8 tests matching `tess|Tess|hull|Hull|pipeline_journal|^agc_driver_graphics$` pass 2 of 2. - Restacked 10-19 (evening) onto #6679's head 30541537b6 (`main` 3aa4448ed3), head 09356fedba. #6941 merged with request version 38, so #6679 now reads its merged-hull flag from 39, and this PR reads it from there with the rest of #6679 (it adds no version of its own). Four conflicts came from `main`'s mesh barycentric change (#6941). In `CacheKey.hpp`, `appendMesh` keeps #6941's pixel key and barycentric layout, and this PR's domain-stage ESGS key and tessellation tag. The tag comes before the barycentric block, which can return early. In `ShaderValidation.cpp`, both added extension clauses stay, along with #6941's per-primitive checks and this PR's position check under rasterizer discard. In `Draw.cpp`, the tessellation geometry stage is inserted before #6941's barycentric pairing. In `DrawCapture.cpp`, this PR's push limit and mesh configuration take #6941's barycentric argument. The 16 tests matching `^agc_driver_graphics$|tessellation|journal|serializer|mesh|geometry` pass 3 of 3. Under the LunarG SDK's 1.4.363 layer, `^agc_driver_graphics$|tessellation|journal|mesh|geometry` gives no validation messages on #6679's head (14 tests) or on this head (15). - Restacked 10-19 (later) onto #6679's rebased head 83a04aba09 (`main` 0fbfd91e5e), head 77d218a50a. #6679 now writes request version 38 and resolves both conflicts adriadam10 listed: #6931's indirect record words and the serializer fixtures. This PR's three commits apply on it without a conflict. The 635 broad-set tests pass on `main`, and 636 of 636 with this PR. The tessellation, journal and serializer tests pass 3 of 3. Under the LunarG SDK's 1.4.363 layer, `tess|journal` reports nothing on `main` or on this head. - Head 22587edfa0: the LunarG SDK's 1.4.363 layer found `VUID-vkCmdDrawIndexed-colorAttachmentCount-06179` ×12 in the capture pass. A discarding pipeline has no fragment output state, so it has no color attachments, while the pass began rendering with the draw's targets. `Pipeline::Begin` now begins a discarding pass with no attachments. Under 1.4.363, `tess|journal` reports nothing on `main` f72c7aacfa or on this head. The 631 broad-set tests pass, and the tessellation, journal and serializer tests pass 3 of 3. - Khronos validation, as CONTRIBUTING.md now asks (Ubuntu's 1.3.275 layer through `VK_LAYER_PATH`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V`, RTX 4070 Ti, `tess|journal`). Neither log reports the layer missing. On 235f5130c0 it found two errors this PR added, 9 each, in `agc_driver_tessellation_geometry`: `VUID-VkGraphicsPipelineCreateInfo-pStages-06894` and `VUID-RuntimeSpirv-OpEntryPoint-08743`. The capture pass discards its primitives but still carried the pixel program, which reads a location the capture geometry stage doesn't write. Head 7570d583d6 leaves the pixel program out of that pass: it has four stages, and `ValidateShaders` expects four and checks no color exports for it. The pixel program still runs in the mesh pass that draws the captured triangles. Now `main` f72c7aacfa and this PR report only `VkDeviceCreateInfo-pNext-pNext` and `VkGraphicsPipelineCreateInfo-pLibraries-06681`, which this older layer gives for every device-creating test, and nothing new. The 631 broad-set tests pass, and the tessellation, journal and serializer tests pass 3 of 3. - Rebased 10-19 onto `main` f72c7aacfa (head 235f5130c0), with #6679's commit still first, as @adriadam10 asked. The one conflict was `main`'s `bool quadList` (#6529) next to this PR's `rasterizerDiscard` and `tessellationCapture` in `State.hpp`, and both are kept. `sizeof(State)` stays 856, because the bool fits in padding, so the journal guards are unchanged. Quad-list draws are never journaled: `Draw.cpp` clears `recipeOut` for them, and the recorder returns `NotRecordable`. So the codec doesn't carry `quadList`, and a decoded recipe's `false` is what it was recorded with. The 630 tests in the broad driver/recompiler/journal set pass on f72c7aacfa, and 631 of 631 with this PR. The tessellation, journal and serializer tests pass 3 of 3. - Restacked 10-19 (later) onto #6679's head 3b69fde441, head 847628a460. #4650 (depth remap) and #6503 (f32 flush-to-zero, request version 36) landed under #6679 in the meantime, and #6679 now writes request version 37. `StagePushLimit` now also takes the depth remap limit, in `main`'s order: mesh, tessellation before rasterization, depth remap, then the slot. The push-constant validation keeps both the depth-remap push and the tessellation capture terms. The journal guards name the new `State` (856 bytes) and `ShaderStages` (160 bytes) sizes, and the journal format becomes 6, since #5656 took 5 on `main`. The AGC, shader, request, journal and tessellation set passes 614 of 615, against 613 of 614 on 3b69fde441 alone; the one failure on both is `agc_driver_bda_device` (#7584). The 6 tessellation, serializer and journal tests pass 3 of 3. - Restacked 10-19 onto #6679's head 4e7fa2be55 (on `main` 324e0e48e0), head 9825024871; it merges with `main` 7bc7905978 cleanly. Two conflicts, both from `main`: in `ShaderRegistry.cpp` the stage loop now computes the push offset, then the deferral check, then decodes the vertex stage inside its `try`, and this PR's `StageWaveSize` and `StageMeshConfiguration` replace the fixed wave size and `stages.mesh` there; in `Draw.cpp` this PR's `|| captured` sits beside `main`'s `KeepMultisampleTarget` loop. The AGC, shader, request, journal and tessellation set passes 609 of 610, against 608 of 609 on 4e7fa2be55 alone; the one failure on both is `agc_driver_bda_device` (#7584). The 6 tessellation, serializer and journal tests pass 3 of 3. - Restacked 10-17 onto #6679's 01947dd9b6 (head c2464855be), which merges with `main` 17cfb1f4cb cleanly: the 6 tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3, and the AGC area suite passes 897 of 898. The one failure is `agc_driver_store_over_untracked`, which also fails under `-j6` here without this PR and passes alone. - Rebased onto `main` 3e3e8b9050 (723155ed20; #6679's commit still first). #7374 now sets the provoking vertex of geometry programs from `PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST` where `DecodeShaderStages` builds the `MeshConfiguration`. This PR builds it in the shared `meshConfiguration`, so that computation moved there, and the tessellation geometry path gets it too. `ctest -R ^agc_`: 710/710 pass, including the two provoking vertex tests. - Restacked 10-16 onto #6679's 36529f17d (its merged hull flag now from request version 32), rebased onto `main` 4524944: the 7 tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3, and the 502 area tests pass except `main`'s `agc_driver_graphics` (#6792) and `agc_driver_store_over_untracked`. - Before that, rebased onto `main` 82ddae75b (10-16). #5884's line-strip output (`outputPrimitiveSize`) now goes through the shared `meshConfiguration` in `State.cpp`, which the tessellation-geometry path also uses; #5804's terminate-invocation checks and this PR's capture rules both stay in `ShaderValidation.cpp`. #5875's pipeline journal guards `State` and `ShaderStages`, so e4c4725f4 adds the hull wave size, the geometry stage after tessellation, the merged hull flag and rasterizer discard to its codec and canonical state, with journal format 4. A pipeline drawn with a tessellation capture validates against that draw's capture buffers, so it isn't journaled. ctest (`^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv|^agc_shader|bda|journal`, 502 tests, with #6789's one-line test fix applied so `agc_driver_graphics` runs to the end): 501 pass. `agc_driver_tessellation`, `agc_driver_tessellation_geometry`, `agc_driver_graphics`, `agc_driver_prepared_graphics` and the journal tests pass 3 of 3; a recipe with these fields must decode with them. `agc_driver_store_over_untracked` fails the same way on `main`; #6385 addresses it. #6679 then read its merged hull flag under request version 31, which `main` uses for #5884; SleglJan moved it to version 32 (36529f17d). (On an earlier head, [jotitadev found](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5542083461) an `agc_driver_prepared_graphics` failure that my stale binary had hidden. That code is now #6679's, and the test passes.) Crimson Desert, scripted pad input: | Build | Result | |---|---| | `main` 5d9dcc42d | stops 14 s in on the refusal above | | the head before the restack (0eeb8159b) | gets past it, and stops 123 s in on a registered NGG passthrough vertex program: `SPIR-V emission failed: ... opcode=Barrier reason=s_barrier in a vertex program that accesses LDS or GDS or writes memory is not implemented` | | de9f0f71c with #6613 and #6178 (for memory) | runs to the 240 s limit with no stop | The title is still building shaders and pipelines then and hasn't issued a draw, so it hasn't drawn the new path yet. With #6706 as well, which makes its large compute pipelines about 3x faster to create, it reaches its first draw at 597 s and stops there on `AGC graphics: fragment shader must export float4 colors to its attachments`, which is a separate change. In a 905 s run (the previous head with #6613 and #6178), the shaders finish after about 7 minutes. After that, eleven compute pipelines of 110,000 to 870,000 SPIR-V words take 2 to 137 s each to create on NVIDIA, about 570 s in all, and the first draw still hasn't come. That's a separate problem, which I'm looking at. The rendering is checked by the tests above only. On the previous head (0eeb8159b), jotitadev ran it on an RTX 3070 (595.99.02) and on lavapipe (Mesa 26.0.3), Ubuntu 26.04, and [confirmed](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5542490351) the area tests there. SleglJan [reviewed the merged hull parts of de9f0f71c](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208700520) on an RTX 3080 (NVIDIA 615.78.08, CachyOS). `ctest -R 'tess|hull|prepared_graphics|shader_memory|request'` passed 10 of 10, and `agc_driver_tessellation` and `agc_driver_tessellation_geometry` passed 3 of 3 each. On de9f0f71c: - lavapipe (llvmpipe, LLVM 20.1.2): the 30 tests matching `^agc_driver_(prepared|graphics$|tessellation|ngg|mesh|vertex|registered)` pass or skip, and `tools/check_skips.py --job linux` accepts the 6 skips. `agc_driver_tessellation` now runs its merged hull cases there, because #6679 runs the merged hull at one lane per invocation. `agc_driver_tessellation_geometry` still skips, since the capture needs subgroup operations in tessellation stages. - Intel VM (Arrow Lake iGPU, Mesa 26.1.6 ANV, Debian 13): `agc_driver_tessellation` and `agc_driver_tessellation_geometry` pass 3 of 3 with no skips. @LeandroLP23 ran it on Windows 11 with an AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001) ([comment](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6252729904)), in one build of `main` 6efb7261b with this PR and six other pull requests: `agc_driver_tessellation`, `agc_driver_tessellation_geometry`, `agc_driver_graphics`, `agc_driver_prepared_graphics` and `agc_driver_store_over_untracked` pass 3 runs of 3. @JJenkx ran this head, rebased unchanged onto `main` 25c1aa1e79, on an AMD Radeon RX 6650 XT (RADV NAVI23, Linux) with Khronos validation ([comment](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6393165482)). They used a Mesa 26.2.5 build with two `nir_opt_varyings.c` fixes, because system RADV already segfaults while linking `main`'s tessellation test pipelines. The nine groups both builds share pass 3 of 3 on `main`, and the same groups plus `agc_driver_tessellation_geometry` pass 3 of 3 with this PR, with no VUID. Cocoon (PPSA08766) stops at about 82 s on both builds. On this PR it stops at the routing guard, since its `VGT_SHADER_STAGES_EN` 0x2135 sets `ES_EN` to 2 where this path takes 1. @klosixgaming-arch ran Cocoon on Windows with this PR merged onto current `main` ([comment](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6405122053)): it builds, and the title still stops after about 80 s at this PR's guard on `VGT_SHADER_STAGES_EN=0x2135`. That value has LS and HS on with `ES_EN` = 2, a routing this PR does not take (it takes `ES_EN` = 1, the domain shader in the ES stage); see the [note to JJenkx](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6393178019). - Capture capacity (b478c407a7, after @oneandonlydean's review): every domain now gets `2 · level²` slots per patch, where triangle patches had `level²`, too few from level 5 on (`3n²/2` triangles). A new `agc_driver_tessellation_geometry` case draws the level-5 triangle patch alone at `VGT_HOS_MAX_TESS_LEVEL` 5 and must match the tessellation path's image. With the old sizing it fails 3 of 3 (a dropped triangle). With the fix it passes 3 of 3, as does `agc_driver_tessellation`. Not checked on a console. Other open PRs touch neighbouring lines in the same files (for example #6176 in `ConstantFolder.cpp`, #6188 in `DrawCapture.cpp`, #6215 in `Draw.cpp`). None of them draws this path; whichever lands second needs a small rebase. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#6679, which this built on, is merged) - [x] Unblocks: #6613, for Crimson Desert - [x] GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99, Ubuntu 24.04; Intel Arrow Lake iGPU, Mesa 26.1.6 ANV, Debian 13 (tests only); lavapipe, Ubuntu 24.04 (tests only); NVIDIA GeForce RTX 3070 and lavapipe on Ubuntu 26.04 (jotitadev, previous head, tests only); AMD Radeon 860M, driver 32.0.13058.8001, Windows 11 (tests, by @LeandroLP23); AMD Radeon RX 6650 XT, RADV (Mesa 26.2.5 with two nir_opt_varyings fixes), Linux (tests, by @JJenkx) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jotitadev commented 2026-10-16 01:55:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T01:55:59Z.

Review: COMMENTED


Two failures on Linux that the PR body doesn't list.

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head 89aa76a76 merged into main 5d9dcc42d (clean merge).

1. agc_driver_prepared_graphics fails with this PR on every run.

  • RTX 3070: 5/5 fail, also with ANYPS5_NO_SHADER_CACHE=1. lavapipe: 3/3 fail. Unchanged main passes it on both.
  • It stops at AGC driver: registered program refers to an incompatible shader binary type, the check at the end of RegisteredProgram in ShaderRegistry.cpp. The last lines before it are the ReportPreparedAtUse notes for stages 5 and 7.
  • The other 15 ^agc_driver_prepared tests pass.
  • The body's run (^agc_driver_|..., 468 of 469) should include this test, so maybe that binary was stale?

2. On lavapipe, which the Linux CI job uses, the new tessellation cases fail.

  • agc_driver_tessellation: AGC graphics: subgroup capability 61 is unsupported for shader stage 2.
  • agc_driver_tessellation_geometry: the same for shader stage 4.
  • Both fail 3/3. Capability 61 is GroupNonUniform, and lavapipe's subgroupSupportedStages is only fragment, compute, task and mesh, so it refuses the merged program's tessellation-control and tessellation-evaluation modules. The RTX 3070 has subgroups in those stages, and there both tests pass 3/3.
  • With the PR's sources and main's Tessellation.cpp (the separate local/hull pair only), agc_driver_tessellation passes 3/3 on lavapipe. So the existing coverage still works there, and only the new merged case and the new test need subgroup support in tessellation stages.
  • They probably need a skip (or a non-subgroup lowering) when subgroupSupportedStages lacks those stages. A skip message that names subgroup support already passes tools/check_skips.py.

Otherwise, on the RTX 3070:

  • agc_driver_tessellation, agc_driver_tessellation_geometry and agc_driver_graphics pass 3/3.
  • The test-only build doesn't compile against main (new state fields), as the body says.
  • ctest -R "^agc|shader|recompiler" -j1 (flip, display and lds_atomics64 excluded): 2 failures. One is prepared_graphics above. The other is store_over_untracked, which also fails on main here (#6347).

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5542083461 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5542083461). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T01:55:59Z. **Review:** COMMENTED --- Two failures on Linux that the PR body doesn't list. **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `89aa76a76` merged into `main` `5d9dcc42d` (clean merge). **1. `agc_driver_prepared_graphics` fails with this PR on every run.** - RTX 3070: 5/5 fail, also with `ANYPS5_NO_SHADER_CACHE=1`. lavapipe: 3/3 fail. Unchanged `main` passes it on both. - It stops at `AGC driver: registered program refers to an incompatible shader binary type`, the check at the end of `RegisteredProgram` in `ShaderRegistry.cpp`. The last lines before it are the `ReportPreparedAtUse` notes for stages 5 and 7. - The other 15 `^agc_driver_prepared` tests pass. - The body's run (`^agc_driver_|...`, 468 of 469) should include this test, so maybe that binary was stale? **2. On lavapipe, which the Linux CI job uses, the new tessellation cases fail.** - `agc_driver_tessellation`: `AGC graphics: subgroup capability 61 is unsupported for shader stage 2`. - `agc_driver_tessellation_geometry`: the same for `shader stage 4`. - Both fail 3/3. Capability 61 is `GroupNonUniform`, and lavapipe's `subgroupSupportedStages` is only fragment, compute, task and mesh, so it refuses the merged program's tessellation-control and tessellation-evaluation modules. The RTX 3070 has subgroups in those stages, and there both tests pass 3/3. - With the PR's sources and `main`'s `Tessellation.cpp` (the separate local/hull pair only), `agc_driver_tessellation` passes 3/3 on lavapipe. So the existing coverage still works there, and only the new merged case and the new test need subgroup support in tessellation stages. - They probably need a skip (or a non-subgroup lowering) when `subgroupSupportedStages` lacks those stages. A skip message that names subgroup support already passes `tools/check_skips.py`. **Otherwise, on the RTX 3070:** - `agc_driver_tessellation`, `agc_driver_tessellation_geometry` and `agc_driver_graphics` pass 3/3. - The test-only build doesn't compile against `main` (new state fields), as the body says. - `ctest -R "^agc|shader|recompiler" -j1` (flip, display and `lds_atomics64` excluded): 2 failures. One is `prepared_graphics` above. The other is `store_over_untracked`, which also fails on `main` here (#6347). GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
milescoviello commented 2026-10-16 02:03:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T02:03:32Z.


@jotitadev Thank you, both are real, and both are fixed in 0eeb8159b.

1. agc_driver_prepared_graphics. Draw decode checked the local slot (0x148) for a merged type-3 hull by asking RegisteredProgram for type 3 alone. That throws registered program refers to an incompatible shader binary type whenever an ordinary type-5 local program is registered there, which is this test's setup. It now asks for type 3 or 5 and takes the merged local and hull roles only for type 3, so a separate pair decodes as on main. The test passes 3 of 3 here now. You're right that my earlier count was wrong: my binary of that test must have been stale. I've corrected the description.

2. lavapipe. As you found, the merged program and the captured domain half need subgroup operations in tessellation-control and tessellation-evaluation shaders. The merged case of agc_driver_tessellation and the whole of agc_driver_tessellation_geometry now skip when SubgroupStages() lacks the stage, with a message that names the missing subgroup support. On this machine's lavapipe, agc_driver_tessellation passes with the merged case skipped and agc_driver_tessellation_geometry skips. The 30 ^agc_driver_(prepared|graphics$|tessellation|ngg|mesh|vertex|registered) tests pass or skip. On the RTX 4070 Ti nothing changes: the area suite is 468 of 469, with only store_over_untracked failing, as on main.

I've added your runs to the description.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6206372134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6206372134). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-16T02:03:32Z. --- @jotitadev Thank you, both are real, and both are fixed in 0eeb8159b. **1. `agc_driver_prepared_graphics`.** Draw decode checked the local slot (0x148) for a merged type-3 hull by asking `RegisteredProgram` for type 3 alone. That throws `registered program refers to an incompatible shader binary type` whenever an ordinary type-5 local program is registered there, which is this test's setup. It now asks for type 3 or 5 and takes the merged local and hull roles only for type 3, so a separate pair decodes as on `main`. The test passes 3 of 3 here now. You're right that my earlier count was wrong: my binary of that test must have been stale. I've corrected the description. **2. lavapipe.** As you found, the merged program and the captured domain half need subgroup operations in tessellation-control and tessellation-evaluation shaders. The merged case of `agc_driver_tessellation` and the whole of `agc_driver_tessellation_geometry` now skip when `SubgroupStages()` lacks the stage, with a message that names the missing subgroup support. On this machine's lavapipe, `agc_driver_tessellation` passes with the merged case skipped and `agc_driver_tessellation_geometry` skips. The 30 `^agc_driver_(prepared|graphics$|tessellation|ngg|mesh|vertex|registered)` tests pass or skip. On the RTX 4070 Ti nothing changes: the area suite is 468 of 469, with only `store_over_untracked` failing, as on `main`. I've added your runs to the description. AI-assisted: yes
jotitadev commented 2026-10-16 02:58:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T02:58:30Z.

Review: COMMENTED


Both fixes confirmed on my machine at 0eeb8159b.

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head 0eeb8159b merged into main 5d9dcc42d (clean merge), -j1 --timeout 30.

  • agc_driver_prepared_graphics: passes 3/3 on the RTX 3070 and 3/3 on lavapipe (previously 5/5 and 3/3 failures).
  • lavapipe: agc_driver_tessellation passes 3/3 with the merged case skipped ("needs subgroup operations in tessellation-control shaders"); agc_driver_tessellation_geometry skips 3/3.
  • RTX 3070: both tessellation tests pass 3/3, merged case included.
  • ^agc_driver_(prepared|graphics$|tessellation|ngg|mesh|vertex|registered): 30/30 on the RTX 3070. On lavapipe, 30/30 with 6 skipped: tessellation_geometry plus the 5 mesh/NGG/clip-distance tests that also skip on main. tools/check_skips.py --job linux on that lavapipe JUnit: all 6 skips expected.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5542490351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5542490351). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T02:58:30Z. **Review:** COMMENTED --- Both fixes confirmed on my machine at `0eeb8159b`. **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `0eeb8159b` merged into `main` `5d9dcc42d` (clean merge), `-j1 --timeout 30`. - `agc_driver_prepared_graphics`: passes 3/3 on the RTX 3070 and 3/3 on lavapipe (previously 5/5 and 3/3 failures). - lavapipe: `agc_driver_tessellation` passes 3/3 with the merged case skipped ("needs subgroup operations in tessellation-control shaders"); `agc_driver_tessellation_geometry` skips 3/3. - RTX 3070: both tessellation tests pass 3/3, merged case included. - `^agc_driver_(prepared|graphics$|tessellation|ngg|mesh|vertex|registered)`: 30/30 on the RTX 3070. On lavapipe, 30/30 with 6 skipped: `tessellation_geometry` plus the 5 mesh/NGG/clip-distance tests that also skip on `main`. `tools/check_skips.py --job linux` on that lavapipe JUnit: all 6 skips expected. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
SleglJan commented 2026-10-16 04:19:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-16T04:19:24Z.


Data from 007 First Light (PPSA11386 v01.018.000), which registers its tessellation hull programs as type 3 too, on Linux 7.2.10, RTX 3080, driver 615.78.08, in a bubblewrap sandbox. Stack: main 4186f06a9 plus open PRs, unpublished local fixes the title needs, local logging and scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only). For this run my merged-hull change (#6679) was reverted and this PR's head 89aa76a76 merged instead, which brings main up to 5d9dcc42d.

  • The title stops in its level load after present 1195 with merged shader user-data address is null (the require in InitializeMerged, DrawDecode.cpp): a merged hull draw there leaves the hull user-data address (SH 0x102/0x103) null.
  • The same stack with #6679 in place of this PR (on main 4186f06a9, without the merge up to 5d9dcc42d) passes the level load and reaches gameplay's first tutorial prompt. #6679 makes the address optional for a merged program (s[0:1] zero when the draw leaves it unset); I have not run this PR with only that check relaxed.
  • The current head 0eeb8159b requires the address the same way; its decode change only lets a registered type-5 local program take the separate path.
  • The two PRs differ in more places (how the program is split, lane mode, the indirect draw record words); #6679 lists them under Overlap.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6207986120 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6207986120). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-16T04:19:24Z. --- Data from 007 First Light (PPSA11386 v01.018.000), which registers its tessellation hull programs as type 3 too, on Linux 7.2.10, RTX 3080, driver 615.78.08, in a bubblewrap sandbox. Stack: `main` 4186f06a9 plus open PRs, unpublished local fixes the title needs, local logging and scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only). For this run my merged-hull change (#6679) was reverted and this PR's head 89aa76a76 merged instead, which brings `main` up to 5d9dcc42d. - The title stops in its level load after present 1195 with `merged shader user-data address is null` (the `require` in `InitializeMerged`, `DrawDecode.cpp`): a merged hull draw there leaves the hull user-data address (SH 0x102/0x103) null. - The same stack with #6679 in place of this PR (on `main` 4186f06a9, without the merge up to 5d9dcc42d) passes the level load and reaches gameplay's first tutorial prompt. #6679 makes the address optional for a merged program (`s[0:1]` zero when the draw leaves it unset); I have not run this PR with only that check relaxed. - The current head 0eeb8159b requires the address the same way; its decode change only lets a registered type-5 local program take the separate path. - The two PRs differ in more places (how the program is split, lane mode, the indirect draw record words); #6679 lists them under Overlap. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-16 04:21:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T04:21:44Z.


Thanks @SleglJan, that settles it. #6612's type-3 split requires the hull user-data address, and 007 First Light leaves it unset. Your #6679 handles that and also keeps VGPRs live across the barrier, which my split can't. So #6679 should own registered merged hulls.

I'll restack #6612 on #6679: drop its type-3 split and keep only the tessellation-to-geometry path, marked "Depends on: #6679". Then I'll check that Crimson Desert gets past its 13 s stop on #6679's merged hull. Its merged program passes 16-bit values through LDS, so that's the part to check. A trial merge conflicts in 8 files (draw decode, registry, cache key, stage IO, tessellation lowering, recompiler), so it will take a while. I'll post here when it's done.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208011895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208011895). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-16T04:21:44Z. --- Thanks @SleglJan, that settles it. #6612's type-3 split requires the hull user-data address, and 007 First Light leaves it unset. Your #6679 handles that and also keeps VGPRs live across the barrier, which my split can't. So #6679 should own registered merged hulls. I'll restack #6612 on #6679: drop its type-3 split and keep only the tessellation-to-geometry path, marked "Depends on: #6679". Then I'll check that Crimson Desert gets past its 13 s stop on #6679's merged hull. Its merged program passes 16-bit values through LDS, so that's the part to check. A trial merge conflicts in 8 files (draw decode, registry, cache key, stage IO, tessellation lowering, recompiler), so it will take a while. I'll post here when it's done. AI-assisted: yes
SleglJan commented 2026-10-16 04:25:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-16T04:25:28Z.


Thanks, sounds good. One heads-up for the Crimson Desert check: #6679 keeps main's 32-bit limit on LDS accesses in tessellation stages, so a LoadSharedU16/WriteSharedU16 in the merged program fails there with only 32-bit LDS reads and writes are supported in tessellation stages. Your 16-bit handling from #6612 (the half-width access with ConvertU16U32/ConvertU32U16 around it) is the right approach, but it won't carry over as is. It only accepts LocalOutput and ControlInput, while #6679 lowers every LDS access in the merged program as ControlShared. Two things to adapt: the ControlShared bounds checks need the 2-byte end for a half access, and the write's read-modify-write has to read the lane's own record. A ControlShared read is emitted as a read of another control point's record (address / shared stride), so a read at an address that isn't indexed by invocation gets control point 0's record. Happy to review it on the restacked #6612.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208054437 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208054437). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-16T04:25:28Z. --- Thanks, sounds good. One heads-up for the Crimson Desert check: #6679 keeps `main`'s 32-bit limit on LDS accesses in tessellation stages, so a `LoadSharedU16`/`WriteSharedU16` in the merged program fails there with `only 32-bit LDS reads and writes are supported in tessellation stages`. Your 16-bit handling from #6612 (the half-width access with `ConvertU16U32`/`ConvertU32U16` around it) is the right approach, but it won't carry over as is. It only accepts `LocalOutput` and `ControlInput`, while #6679 lowers every LDS access in the merged program as `ControlShared`. Two things to adapt: the `ControlShared` bounds checks need the 2-byte end for a half access, and the write's read-modify-write has to read the lane's own record. A `ControlShared` read is emitted as a read of another control point's record (address / shared stride), so a read at an address that isn't indexed by invocation gets control point 0's record. Happy to review it on the restacked #6612. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-16 04:59:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T04:59:15Z.


Restacked on #6679 at de9f0f71c (the first commit is #6679's 8f93aa0bd). The type-3 split is gone; draw decode takes #6679's merged hull on the tessellation-plus-geometry path too.

@SleglJan, your two points are in: a ControlShared 16-bit write reads the lane's own record for its read-modify-write, and the bounds checks use the 2-byte end. The new agc_driver_tessellation case splits one 32-bit LDS write and one 32-bit read of your MergedHullCode into b16/d16_hi pairs. It fails on #6679 alone at the write (only 32-bit LDS ... at pc 0x84) and passes 3 of 3 here. Crimson Desert with #6613 and #6178 runs to my 240 s limit with no stop, like before the restack. Details and lavapipe/Intel results are in the description.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208434360 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208434360). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-16T04:59:15Z. --- Restacked on #6679 at de9f0f71c (the first commit is #6679's 8f93aa0bd). The type-3 split is gone; draw decode takes #6679's merged hull on the tessellation-plus-geometry path too. @SleglJan, your two points are in: a `ControlShared` 16-bit write reads the lane's own record for its read-modify-write, and the bounds checks use the 2-byte end. The new `agc_driver_tessellation` case splits one 32-bit LDS write and one 32-bit read of your `MergedHullCode` into `b16`/`d16_hi` pairs. It fails on #6679 alone at the write (`only 32-bit LDS ... at pc 0x84`) and passes 3 of 3 here. Crimson Desert with #6613 and #6178 runs to my 240 s limit with no stop, like before the restack. Details and lavapipe/Intel results are in the description. AI-assisted: yes
SleglJan commented 2026-10-16 05:21:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-16T05:21:48Z.


I reviewed the parts of de9f0f71c that touch #6679's merged hull: the 16-bit ControlShared lowering, draw decode on the tessellation-plus-geometry path, and the new agc_driver_tessellation case.

The lowering looks right. A half write's read now uses InvocationId × shared stride + (offset & ~3), and the emitter turns that into the same [gl_InvocationID] element that the write stores to. A ControlShared write has to stay in its own record, so no two invocations write the same word. The 2-byte end is used for both reads and writes, and odd offsets are refused. Draw decode takes the merged hull through the same branch on the new path, and #6679's refusals are unchanged.

The new test case doesn't exercise the write side, though:

  • The split write is the local part's ds_write_b32 v7 at offset 16, and the hull part never reads offset 16 of a record. It reads its own record at 0 to 15, control point 2's at +8 (the level), and control points 1 and 2 at +0.
  • The split read at 72/74 reads the level. Levels 1, 0 and 5 have a zero low half, and every control point of a patch carries the same level.
  • On an RTX 3080 the case still passes 3 of 3 with either of two changes to rewrite():
    • the read-modify-write reads address, which is control point 0's record (the case from my earlier comment);
    • it merges into 0 instead of existing.

The variant below splits the x-position write instead. It writes the high half first, so the second write's read-modify-write has to keep it. The x position has non-zero low halves, differs per control point, and is read back through the own-record ds_read_b128 and the ds_read2_b32. It passes 3 of 3 on de9f0f71c and fails 3 of 3 under both changes:

alignas(256) constexpr auto MergedHullHalfRecord = [] {
    std::array<std::uint32_t, MergedHullCode.size() + 6u> code{};
    std::size_t at = 0;
    for (std::size_t index = 0; index < MergedHullCode.size(); ++index) {
        const auto word = MergedHullCode[index];
        if (word == 0xbf88001cu) {
            code[at++] = 0xbf880020u;
        } else if (word == 0xd9340000u) {
            ++index;
            for (const auto value : {0xda840002u, 0x0000080au, 0xd87c0000u, 0x0000080au, 0xd8340004u, 0x0000090au}) code[at++] = value;
        } else if (word == 0xd8d80048u) {
            const auto operands = MergedHullCode[++index];
            for (const auto value : {0xd8f00048u, operands, 0xda9c004au, operands}) code[at++] = value;
        } else {
            code[at++] = word;
        }
    }
    return code;
}();

That turns ds_write_b64 v10, v[8:9] into ds_write_b16_d16_hi v10, v8 offset:2, ds_write_b16 v10, v8 and ds_write_b32 v10, v9 offset:4, and moves s_cbranch_execz from 28 to 32. Your read split stays. It runs with the same RequirePatches(..., MergedTriangles, MergedHullHalfRecord) call as your case, either in place of MergedHullHalfWords or next to it.

A coverage gap on the lane side: this PR lets the merged hull run with HS_W32, which Crimson Desert's 0x60212d sets, but no test compiles or draws a wave32 merged hull. Tessellation.cpp compiles at 64. TessellationGeometry.cpp draws wave32 only with the separate local/hull pair and registers its merged hull with 0x212d (wave64). Registering one with HS_W32 there would cover it. agc_driver_graphics decodes 0x60212d without compiling it.

Tested on Linux 7.2.10 (CachyOS), RTX 3080, NVIDIA 615.78.08, GCC 16.2.1, Release:

  • ctest -R 'tess|hull|prepared_graphics|shader_memory|request': 10 of 10 pass, no skips.
  • agc_driver_tessellation and agc_driver_tessellation_geometry each pass 3 of 3, and agc_driver_graphics passes.
  • Your new case on 8f93aa0bd, with only the Tessellation.cpp change applied, fails 3 of 3 with only 32-bit LDS reads and writes are supported in tessellation stages at pc 0x84.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208700520 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208700520). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-16T05:21:48Z. --- I reviewed the parts of de9f0f71c that touch #6679's merged hull: the 16-bit `ControlShared` lowering, draw decode on the tessellation-plus-geometry path, and the new `agc_driver_tessellation` case. The lowering looks right. A half write's read now uses `InvocationId × shared stride + (offset & ~3)`, and the emitter turns that into the same `[gl_InvocationID]` element that the write stores to. A `ControlShared` write has to stay in its own record, so no two invocations write the same word. The 2-byte end is used for both reads and writes, and odd offsets are refused. Draw decode takes the merged hull through the same branch on the new path, and #6679's refusals are unchanged. The new test case doesn't exercise the write side, though: - The split write is the local part's `ds_write_b32 v7` at offset 16, and the hull part never reads offset 16 of a record. It reads its own record at 0 to 15, control point 2's at +8 (the level), and control points 1 and 2 at +0. - The split read at 72/74 reads the level. Levels 1, 0 and 5 have a zero low half, and every control point of a patch carries the same level. - On an RTX 3080 the case still passes 3 of 3 with either of two changes to `rewrite()`: - the read-modify-write reads `address`, which is control point 0's record (the case from my earlier comment); - it merges into `0` instead of `existing`. The variant below splits the x-position write instead. It writes the high half first, so the second write's read-modify-write has to keep it. The x position has non-zero low halves, differs per control point, and is read back through the own-record `ds_read_b128` and the `ds_read2_b32`. It passes 3 of 3 on de9f0f71c and fails 3 of 3 under both changes: ```cpp alignas(256) constexpr auto MergedHullHalfRecord = [] { std::array<std::uint32_t, MergedHullCode.size() + 6u> code{}; std::size_t at = 0; for (std::size_t index = 0; index < MergedHullCode.size(); ++index) { const auto word = MergedHullCode[index]; if (word == 0xbf88001cu) { code[at++] = 0xbf880020u; } else if (word == 0xd9340000u) { ++index; for (const auto value : {0xda840002u, 0x0000080au, 0xd87c0000u, 0x0000080au, 0xd8340004u, 0x0000090au}) code[at++] = value; } else if (word == 0xd8d80048u) { const auto operands = MergedHullCode[++index]; for (const auto value : {0xd8f00048u, operands, 0xda9c004au, operands}) code[at++] = value; } else { code[at++] = word; } } return code; }(); ``` That turns `ds_write_b64 v10, v[8:9]` into `ds_write_b16_d16_hi v10, v8 offset:2`, `ds_write_b16 v10, v8` and `ds_write_b32 v10, v9 offset:4`, and moves `s_cbranch_execz` from 28 to 32. Your read split stays. It runs with the same `RequirePatches(..., MergedTriangles, MergedHullHalfRecord)` call as your case, either in place of `MergedHullHalfWords` or next to it. A coverage gap on the lane side: this PR lets the merged hull run with `HS_W32`, which Crimson Desert's `0x60212d` sets, but no test compiles or draws a wave32 merged hull. `Tessellation.cpp` compiles at 64. `TessellationGeometry.cpp` draws wave32 only with the separate local/hull pair and registers its merged hull with `0x212d` (wave64). Registering one with `HS_W32` there would cover it. `agc_driver_graphics` decodes `0x60212d` without compiling it. Tested on Linux 7.2.10 (CachyOS), RTX 3080, NVIDIA 615.78.08, GCC 16.2.1, Release: - `ctest -R 'tess|hull|prepared_graphics|shader_memory|request'`: 10 of 10 pass, no skips. - `agc_driver_tessellation` and `agc_driver_tessellation_geometry` each pass 3 of 3, and `agc_driver_graphics` passes. - Your new case on 8f93aa0bd, with only the `Tessellation.cpp` change applied, fails 3 of 3 with `only 32-bit LDS reads and writes are supported in tessellation stages at pc 0x84`. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-16 05:30:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T05:30:18Z.


Thanks @SleglJan, you're right on both counts. 2920dce82 adds your MergedHullHalfRecord case next to mine, with you as co-author on that commit. Here it fails under both of your rewrite() changes, own-record read replaced by address and merge into 0, each with the level-1 patch was not drawn as one flat triangle. Restored, it passes 3 of 3.

For the lane side, TessellationGeometry.cpp now resolves the registered merged hull a second time with HS_W32, on both VGT_SHADER_STAGES_EN and the hull's registration. A throwaway check that throws when a merged hull is compiled at wave32 fails with the new registration and doesn't trigger on the previous test, so that path is now compiled. Both tests pass 3 of 3, and I credited your review and your RTX 3080 runs in the description.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208801056 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6208801056). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-16T05:30:18Z. --- Thanks @SleglJan, you're right on both counts. 2920dce82 adds your `MergedHullHalfRecord` case next to mine, with you as co-author on that commit. Here it fails under both of your `rewrite()` changes, own-record read replaced by `address` and merge into 0, each with `the level-1 patch was not drawn as one flat triangle`. Restored, it passes 3 of 3. For the lane side, `TessellationGeometry.cpp` now resolves the registered merged hull a second time with `HS_W32`, on both `VGT_SHADER_STAGES_EN` and the hull's registration. A throwaway check that throws when a merged hull is compiled at wave32 fails with the new registration and doesn't trigger on the previous test, so that path is now compiled. Both tests pass 3 of 3, and I credited your review and your RTX 3080 runs in the description. AI-assisted: yes
milescoviello commented 2026-10-16 16:14:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T16:14:42Z.


Thanks @SleglJan. I restacked this PR onto your 36529f17d (rebased onto main 4524944), so its first commit now reads mergedHull from version 32. The tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3 on the new head 3400c1349, and the area suite matches main.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6219710344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6219710344). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-16T16:14:42Z. --- Thanks @SleglJan. I restacked this PR onto your 36529f17d (rebased onto `main` 4524944), so its first commit now reads `mergedHull` from version 32. The tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3 on the new head 3400c1349, and the area suite matches `main`. AI-assisted: yes
milescoviello commented 2026-10-17 07:36:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T07:36:00Z.


Restacked onto #6679's current head 01947dd9b6, so the first commit here is #6679's as it stands now. My three commits applied without conflicts, and the branch still merges with main 17cfb1f4cb cleanly. On the new head c2464855be: the tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3. The AGC area suite passes 897 of 898. The one failure is agc_driver_store_over_untracked, which also fails under -j6 on this machine without this PR and passes when run alone.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231277578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6231277578). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-17T07:36:00Z. --- Restacked onto #6679's current head 01947dd9b6, so the first commit here is #6679's as it stands now. My three commits applied without conflicts, and the branch still merges with `main` 17cfb1f4cb cleanly. On the new head c2464855be: the tessellation, geometry, merged hull, journal and serializer tests pass 3 of 3. The AGC area suite passes 897 of 898. The one failure is `agc_driver_store_over_untracked`, which also fails under `-j6` on this machine without this PR and passes when run alone. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 00:09:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T00:09:28Z.


Rebased onto main a8581d3331 (head 565ce1a861; #6679's commit is still first, unchanged). The only conflict was in ShaderValidation.cpp with #7308, which routes emulated barycentrics through generated tessellation stages. Both sides keep their checks:

  • The push-constant check allows generated control stages for both rect lists and barycentric patches, plus the geometry stage of a captured tessellation pass.
  • The stage count is 5 for a captured tessellation pass, and 4 for tessellation, rect lists and barycentric patches. The triangle-list requirement of the patches route is kept.

The tests matching tessellation|prepared_graphics|^agc_driver_graphics$|merged_hull|tess pass 3 of 3, and all 685 ^agc_ tests pass (Linux, RTX 4070 Ti, 595.99.02).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243560662 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6243560662). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T00:09:28Z. --- Rebased onto `main` a8581d3331 (head 565ce1a861; #6679's commit is still first, unchanged). The only conflict was in `ShaderValidation.cpp` with #7308, which routes emulated barycentrics through generated tessellation stages. Both sides keep their checks: - The push-constant check allows generated control stages for both rect lists and barycentric patches, plus the geometry stage of a captured tessellation pass. - The stage count is 5 for a captured tessellation pass, and 4 for tessellation, rect lists and barycentric patches. The triangle-list requirement of the patches route is kept. The tests matching `tessellation|prepared_graphics|^agc_driver_graphics$|merged_hull|tess` pass 3 of 3, and all 685 `^agc_` tests pass (Linux, RTX 4070 Ti, 595.99.02). AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 01:02:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T01:02:00Z.


Rebased onto main f663e565fe (head fa48241e96; #6679's commit is still first, unchanged). The only conflict was in docs/dev/debt/shader.md, where main added the guest memory load guards entry on the same line as the merged hull programs entry. Both entries are kept.

After the rebase on Linux/NVIDIA, the tessellation, graphics, journal and shader memory tests pass (14/14), and so do the recompiler, SPIR-V, disk cache, rect-list, barycentric and prepared-pipeline tests (43/43).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6244006040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6244006040). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T01:02:00Z. --- Rebased onto `main` f663e565fe (head fa48241e96; #6679's commit is still first, unchanged). The only conflict was in `docs/dev/debt/shader.md`, where `main` added the guest memory load guards entry on the same line as the merged hull programs entry. Both entries are kept. After the rebase on Linux/NVIDIA, the tessellation, graphics, journal and shader memory tests pass (14/14), and so do the recompiler, SPIR-V, disk cache, rect-list, barycentric and prepared-pipeline tests (43/43). AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 02:24:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T02:24:24Z.


Rebased again onto main b39d90bf14 (head a66f3b6d79; #6679's commit is still first). The only conflict was the same line in docs/dev/debt/shader.md: main reworded the guest memory load guards entry. That entry now has main's text, followed by this PR's merged hull programs entry.

After the rebase on Linux/NVIDIA (RTX 4070 Ti, 595.99.02), the 46 tessellation, graphics, journal, shader memory, SPIR-V, rect-list, barycentric, prepared-pipeline, disk cache and recompiler tests pass.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6244695565 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6244695565). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T02:24:24Z. --- Rebased again onto `main` b39d90bf14 (head a66f3b6d79; #6679's commit is still first). The only conflict was the same line in `docs/dev/debt/shader.md`: `main` reworded the guest memory load guards entry. That entry now has `main`'s text, followed by this PR's merged hull programs entry. After the rebase on Linux/NVIDIA (RTX 4070 Ti, 595.99.02), the 46 tessellation, graphics, journal, shader memory, SPIR-V, rect-list, barycentric, prepared-pipeline, disk cache and recompiler tests pass. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 14:15:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T14:15:36Z.


Rebased onto main a62c724c38 (head 126d3ff17a). The only conflict was in DecodeShaderStages: #6129 changed the triangle/quad domain refusal to print the VGT_TF_PARAM and VGT_LS_HS_CONFIG fields (tessellationMessage), and this PR moves that block into the shared tessellation branch. The moved block now uses #6129's message, and the rest is this PR's code. Built and ran the 7 tests matching tess|hull|^agc_driver_graphics|pipeline_journal|request_serializer, including #6129's new message cases in agc_driver_graphics and this PR's agc_driver_tessellation_geometry: all pass.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6250951923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6250951923). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T14:15:36Z. --- Rebased onto `main` a62c724c38 (head 126d3ff17a). The only conflict was in `DecodeShaderStages`: #6129 changed the triangle/quad domain refusal to print the `VGT_TF_PARAM` and `VGT_LS_HS_CONFIG` fields (`tessellationMessage`), and this PR moves that block into the shared tessellation branch. The moved block now uses #6129's message, and the rest is this PR's code. Built and ran the 7 tests matching `tess|hull|^agc_driver_graphics|pipeline_journal|request_serializer`, including #6129's new message cases in `agc_driver_graphics` and this PR's `agc_driver_tessellation_geometry`: all pass. AI-assisted: yes (Claude Code)
LeandroLP23 commented 2026-10-18 17:10:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T17:10:43Z.


AMD on Windows run, since the description lists Windows and AMD as not checked. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. Build: main 6efb7261b with #7524, #7006, #6612, #6929, #7119, #6896 and #6856 merged together (each merge clean, built once). It conflicted with a larger AGC batch earlier, so it was tested here without those.

agc_driver_tessellation, agc_driver_tessellation_geometry, agc_driver_graphics, agc_driver_prepared_graphics and agc_driver_store_over_untracked pass 3 runs of 3.

AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252729904 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6252729904). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-18T17:10:43Z. --- AMD on Windows run, since the description lists Windows and AMD as not checked. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. Build: `main` `6efb7261b` with #7524, #7006, #6612, #6929, #7119, #6896 and #6856 merged together (each merge clean, built once). It conflicted with a larger AGC batch earlier, so it was tested here without those. `agc_driver_tessellation`, `agc_driver_tessellation_geometry`, `agc_driver_graphics`, `agc_driver_prepared_graphics` and `agc_driver_store_over_untracked` pass 3 runs of 3. AI-assisted
milescoviello commented 2026-10-18 18:04:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:04:16Z.


Rebased onto main 8625038579 (head 8addea1d05). #6150 changed the same lines in ShaderRegistry.cpp: it now defers a vertex program whose s_barrier depends on draw routing. The resolution keeps that, together with this branch's wave size bit for tessellation control (0x00200000). The 11 tests matching ^agc_driver_graphics$|tess|geometry|ngg|hull|prepared_graphics|store_over_untracked pass in 2 runs of 2 (RTX 4070 Ti, 595.99.02, Ubuntu 24.04).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253285393 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6253285393). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T18:04:16Z. --- Rebased onto `main` 8625038579 (head 8addea1d05). #6150 changed the same lines in `ShaderRegistry.cpp`: it now defers a vertex program whose `s_barrier` depends on draw routing. The resolution keeps that, together with this branch's wave size bit for tessellation control (`0x00200000`). The 11 tests matching `^agc_driver_graphics$|tess|geometry|ngg|hull|prepared_graphics|store_over_untracked` pass in 2 runs of 2 (RTX 4070 Ti, 595.99.02, Ubuntu 24.04). AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 18:46:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:46:02Z.


Thanks @LeandroLP23 for the AMD run on Windows. I added it to the description.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6253713556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6253713556). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T18:46:02Z. --- Thanks @LeandroLP23 for the AMD run on Windows. I added it to the description. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-19 06:49:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T06:49:10Z.

Review: DISMISSED


Thanks for the continued restacks. This head can't land as is:

  • It is stacked on #6679 at 4e7fa2be5, and #6679 has moved on (3b69fde44). Please restack onto its current head.
  • Against current main it conflicts in 8 files: Draw/DrawCapture.cpp, Shaders/ShaderRegistry.cpp (also touched by the merged #6150), Graphics/include/State.hpp, PipelineJournal.cpp, ShaderValidation.cpp, tests/ShaderMemory.cpp, RequestSerializer.cpp and RequestSerializerTests.cpp. These are not mechanical, so please resolve them and re-run the tessellation, graphics, journal and serializer tests.

Once #6679 is merged and this is rebased on main, it will be reviewed against the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5567840023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5567840023). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T06:49:10Z. **Review:** DISMISSED --- Thanks for the continued restacks. This head can't land as is: - It is stacked on #6679 at 4e7fa2be5, and #6679 has moved on (3b69fde44). Please restack onto its current head. - Against current `main` it conflicts in 8 files: `Draw/DrawCapture.cpp`, `Shaders/ShaderRegistry.cpp` (also touched by the merged #6150), `Graphics/include/State.hpp`, `PipelineJournal.cpp`, `ShaderValidation.cpp`, `tests/ShaderMemory.cpp`, `RequestSerializer.cpp` and `RequestSerializerTests.cpp`. These are not mechanical, so please resolve them and re-run the tessellation, graphics, journal and serializer tests. Once #6679 is merged and this is rebased on `main`, it will be reviewed against the new head.
milescoviello commented 2026-10-19 06:50:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T06:50:35Z.


@adriadam10 thanks for the review. The restack onto #6679's current head 3b69fde44 is done locally, and its tests are running now. #6679's head alone passes 613 of 614 of the AGC, shader, request, journal and tessellation set; the one failure is agc_driver_bda_device (#7584). The PR's own run, then the tessellation, serializer and journal tests 3 of 3, are next.

The conflicts in the files you listed came from #4650 and #6503, which landed while this sat on the older head:

  • StagePushLimit now takes the depth remap limit, in main's order;
  • the validation conditions keep both the depth-remap push and the tessellation capture terms;
  • the journal guards and format follow main.

I'll push with the results. Once #6679 merges, I'll rebase this onto main.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6261456565 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6261456565). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T06:50:35Z. --- @adriadam10 thanks for the review. The restack onto #6679's current head 3b69fde44 is done locally, and its tests are running now. #6679's head alone passes 613 of 614 of the AGC, shader, request, journal and tessellation set; the one failure is `agc_driver_bda_device` (#7584). The PR's own run, then the tessellation, serializer and journal tests 3 of 3, are next. The conflicts in the files you listed came from #4650 and #6503, which landed while this sat on the older head: - `StagePushLimit` now takes the depth remap limit, in `main`'s order; - the validation conditions keep both the depth-remap push and the tessellation capture terms; - the journal guards and format follow `main`. I'll push with the results. Once #6679 merges, I'll rebase this onto `main`. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-19 06:55:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T06:55:49Z.


@adriadam10 @SleglJan pushed: #6612 is now on #6679's head 3b69fde44 (head 847628a460).

  • The AGC, shader, request, journal and tessellation set passes 614 of 615, against 613 of 614 on 3b69fde44 alone. The one failure on both is agc_driver_bda_device (#7584).
  • The tessellation, serializer and journal tests pass 3 of 3.
  • The resolutions are in the description: StagePushLimit takes the depth remap limit, the validation keeps both push terms, and the journal format becomes 5.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6261530576 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6261530576). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T06:55:49Z. --- @adriadam10 @SleglJan pushed: #6612 is now on #6679's head 3b69fde44 (head 847628a460). - The AGC, shader, request, journal and tessellation set passes 614 of 615, against 613 of 614 on 3b69fde44 alone. The one failure on both is `agc_driver_bda_device` (#7584). - The tessellation, serializer and journal tests pass 3 of 3. - The resolutions are in the description: `StagePushLimit` takes the depth remap limit, the validation keeps both push terms, and the journal format becomes 5. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-19 07:27:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T07:27:35Z.

Review: DISMISSED


Thanks for restacking onto #6679's current head; the earlier eight conflicts are resolved. One conflict with main remains:

  • Graphics/include/State.hpp: main added bool quadList right after rectList (support quad-list primitive type), where this PR adds rasterizerDiscard and tessellationCapture. Please resolve it and re-check the State size guards in PipelineJournal.cpp (the new member changes the layout) and that the journal codec/canonical state treat quadList consistently with the new fields. Then re-run the graphics, journal and tessellation tests.

This is also still stacked on #6679, which is open; it will be reviewed against the new head once #6679 has merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5568223883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5568223883). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T07:27:35Z. **Review:** DISMISSED --- Thanks for restacking onto #6679's current head; the earlier eight conflicts are resolved. One conflict with `main` remains: - `Graphics/include/State.hpp`: `main` added `bool quadList` right after `rectList` (support quad-list primitive type), where this PR adds `rasterizerDiscard` and `tessellationCapture`. Please resolve it and re-check the `State` size guards in `PipelineJournal.cpp` (the new member changes the layout) and that the journal codec/canonical state treat `quadList` consistently with the new fields. Then re-run the graphics, journal and tessellation tests. This is also still stacked on #6679, which is open; it will be reviewed against the new head once #6679 has merged.
milescoviello commented 2026-10-19 11:29:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T11:29:46Z.


@adriadam10 thanks, resolved and pushed: 235f5130c0, rebased onto main f72c7aacfa with #6679's commit still first.

  • State.hpp: the conflict was main's bool quadList after rectList, next to this PR's rasterizerDiscard and tessellationCapture. Both are kept.
  • Size guards: sizeof(State) is still 856 with quadList, because the bool fits in existing padding. The guards in PipelineJournal.cpp (State 856, ShaderStages 160, journal format 5) compile unchanged.
  • Codec and canonical state: quad-list draws never produce a recipe. Draw.cpp clears recipeOut when state.quadList is set, and the recorder returns DrawRecipeMiss::NotRecordable for them. So neither the recipe codec nor CanonicalPipelineState carries quadList, the same as on main. A decoded state's default false is what every journaled draw was recorded with. The new tessellation fields are encoded and compared as before.
  • Tests (RTX 4070 Ti, Linux, Release): the 630 tests in the broad driver/recompiler/journal/tessellation set pass on f72c7aacfa, and 631 of 631 with this PR. The tessellation, journal and request serializer tests pass 3 of 3.

The Khronos validation comparison CONTRIBUTING.md now asks for (main vs this PR, tess|journal tests) is queued. I'll add it to the description when it finishes.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266163594 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6266163594). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T11:29:46Z. --- @adriadam10 thanks, resolved and pushed: 235f5130c0, rebased onto `main` f72c7aacfa with #6679's commit still first. - **`State.hpp`**: the conflict was `main`'s `bool quadList` after `rectList`, next to this PR's `rasterizerDiscard` and `tessellationCapture`. Both are kept. - **Size guards**: `sizeof(State)` is still 856 with `quadList`, because the bool fits in existing padding. The guards in `PipelineJournal.cpp` (`State` 856, `ShaderStages` 160, journal format 5) compile unchanged. - **Codec and canonical state**: quad-list draws never produce a recipe. `Draw.cpp` clears `recipeOut` when `state.quadList` is set, and the recorder returns `DrawRecipeMiss::NotRecordable` for them. So neither the recipe codec nor `CanonicalPipelineState` carries `quadList`, the same as on `main`. A decoded state's default `false` is what every journaled draw was recorded with. The new tessellation fields are encoded and compared as before. - **Tests** (RTX 4070 Ti, Linux, Release): the 630 tests in the broad driver/recompiler/journal/tessellation set pass on f72c7aacfa, and 631 of 631 with this PR. The tessellation, journal and request serializer tests pass 3 of 3. The Khronos validation comparison CONTRIBUTING.md now asks for (`main` vs this PR, `tess|journal` tests) is queued. I'll add it to the description when it finishes. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-19 11:39:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T11:39:47Z.


@adriadam10 one more push, from the validation comparison mentioned above: 7570d583d6.

Under the Khronos layer, 235f5130c0 added two errors in agc_driver_tessellation_geometry, 9 each: VUID-VkGraphicsPipelineCreateInfo-pStages-06894 and VUID-RuntimeSpirv-OpEntryPoint-08743. The first pass of tessellation followed by a geometry stage captures the tessellated triangles with rasterizer discard. It still carried the pixel program, which Vulkan doesn't allow without fragment shader state, and that program reads a location the capture geometry stage doesn't write.

The capture pass now has the four pre-rasterization stages only. ValidateShaders expects four stages for it and checks no color exports there, and the pixel program runs only in the mesh pass that draws the captured triangles. The fix is folded into "draw tessellation followed by an NGG geometry stage".

  • Layer, tess|journal: main f72c7aacfa and this head now report only VkDeviceCreateInfo-pNext-pNext and VkGraphicsPipelineCreateInfo-pLibraries-06681, which this older layer (1.3.275) gives for every device-creating test. Nothing is new, and neither log reports the layer missing.
  • The 631 broad-set tests pass. The tessellation, journal and request serializer tests pass 3 of 3.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266341133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6266341133). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T11:39:47Z. --- @adriadam10 one more push, from the validation comparison mentioned above: 7570d583d6. Under the Khronos layer, 235f5130c0 added two errors in `agc_driver_tessellation_geometry`, 9 each: `VUID-VkGraphicsPipelineCreateInfo-pStages-06894` and `VUID-RuntimeSpirv-OpEntryPoint-08743`. The first pass of tessellation followed by a geometry stage captures the tessellated triangles with rasterizer discard. It still carried the pixel program, which Vulkan doesn't allow without fragment shader state, and that program reads a location the capture geometry stage doesn't write. The capture pass now has the four pre-rasterization stages only. `ValidateShaders` expects four stages for it and checks no color exports there, and the pixel program runs only in the mesh pass that draws the captured triangles. The fix is folded into "draw tessellation followed by an NGG geometry stage". - Layer, `tess|journal`: `main` f72c7aacfa and this head now report only `VkDeviceCreateInfo-pNext-pNext` and `VkGraphicsPipelineCreateInfo-pLibraries-06681`, which this older layer (1.3.275) gives for every device-creating test. Nothing is new, and neither log reports the layer missing. - The 631 broad-set tests pass. The tessellation, journal and request serializer tests pass 3 of 3. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-19 16:09:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T16:09:38Z.

Review: DISMISSED


Thanks for resolving the State.hpp conflict; the quadList handling and the new capture pass without a pixel program look consistent. main has moved again and the branch conflicts in two files:

  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp: #6931 (pipelined indirect draws) now locates baseVertexLocation/startInstanceLocation/drawIndexLocation as single words and computes lastDrawable, where this branch reads them through UserDataWords(programs, roles, ...). Please merge the two so the merged-hull/tessellation roles are still covered by the new queued path.
  • core/shader/recompiler/tests/RequestSerializerTests.cpp: main already upgrades the fixture to request version 37 (upgraded[4] = 37u), while this branch builds main36 and then upgrades to 37 itself. Please re-check which version this stack should write and adjust the fixtures to match.

Also, #6679, which this PR is stacked on, is still open and itself conflicts with main. This one can only land after #6679 does, so please restack onto its resolved head, then re-run the graphics, journal, serializer and tessellation tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5574383404 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#pullrequestreview-5574383404). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T16:09:38Z. **Review:** DISMISSED --- Thanks for resolving the `State.hpp` conflict; the `quadList` handling and the new capture pass without a pixel program look consistent. `main` has moved again and the branch conflicts in two files: - `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`: #6931 (pipelined indirect draws) now locates `baseVertexLocation`/`startInstanceLocation`/`drawIndexLocation` as single words and computes `lastDrawable`, where this branch reads them through `UserDataWords(programs, roles, ...)`. Please merge the two so the merged-hull/tessellation roles are still covered by the new queued path. - `core/shader/recompiler/tests/RequestSerializerTests.cpp`: `main` already upgrades the fixture to request version 37 (`upgraded[4] = 37u`), while this branch builds `main36` and then upgrades to 37 itself. Please re-check which version this stack should write and adjust the fixtures to match. Also, #6679, which this PR is stacked on, is still open and itself conflicts with `main`. This one can only land after #6679 does, so please restack onto its resolved head, then re-run the graphics, journal, serializer and tessellation tests.
milescoviello commented 2026-10-19 16:10:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T16:10:03Z.


@adriadam10 two updates on #6612:

  • Pushed 22587edfa0. The LunarG SDK's 1.4.363 layer, which is newer than the 1.3.275 one I used before, found one more error the capture pass added: VUID-vkCmdDrawIndexed-colorAttachmentCount-06179 ×12. A pipeline that discards its primitives has no fragment output state, so it counts as having no color attachments, while the pass still began rendering with the draw's targets. Pipeline::Begin now begins a discarding pass with no attachments. Under 1.4.363, tess|journal on main f72c7aacfa and on this head now report nothing. The 631 broad-set tests pass, and the tessellation, journal and serializer tests pass 3 of 3.
  • main moved again. 7563b4a480 (stencil operation value export) took request version 37, which #6679's merged hull flag also uses, so the stack conflicts with main in #6679's commit. I've told SleglJan on #6679 that the next free version is 38, and I'll restack #6612 on #6679's rebased head and push it with the tests then.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271673337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6271673337). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T16:10:03Z. --- @adriadam10 two updates on #6612: - **Pushed 22587edfa0.** The LunarG SDK's 1.4.363 layer, which is newer than the 1.3.275 one I used before, found one more error the capture pass added: `VUID-vkCmdDrawIndexed-colorAttachmentCount-06179` ×12. A pipeline that discards its primitives has no fragment output state, so it counts as having no color attachments, while the pass still began rendering with the draw's targets. `Pipeline::Begin` now begins a discarding pass with no attachments. Under 1.4.363, `tess|journal` on `main` f72c7aacfa and on this head now report nothing. The 631 broad-set tests pass, and the tessellation, journal and serializer tests pass 3 of 3. - **`main` moved again.** 7563b4a480 (stencil operation value export) took request version 37, which #6679's merged hull flag also uses, so the stack conflicts with `main` in #6679's commit. I've told SleglJan on #6679 that the next free version is 38, and I'll restack #6612 on #6679's rebased head and push it with the tests then. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-19 16:55:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T16:55:36Z.


@adriadam10 restacked as you asked: 77d218a50a is this PR's three commits on SleglJan's rebased #6679 head 83a04aba09 (main 0fbfd91e5e). They apply without a conflict.

  • Draw.cpp: #6679's head keeps the three record lookups as UserDataWords(programs, roles, ...) and runs #6931's lastDrawable scan after them. So every program that holds the register gets the word, both stages of a merged hull included, and the queued last drawable record carries them.
  • Request version: main took 37 for the stencil operation value export, so #6679 now writes 38 and reads mergedHull only from 38. Its replay test replays main's version 37 format. This PR adds no version of its own.
  • Tests (RTX 4070 Ti, Linux, Release): the 635 broad-set tests pass on main, and 636 of 636 with this PR. The graphics, journal, request serializer and tessellation tests pass 3 of 3. Under the LunarG SDK's 1.4.363 layer, tess|journal reports nothing on main or on this head.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272540686 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6272540686). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T16:55:36Z. --- @adriadam10 restacked as you asked: 77d218a50a is this PR's three commits on SleglJan's rebased #6679 head 83a04aba09 (`main` 0fbfd91e5e). They apply without a conflict. - **`Draw.cpp`**: #6679's head keeps the three record lookups as `UserDataWords(programs, roles, ...)` and runs #6931's `lastDrawable` scan after them. So every program that holds the register gets the word, both stages of a merged hull included, and the queued last drawable record carries them. - **Request version**: `main` took 37 for the stencil operation value export, so #6679 now writes 38 and reads `mergedHull` only from 38. Its replay test replays `main`'s version 37 format. This PR adds no version of its own. - **Tests** (RTX 4070 Ti, Linux, Release): the 635 broad-set tests pass on `main`, and 636 of 636 with this PR. The graphics, journal, request serializer and tessellation tests pass 3 of 3. Under the LunarG SDK's 1.4.363 layer, `tess|journal` reports nothing on `main` or on this head. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-20 03:33:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T03:33:04Z.


Restacked on #6679's current head 0307183985 (SleglJan's rebased single commit), so it's now at 6f8d397618. My three commits applied without conflicts, and the branch merges cleanly with main 525e299fc0. agc_driver_tessellation, agc_driver_tessellation_geometry, agc_driver_graphics, agc_driver_store_over_untracked, agc_driver_prepared_graphics and agc_driver_bda_device pass, 6 of 6.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6282700422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6282700422). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T03:33:04Z. --- Restacked on #6679's current head 0307183985 (SleglJan's rebased single commit), so it's now at 6f8d397618. My three commits applied without conflicts, and the branch merges cleanly with `main` 525e299fc0. `agc_driver_tessellation`, `agc_driver_tessellation_geometry`, `agc_driver_graphics`, `agc_driver_store_over_untracked`, `agc_driver_prepared_graphics` and `agc_driver_bda_device` pass, 6 of 6. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-20 15:22:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T15:22:34Z.


#6679 is merged, so this is now rebased onto main 5ccf1824df without it (c068cc8fe6). It is the same three commits, and they applied without a conflict. The conflict GitHub showed came from the older copy of #6679's commit that this branch carried. ctest -R '^(agc_|shader_|request_)' passes 835 of 835, and the tessellation, graphics, journal, serializer, mesh and geometry tests pass 3 of 3. Depends on is now none.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294405044 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6294405044). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T15:22:34Z. --- #6679 is merged, so this is now rebased onto `main` 5ccf1824df without it (c068cc8fe6). It is the same three commits, and they applied without a conflict. The conflict GitHub showed came from the older copy of #6679's commit that this branch carried. `ctest -R '^(agc_|shader_|request_)'` passes 835 of 835, and the tessellation, graphics, journal, serializer, mesh and geometry tests pass 3 of 3. **Depends on** is now none. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-20 16:14:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T16:14:47Z.


Thanks for the restack. One correctness problem in the capture sizing, plus a question.

Triangle-domain capture capacity is below the tessellator's output. drawTessellationGeometry sizes the capture as level = ceil(clamp(VGT_HOS_MAX_TESS_LEVEL)) + 1 and perPatch = domain == 2 ? 2 * level * level : level * level, so a triangle patch gets (n + 1)² slots. A triangle domain with uniform level n tessellates into 3n²/2 triangles (n even) or (3n² − 1)/2 (n odd): 1, 6, 13, 24, 37 for n = 1…5. That's more than (n + 1)² from n = 5 on (37 > 36), and 6144 vs 4225 at n = 64 (+45%). The capture shader then drops every triangle past capacity (index < capacity, TessellationCaptureShader.cpp:57), with no error. So a draw whose patches are tessellated near the maximum loses geometry silently, well under the documented 2^20 cap. The debt entry says the capacity is "no more than its patches allow at VGT_HOS_MAX_TESS_LEVEL", which this bound doesn't satisfy for triangles. Quads are fine (2n² ≤ 2(n + 1)²).

Could you size triangle patches at least ceil(3 · level² / 2) (or use 2 · level² for both domains), and add a case to agc_driver_tessellation_geometry that tessellates a triangle patch at a level ≥ 5 with every factor at the maximum, checking the captured count equals the tessellator's? The current PatchLevels {1, 0, 5} stays under capacity because the other patches leave room.

Question: a 16-bit LDS write in a merged hull (ControlShared) becomes a read-modify-write of the containing 32-bit attribute word (GetTessellationAttribute → BitFieldInsert → SetTessellationAttribute). If two lanes write the two halves of the same dword, can one update be lost? If the hull program only ever writes the halves from one lane, a line in the debt entry saying so would settle it.

Minor, no change needed for merge: the capture buffers are allocated per draw at the worst case (e.g. 2^20 × 3 × 32 dwords × 4 B ≈ 384 MB device-local for a 32-dword ESGS item), and Draw.cpp's static capture-shader map is keyed only by (esgsItemSize, primitivesPerGroup), not by device or target.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6295530756 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6295530756). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T16:14:47Z. --- Thanks for the restack. One correctness problem in the capture sizing, plus a question. **Triangle-domain capture capacity is below the tessellator's output.** `drawTessellationGeometry` sizes the capture as `level = ceil(clamp(VGT_HOS_MAX_TESS_LEVEL)) + 1` and `perPatch = domain == 2 ? 2 * level * level : level * level`, so a triangle patch gets `(n + 1)²` slots. A triangle domain with uniform level n tessellates into `3n²/2` triangles (n even) or `(3n² − 1)/2` (n odd): 1, 6, 13, 24, 37 for n = 1…5. That's more than `(n + 1)²` from n = 5 on (37 > 36), and 6144 vs 4225 at n = 64 (+45%). The capture shader then drops every triangle past `capacity` (`index < capacity`, TessellationCaptureShader.cpp:57), with no error. So a draw whose patches are tessellated near the maximum loses geometry silently, well under the documented 2^20 cap. The debt entry says the capacity is "no more than its patches allow at `VGT_HOS_MAX_TESS_LEVEL`", which this bound doesn't satisfy for triangles. Quads are fine (2n² ≤ 2(n + 1)²). Could you size triangle patches at least `ceil(3 · level² / 2)` (or use `2 · level²` for both domains), and add a case to `agc_driver_tessellation_geometry` that tessellates a triangle patch at a level ≥ 5 with every factor at the maximum, checking the captured count equals the tessellator's? The current PatchLevels {1, 0, 5} stays under capacity because the other patches leave room. **Question:** a 16-bit LDS write in a merged hull (`ControlShared`) becomes a read-modify-write of the containing 32-bit attribute word (`GetTessellationAttribute` → `BitFieldInsert` → `SetTessellationAttribute`). If two lanes write the two halves of the same dword, can one update be lost? If the hull program only ever writes the halves from one lane, a line in the debt entry saying so would settle it. Minor, no change needed for merge: the capture buffers are allocated per draw at the worst case (e.g. 2^20 × 3 × 32 dwords × 4 B ≈ 384 MB device-local for a 32-dword ESGS item), and `Draw.cpp`'s static capture-shader map is keyed only by `(esgsItemSize, primitivesPerGroup)`, not by device or target.
milescoviello commented 2026-10-20 16:24:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T16:24:05Z.


Thanks @oneandonlydean, you're right on both counts, and the capacity one was a real bug.

Capacity. Fixed in b478c407a7. Every domain now gets 2 · level² slots per patch, with level = ceil(clamp(VGT_HOS_MAX_TESS_LEVEL)) + 1, as you suggested. That covers a triangle's 3n²/2 and a quad's 2n².

agc_driver_tessellation_geometry gains the case you described: the level-5 triangle patch drawn alone, with VGT_HOS_MAX_TESS_LEVEL at 5, so that patch alone has to fit its capacity. That's 37 triangles, against 36 slots before the fix. The geometry path's image must match the tessellation path's.

  • With the old sizing, it fails 3 of 3: the element at byte 22292 is (16, 24, 40, 255), the tessellation path drew (255, 102, 0, 255), a dropped triangle.
  • With the fix, agc_driver_tessellation and agc_driver_tessellation_geometry pass 3 of 3.

The debt entry's "no more than its patches allow at VGT_HOS_MAX_TESS_LEVEL" now holds.

16-bit halves. No update can be lost. TessellationLowering refuses a merged-hull LDS write unless it lands in the writing control point's own record: the merged hull program writes LDS outside its own control point's record, in the ControlShared write check. The emitter indexes that record by the invocation. So the two halves of a dword are always written by the same invocation, in program order. The read-modify-write reads that invocation's own record, and no other lane writes it. That's enforced rather than assumed, so I've left the debt entry as it is.

Minor points. Noted. Both the worst-case per-draw capture buffers and the capture-shader map keyed only by item size and group size would be follow-ups if a title shows them mattering.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6295721218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6295721218). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T16:24:05Z. --- Thanks @oneandonlydean, you're right on both counts, and the capacity one was a real bug. **Capacity.** Fixed in b478c407a7. Every domain now gets `2 · level²` slots per patch, with `level = ceil(clamp(VGT_HOS_MAX_TESS_LEVEL)) + 1`, as you suggested. That covers a triangle's `3n²/2` and a quad's `2n²`. `agc_driver_tessellation_geometry` gains the case you described: the level-5 triangle patch drawn alone, with `VGT_HOS_MAX_TESS_LEVEL` at 5, so that patch alone has to fit its capacity. That's 37 triangles, against 36 slots before the fix. The geometry path's image must match the tessellation path's. - With the old sizing, it fails 3 of 3: `the element at byte 22292 is (16, 24, 40, 255), the tessellation path drew (255, 102, 0, 255)`, a dropped triangle. - With the fix, `agc_driver_tessellation` and `agc_driver_tessellation_geometry` pass 3 of 3. The debt entry's "no more than its patches allow at `VGT_HOS_MAX_TESS_LEVEL`" now holds. **16-bit halves.** No update can be lost. `TessellationLowering` refuses a merged-hull LDS write unless it lands in the writing control point's own record: `the merged hull program writes LDS outside its own control point's record`, in the `ControlShared` write check. The emitter indexes that record by the invocation. So the two halves of a dword are always written by the same invocation, in program order. The read-modify-write reads that invocation's own record, and no other lane writes it. That's enforced rather than assumed, so I've left the debt entry as it is. **Minor points.** Noted. Both the worst-case per-draw capture buffers and the capture-shader map keyed only by item size and group size would be follow-ups if a title shows them mattering. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-20 20:43:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T20:43:00Z.


Rebased onto main 26740077bd, now e7b06892d3, with the same five commits. The one conflict was in ShaderInputInfoBuilder.cpp with #6611, which moved the mesh checks into _validateMesh and added a validate-only path. This PR's mesh-stage line (capturedInput) stays where it was. Its copy of the old inline check is gone, since main now makes that check in _validateMesh for both paths. This PR changes no validation, so the new ValidateVertexStageInputs needs nothing.

On the rebased head, ctest -R '^(agc_|shader_|request_)' passes 841 of 842. The usual three skip themselves. The one failure is agc_driver_lookup_log_fits_build, the load-sensitive test that #8601 fixes, and this PR doesn't touch it. The tessellation, journal, serializer and graphics tests (10) pass 3 of 3.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6301045484 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6301045484). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T20:43:00Z. --- Rebased onto `main` 26740077bd, now e7b06892d3, with the same five commits. The one conflict was in `ShaderInputInfoBuilder.cpp` with #6611, which moved the mesh checks into `_validateMesh` and added a validate-only path. This PR's mesh-stage line (`capturedInput`) stays where it was. Its copy of the old inline check is gone, since main now makes that check in `_validateMesh` for both paths. This PR changes no validation, so the new `ValidateVertexStageInputs` needs nothing. On the rebased head, `ctest -R '^(agc_|shader_|request_)'` passes 841 of 842. The usual three skip themselves. The one failure is `agc_driver_lookup_log_fits_build`, the load-sensitive test that #8601 fixes, and this PR doesn't touch it. The tessellation, journal, serializer and graphics tests (10) pass 3 of 3. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-20 21:44:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T21:44:18Z.


A follow-up to my rebase: this PR had the same silent collision oneandonlydean found on #6639. Its journal commit bumps FileFormat from 4 to 5 while it changes the record layout, and #5656 had already set main to 5. So the rebase merged cleanly, but the branch no longer changed the format.

In 9ffafc3946, fix(agc): journal the tessellation geometry state (now 6d2efc22d7) sets the format to 6 and its message says so. The two commits after it are unchanged, and the only change from e7b06892d3 is that line. The journal, tessellation and graphics tests (9) pass 3 of 3 on rebuilt binaries.

#6639 and #8365 also take 6. Whichever of the three merges after the first will take the next number when I rebase it.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302258629 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6302258629). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T21:44:18Z. --- A follow-up to my rebase: this PR had the same silent collision oneandonlydean found on #6639. Its journal commit bumps `FileFormat` from 4 to 5 while it changes the record layout, and #5656 had already set main to 5. So the rebase merged cleanly, but the branch no longer changed the format. In 9ffafc3946, `fix(agc): journal the tessellation geometry state` (now 6d2efc22d7) sets the format to 6 and its message says so. The two commits after it are unchanged, and the only change from e7b06892d3 is that line. The journal, tessellation and graphics tests (9) pass 3 of 3 on rebuilt binaries. #6639 and #8365 also take 6. Whichever of the three merges after the first will take the next number when I rebase it. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-21 11:06:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:06:01Z.


Rebased onto main 275e896797. The new head is dfc290f4ae, five commits.

  • #7869 (polygon modes) merged and took journal format 6, so this PR's journal commit now takes 7. Its message names both earlier bumps.
  • Pipeline.cpp kept main's new polygonMode lines, with this PR's rasterizerDiscardEnable after them.
  • sizeof(State) stays 856 with #7869's field.

The 8 tests matching tess|Tess|hull|Hull|pipeline_journal|^agc_driver_graphics$ pass 2 of 2.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314403967 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6314403967). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T11:06:01Z. --- Rebased onto `main` 275e896797. The new head is `dfc290f4ae`, five commits. - #7869 (polygon modes) merged and took journal format 6, so this PR's journal commit now takes 7. Its message names both earlier bumps. - `Pipeline.cpp` kept `main`'s new `polygonMode` lines, with this PR's `rasterizerDiscardEnable` after them. - `sizeof(State)` stays 856 with #7869's field. The 8 tests matching `tess|Tess|hull|Hull|pipeline_journal|^agc_driver_graphics$` pass 2 of 2. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-21 12:59:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T12:59:03Z.


Rebased again, onto main ce7d547175, after #8856 (point-list output of NGG geometry programs). The new head is a4d995c4af. The one conflict was in DecodeShaderStages: this PR renames primitive to inputPrimitive, and #8856 added point-list output there. The resolution is #8856's lines with the new name. The journal format stays 7 and sizeof(State) 856. The 8 tests matching tess|Tess|hull|Hull|pipeline_journal|^agc_driver_graphics$|geometry|Geometry pass 2 of 2.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6316645039 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6316645039). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-21T12:59:03Z. --- Rebased again, onto `main` ce7d547175, after #8856 (point-list output of NGG geometry programs). The new head is `a4d995c4af`. The one conflict was in `DecodeShaderStages`: this PR renames `primitive` to `inputPrimitive`, and #8856 added point-list output there. The resolution is #8856's lines with the new name. The journal format stays 7 and `sizeof(State)` 856. The 8 tests matching `tess|Tess|hull|Hull|pipeline_journal|^agc_driver_graphics$|geometry|Geometry` pass 2 of 2. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-22 10:31:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T10:31:27Z.


Rebased onto main cc0078595d as 6aa4f7cc7f. The conflict was #8992's split of Graphics::Draw into a prepare and a record step. drawTessellationGeometry and its hand-off now sit around the new Draw, and the change is otherwise line for line the same. The 17 focused tests pass 3 of 3. Details in Tested.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6338601495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6612#issuecomment-6338601495). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-22T10:31:27Z. --- Rebased onto `main` cc0078595d as `6aa4f7cc7f`. The conflict was #8992's split of `Graphics::Draw` into a prepare and a record step. `drawTessellationGeometry` and its hand-off now sit around the new `Draw`, and the change is otherwise line for line the same. The 17 focused tests pass 3 of 3. Details in Tested. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6612
No description provided.