feat(agc): draw one-sample color targets beside a multisampled depth target with sample 0's coverage #8115
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8115"
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 milescoviello on 2026-10-19T22:26:58Z.
What
DecodeStaterefuses a draw that writes a one-sample color target beside a multisampled depth target: "a color target's sample count differs from the rasterizer's". The only one-sample color target it accepts under a multisampled rasterizer is merged coverage (overrasterization with no depth target), drawn throughVK_NV_framebuffer_mixed_samples.Ghost of Tsushima (PPSA02225) stops on such a draw. A diagnostic build logged its state: a one-sample
R8G8B8A8_UNORMcolor target (CB_COLOR0_ATTRIB0) and a 2xD32_SFLOAT_S8_UINTdepth/stencil target (DB_Z_INFO.NUM_SAMPLES1), 1920x2160, withPA_SC_AA_CONFIG0x108001 (2 samples),MSAA_ENABLEset andDB_EQAA0. Once that draw passed, a later draw into the same targets addedPS_ITER_SAMPLE(PA_SC_MODE_CNTL_10x6030000) and a sample-interpolated input.AMD's own Vulkan extension for this case,
VK_AMD_mixed_attachment_samples, says "all samples are depth/stencil tested, but only the first color sample count number of samples get a corresponding color output". For one color sample, the pixel's color is written when rasterizer sample 0 is covered and passes the depth and stencil tests. WithPS_ITER_SAMPLEevery sample's invocation runs and is tested, and the color is sample 0's output.VK_NV_coverage_reduction_mode'sTRUNCATEmode gives the same mapping ("raster sample i maps to color sample i"). It is also the rule the existing debt entry for a one-sample target under a multisampled rasterizer already takes from the AMD extension.StategetstruncatedCoverage. It is set for a one-sample color target when the depth target has the rasterizer's sample count (more than 1), the draw isn't overrasterized, and every color target is one-sample. A pixel shader that runs per sample keeps doing so.TRUNCATEcombinations fromvkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNVwith one color sample and depth/stencil samples equal to the rasterizer's, or, without the NV extensions,VK_AMD_mixed_attachment_samplesfor every depth and color sample count.VkAttachmentSampleCountInfoAMD/NVthe depth sample count, and on NVIDIA it addsTRUNCATEcoverage reduction. Without either extension, the draw throws a message naming them.polygonModeonmain,sizeof(State)becomes 792, and the journal'sFileFormatgoes to 7 (main's #5656 took 5 and #7869 took 6).Stacked on #7985, which keeps
VkAttachmentSampleCountInfoNV(with its depth/stencil count) when a pipeline is linked from libraries.Tested
mainf6075c2f4aas4ba0175ba2, after #7948 grewStatefrom 784 to 800 bytes. The one conflict was the size check inPipelineJournal.cpp, now 808:main's 800 plus this PR's 8. The build confirms it. On that head (Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, 615.71.09):^agc_driver_graphics$|pixel_sample|pipeline_journal|pipeline_library|sample_count|mixed|msaa|multisamplepass 3 of 3.mainand on this head.mainreportsVUID-vkCmdDraw-multisampledRenderToSingleSampled-07285twice, both fromagc_driver_multisample_fill_host_only; this head reports none, and nothing new.test/ghost-9742-9717(3ec696f7fe: #9533, #9742 and #9717), release libs, 20 GiB cap. Without this PR, warm and cold runs stop 246 s and 254 s in ona color target's sample count differs from the rasterizer's. With it merged (2620f8d62e), that refusal is gone, and both runs go on to #8121's case (a one-sample color target under a multisampled rasterizer without MSAA_ENABLE ...), 146 s and 267 s in. With #8121 as well, both reach the 600 s limit with no refusal (comment).Ubuntu 24.04, GCC 13.3, Release, NVIDIA RTX 4070 Ti (595.99.02). The driver reports
TRUNCATEandMERGEwith one color sample and depth/stencil samples equal to the rasterizer's for 2 and 4 samples.2620f8d62e, for the llvmpipe CI failure @oneandonlydean found:ExpectTruncatednow skips withtruncated coverage not tested: the device has no two-sample depth targets (framebufferDepthSampleCounts)whenframebufferDepthSampleCountslacks 2, as on lavapipe, wheremain's depth sample count check refused the draw first. Under lavapipe (llvmpipe, LLVM 20.1.2),agc_driver_pixel_sample_coverageprints that line and passes 3 of 3, and the 33 tests pass. On the RTX 4070 Ti the truncated case still runs and passes, and the 33 pass 3 of 3. No CI lane reaches the truncated path: llvmpipe has neither mixed-sample extension and the Windows runner has no GPU. Its evidence is this card (VK_NV_framebuffer_mixed_samples) and @thuanquang's AMD run (VK_AMD_mixed_attachment_samples).main275e896797(7d215928d1), after #5656 and #7869 had each taken a journal format. Thesizeof(State)assert is now 792 andFileFormat7, and the 33 tests matchingpixel_sample_coverage|pipeline_journal|pipeline_library|^agc_driver_graphics$|sample_count|mixed|msaa|multisamplepass 3 of 3.agc_driver_graphics, new cases inmultisampledDepthTests:PS_ITER_SAMPLEand the sample-interpolated input from the second draw runs per sample with sample 0's color. With a 4x color target it is still refused.agc_driver_pixel_sample_coverage, new truncated case. Two half-covering triangles are drawn at 2x beside a 2x depth target, writing theirSAMPLE_COVERAGEmask into a one-sample target. With the standard 2x locations, one triangle's edge pixels cover only sample 0 and the other's only sample 1. The test requires that pixels covering only sample 0 are written and that no pixel covering only sample 1 is.PS_ITER_SAMPLE, writing each invocation's sample index fromANCILLARY. Every written pixel must hold sample 0's 0, and it must write exactly the pixels the first case wrote.agc_driver_graphics.MERGEinstead ofTRUNCATE(7d2c2c867b) fails with "32 pixels that cover only sample 1 were written into the one-sample target".mainf9012eed0against it with 7e5351d57 merged, with the Khronos validation layer.vulkaninfolistsVK_AMD_mixed_attachment_samplesand neither NVIDIA extension, soVulkanDevicetakes the AMD branch.agc_driver_pixel_sample_coverage -Vprints the merged-coverage skip but nottruncated coverage not tested, so the truncated-coverage checks ran through the AMD extension, and they pass 3 of 3.agc_driver_graphicspasses 3 of 3 with and without this PR. Neither side has aVUID-message or reports the layer missing.agc_driver_graphicsandagc_driver_pixel_sample_coveragepass 3 of 3 on an NVIDIA RTX 3080 (617.42) and on an AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002). That run did not use the validation layer or a title.main02fb1ce53(with #8172) with 7e5351d57 merged.agc_driver_graphics,agc_driver_pixel_sample_coverage,agc_driver_msaa_dcc_stateandmsaa_dcc_clear_{2,4,8}pass 3 of 3 on each GPU. On the RTX 5070 Ti both coverage cases ran through the NV extensions, and on the iGPU the truncated case ran throughVK_AMD_mixed_attachment_samples. A related set of 62 tests passes on each GPU.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_driver_graphics$|pixel_sample|multisample|msaa|sample_mask|alpha_to_coverage|depth' -Von #7985's head c46005c996 and on this PR (7e5351d579). 54 of 54 pass on each, neither log reports the layer missing, and neither has aVUID-error.ctest -R '^agc_'(before the per-sample case was added): 802 of 803 pass.agc_driver_storage_read_during_idle_storeis a newer test onmainthat this tree doesn't have; it shows asNot Run.mainwith the PRs it needs to reach these draws (#7726, #7725, #7729, #6300 rebased, #7985 and a local separate-stencil-plane change). Without this PR it stops 62 s in on the first draw above. With the first version of this PR (no per-sample case) it ran to 147 s and stopped on the second draw. With this head it stops 55 s and 70 s in (two runs) at another refusal, a one-sample color target withoutMSAA_ENABLEunderPS_ITER_SAMPLE, which is a separate rule. Those runs ended before the point where the second draw came up, so in the title only the first draw is confirmed past; the per-sample decode and GPU cases above cover the second.tools/check_conventions.py --base upstream/mainpasses. One warning remains: the existing "Single-sample scan into a multisampled depth target" entry is over 1000 characters, and this PR only shortens it.Not tested: RADV, and a title on AMD. The
VK_AMD_mixed_attachment_samplespath has run on AMD's Windows driver (@thuanquang's run above).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T07:39:13Z.
Tested on RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (
1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head7e5351d57:agc_driver_graphicsandagc_driver_pixel_sample_coveragepass 3 of 3 on both GPUs. Not run: the validation layer, and no title.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T07:44:24Z.
@TheSovietWaffle thank you for running these on two vendors. The AMD run is the first one this PR has had: until now the
VK_AMD_mixed_attachment_samplespath had only been compiled. I added your results to the description and credited you. I worded the AMD part carefully, because a pass on AMD's Windows driver doesn't say which path the driver took, and RADV is still untested. If you can rerunagc_driver_pixel_sample_coveragewith-V, its output would show whether the extension was used.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T08:54:46Z.
@milescoviello the
-Vrun you asked for, on a discrete RDNA 2 card: RX 6700 XT (gfx1031), AMD's Windows driver 32.0.21045.5002, Windows 11 26200, Release.mainf9012eed0againstmainf9012eed0with this head (7e5351d57, clean merge),ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer on.vulkaninfolistsVK_AMD_mixed_attachment_sampleson this device and neitherVK_NV_framebuffer_mixed_samplesnorVK_NV_coverage_reduction_mode, soVulkanDevicetakes the AMD branch.agc_driver_pixel_sample_coverage -Vwith this PR printsmerged coverage not tested: the device lacks VK_NV_framebuffer_mixed_samples with merged coverage reduction, but nottruncated coverage not tested: .... SoExpectTruncateddrew through the AMD extension and its pixel checks passed. With the truncated-coverage path in place, the test passes 3 of 3.agc_driver_graphicspasses 3 of 3 with and without the PR.VUID-messages on either side and nowas not found but was requestedline. WithVK_LOADER_DEBUG=layerthe same setup logsInsert instance layer "VK_LAYER_KHRONOS_validation".So the
VK_AMD_mixed_attachment_samplespath executes, and gives sample 0's coverage on this driver. RADV is still not checked, and I haven't run a title.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T08:58:03Z.
@thuanquang thank you, this settles the AMD question. The vulkaninfo check plus the missing
truncated coverage not testedline show theVK_AMD_mixed_attachment_samplesbranch ran, rather than just passing. It's in the description now, credited to you, and the "Not tested" line names only RADV and a title on AMD.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T12:19:07Z.
A short addition: results on current
main(02fb1ce53, which includes #8172) with7e5351d57merged (clean), on a Blackwell NVIDIA GPU that hadn't been tested yet.Setup: Windows 11 (26300), WinLibs GCC 15.2.0, Release,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, no validation layer. The GPUs are an RTX 5070 Ti (NVIDIA 617.42) and an AMD Radeon iGPU (AMD proprietary 2.0.353,VK_AMD_mixed_attachment_samples).agc_driver_graphicsandagc_driver_pixel_sample_coveragepass 3 of 3 on each GPU. So doagc_driver_msaa_dcc_stateandmsaa_dcc_clear_2,_4and_8, so the DCC import paths #8172 touched are not affected.agc_driver_pixel_sample_coverage -Vprints neither "not tested" line on the RTX 5070 Ti, so the merged and truncated cases both ran through the NV extensions. On the AMD iGPU it prints onlymerged coverage not tested: ..., so the truncated case ran throughVK_AMD_mixed_attachment_samples, as in @thuanquang's RX 6700 XT run.agc_driver_stencil_ref_exportskips on NVIDIA because the GPU has no stencil export.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T12:20:42Z.
Thanks @wachi35676. That's the first Blackwell run, and it confirms the paths #8172 touched still pass on top of it. I added it to the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T11:01:04Z.
@milescoviello thanks for the rebase.
06f707be1matches the version we checked: the patch is identical in all 12 files and adds no new title references to the docs.Since then #7869 merged at 10:48 UTC and added
polygonModetoState, which breaks this branch on current main in two ways:truncatedCoverage,sizeof(State)is 792, so thestatic_assert(sizeof(State) == 784, ...)inPipelineJournal.cpp:38fails. The text merge is clean, but the build isn't. We checked by compiling the merged file against main: main itself compiles, and planting a wrong size on main fails the same way.FileFormatis already 6, so this branch's 6 no longer marks the older journals. Please use 7 (PipelineJournal.cpp:47).Could you rebase onto current main, set the assert to 792 and
FileFormatto 7? Other open pull requests also changeStateand this value, so whichever lands second will need the next size and format. We'll check both at merge time.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:02:55Z.
@oneandonlydean yes, I hit both a few minutes ago. The branch is rebased onto
main275e896797as7d215928d1, with the assert at 792 andFileFormatat 7 (the earlier 06f707be1a had moved it to 6, which then collided with #7869). It's queued to build and run the 33 tests matchingpixel_sample_coverage|pipeline_journal|pipeline_library|^agc_driver_graphics$|sample_count|mixed|msaa|multisample3 times. I'll push when they pass and fix the description's format line.#6612, #6639, #8365 and #8542 took 6 as well. They're rebased onto the same
mainand now take 7; I'll post each one's results in its own thread.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:09:04Z.
Pushed
7d215928d1: rebased ontomain275e896797, with thesizeof(State)assert at 792 andFileFormatat 7. The 33 tests pass 3 of 3, and the description's format line is updated.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T12:08:49Z.
@milescoviello the full CI run on
7d215928dis green on Windows, but on Linuxagc_driver_pixel_sample_coveragefails after 0.21 s on llvmpipe:The test passes on
main. It's the newExpectTruncatedcase, and the production path is right to refuse here. That case draws with a 2-sampleD32_SFLOATdepth target, and llvmpipe'sframebufferDepthSampleCountsis 1|4, with no 2. Somain's existing check inPipeline.cpp("device does not support depth targets with the draw's sample count", line 331 on this head) throws before your truncated-coverage check at line 339 is reached.ExpectTruncatedcatches only messages containing "truncated coverage reduction", so it rethrows this one and the test exits 1.The fix we'd expect is in the test only. Before drawing,
ExpectTruncatedshould return false (not tested) when the device can't make a 2-sample depth target, i.e.framebufferDepthSampleCountslacksVK_SAMPLE_COUNT_2_BIT, and print a line naming that limit, as it already does for the missing extensions. That's better than widening the catch, which would also hide that refusal on a device that should support it.One more note for the Tested section: llvmpipe has neither
VK_AMD_mixed_attachment_samplesnorVK_NV_framebuffer_mixed_samples, and the Windows runner has no GPU, so no CI lane runs the truncated path even after this fix. The evidence for it is a run on a device with one of those extensions (NVIDIA, or AMD on Windows). If your own GPU run already covers it, please mention it there.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T12:21:29Z.
@oneandonlydean thanks, agreed on all counts.
2620f8d62edoes it in the test only.ExpectTruncatednow returns its reason for not testing, and the first check isframebufferDepthSampleCountswithoutVK_SAMPLE_COUNT_2_BIT, which printstruncated coverage not tested: the device has no two-sample depth targets (framebufferDepthSampleCounts). The extension refusal keeps its own message, and the catch stays as narrow as it was.It's queued to build and run under lavapipe and on the 4070 Ti, after the title run that has the machine now. I'll push when it passes.
On the Tested note: the truncated path does run on this machine. The RTX 4070 Ti has
VK_NV_framebuffer_mixed_sampleswith truncated coverage reduction, and earlier @thuanquang ran theVK_AMD_mixed_attachment_samplesbranch on AMD; both are in the Tested section. I'll add that no CI lane can reach it.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T12:31:31Z.
Pushed
2620f8d62e. Under lavapipe,agc_driver_pixel_sample_coveragenow printstruncated coverage not tested: the device has no two-sample depth targets (framebufferDepthSampleCounts)and passes 3 of 3, and the 33 tests pass. On the RTX 4070 Ti the truncated case still runs and passes, 3 of 3. The Tested section says which devices cover the truncated path, and that no CI lane does.AI-assisted: yes (Claude Code)