feat(agc): implement overestimating conservative rasterization #1112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1112"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T12:54:28Z.
What
A draw whose PA_SC_CONSERVATIVE_RASTERIZATION_CNTL (context 0x313) isn't the default 0x6000 is skipped (
conservative rasterization is unsupported).OVER_RAST_ENABLE(bit 0 in amdgpu's gc_10_3_0_sh_mask.h). It becomesVK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXTin the pipeline's rasterization state and key.VK_EXT_conservative_rasterizationis enabled only ifprimitiveOverestimationSizeis at most 1/256 pixel (the vertex grid of PA_SU_VTX_CNTL 0x2d) anddegenerateTrianglesRasterizedis set; otherwise the pipeline throws.VGT_GS_OUT_PRIM_TYPE(geometry shader),VGT_TF_PARAM(tessellation) orVGT_PRIMITIVE_TYPE.DRAW_INDEX_INDIRECTtriangle strips with 0x313 = 0x6001 into a seven-target 3840x2160 G-buffer at 0x5050bc0000.DecodeState.Tested
mainc81c2b31: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 430/430 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeagc_driver_conservative_rasterization(GPU): three triangles write just the 6 pixels whose centres they cover, or with overestimation the 13 they touch; lavapipe (no extension) checks the throw and skips.agc_driver_graphics, also with points, lines and triangles out of geometry shaders and tessellation. Both fail or do not build onmain.conservative rasterization is unsupportedskips (a 1,500 s run without it had 1,432, 5-7 per present once the menus open), and no other error skips thoseDRAW_INDEX_INDIRECTdraws.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T12:57:25Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppL163core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL215, L2421, L2465core/libs/prx/libSceAgcDriver/Graphics/include/Context.hppL127Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T10:50:43Z.
Review: CHANGES_REQUESTED
Checked on current
main: build + ctest green (441/441);agc_driver_conservative_rasterizationruns on RADV with the extension (13 touched pixels vs 6 centres) and both new tests fail to build without the change.One thing to fix:
State.cpp:506: the points/lines/rect-list rejection only applies whenresult.stages.path == ShaderPath::Vertex. On the Geometry, Tessellation and TessellationGeometry pathsresult.topologyis the input topology (triangles orPATCH_LIST), but the GS or tessellation stage can emit points or lines, and those would get Vulkan's overestimation, which isn't modelled. Either throw for 0x6001 on non-vertex paths, or derive the rasterized primitive type from the GS output / tessellation mode and throw unless it is triangles. Add a case for it toConservativeRasterizationTests.Everything else looks fine (TechnicalDebt line, key/
sameDecodecoverage, device gate).Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T12:13:50Z.
Thanks for catching that the check only looked at the input topology. It now looks at the primitive that actually reaches the rasterizer, on every path.
With GS_EN set (the Geometry and TessellationGeometry paths) it reads
VGT_GS_OUT_PRIM_TYPEand only accepts a triangle strip with no per-stream types. With only HS_EN set it readsVGT_TF_PARAM: a triangle or quad domain with clockwise or counter-clockwise triangle output passes, while point mode, line output and isolines throw. Otherwise it readsVGT_PRIMITIVE_TYPEas before, so point, line and rect lists throw. Each rejection names the register and its value.One thing I found while writing the tests: on the old head these draws already threw, just not for this reason.
DecodeShaderStagesonly letsVGT_GS_OUT_PRIM_TYPE2 and clockwise triangle tessellation through, so nothing wrong could render with today's routings. That would have changed silently as soon as either one was widened, though. So the conservative decode now runs at the start ofDecodeState, before the stage decode: it holds on its own, and the tests can see it.ConservativeRasterizationTestsnow has GS point, line and per-stream outputs, tessellation point mode, line output and isolines, and a combined tessellation and GS draw that emits lines. All of them must throw with the conservative reason. It also checks that triangle strips out of a GS (fed points, lines or triangles) and clockwise tessellated triangles still get overestimation. All ten rejection cases fail on e86533bb79, where they hit the stage-routing or old vertex-path messages instead, and pass now. The draw key andsameDecodedidn't need changes: the key already hashes 0x29b, 0x2d5 and 0x2db, and the new check only decides between accepting and throwing.The new head is
29c22442dc.Details
VGT_SHADER_STAGES_EN=0x2020: unsupported geometry input or output assembly.VGT_TF_PARAM0x9, 0x29 and 0x28 throwonly triangular, fractional-odd, clockwise tessellation is supported by the reference path. The combined draw throwscombined tessellation and geometry is unsupported. The vertex point list throwspoint-list vertex rendering requires point-size output support.29c22442dceach case throws e.g.conservative rasterization of lines is unsupported (VGT_GS_OUT_PRIM_TYPE=0x1): only triangles are overestimated.b1c5f10d:agc_driver,agc_driver_graphicsandagc_driver_conservative_rasterizationpass on the RTX 3080 Laptop and on lavapipe (Mesa 26.2.4 llvmpipe, where the GPU test checks the throw and skips).29c22442dc: Windows ctest 431/431 on NVIDIA and 430/430 on lavapipe; Linux (WSL Ubuntu 24.04, GCC 13.3, Mesa 25.2.8 llvmpipe, upstream's job config) merged with main1081602d, 454/454.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T12:31:35Z.
Review: APPROVED
Checked the rework on current
main: build + ctest green (451/451).agc_driver_graphicsandagc_driver_conservative_rasterizationpass on RADV with the extension, and both fail to build without the change. The rasterizer-primitive check (VGT_GS_OUT_PRIM_TYPE/VGT_TF_PARAM/VGT_PRIMITIVE_TYPE) covers every path now, register fields match gfx10.3, and the pipeline key andsameDecodeinclude the mode. Merging once the Linux job is green.