fix(agc): copy a linked pipeline's color sample counts only when it has color attachments #7985
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7985"
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-19T16:55:09Z.
What
This PR's first two commits reached
mainthrough #8115 as identical patches:LinkPipelineFromLibrariescopies a linked pipeline's attachment sample counts and chains them to the link's and relink's create info. What is left is the follow-up from @MarcZX10's review:Pipeline.cppgives a depth-only merged-coverage pipeline aVkAttachmentSampleCountInfowithcolorAttachmentCount0 and a nullpColorAttachmentSamples, which Vulkan allows.memmove, which requires non-null pointers even for 0 bytes.attachmentSamplesalready chains a nullpColorAttachmentSamplesfor it.Tested
Current head
5d1e214ce3(the one commit, rebased ontomain52c09d567dwithout conflicts;git range-diffshows it unchanged), Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, NVIDIA 615.71.09:agc_driver_pipeline_journalfails onmaintoo, as described below.main52c09d567dand at this head: 85 of 86 on both, with the same journal failure. Neither log has a missing-layer line, the layer checked 104 devices on each side, and neither has aVUID-message.Previous head
e6d81fbe9b(onmain3a2b919816), same machine:pipeline_library|^agc_driver_prepared|^agc_driver_graphics$|sample_coverage|msaa|multisample|pipeline_cache|journal, 85 pass in each of 3 runs.agc_driver_pipeline_journalfails the same way onmain3a2b919816. On this machine its 11th Vulkan device can't load the NVIDIA driver (libnvidia-tls.so.615.71.09: cannot allocate memory in static TLS block, withVK_LOADER_DEBUG=error) and falls back to llvmpipe. It passes withGLIBC_TUNABLES=glibc.rtld.optional_static_tls=8192, so it isn't this change.VK_LAYER_PATH=<LunarG SDK 1.4.363>/layers VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -Vover the same 86, onmain3a2b919816and on this head.was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-messages on either.Previous head
6346c5f2fe(onmaincf528e78c6): on Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti, 615.71.09, the 71 tests matchingpipeline_library|^agc_driver_prepared|^agc_driver_graphics$|sample_coverage|msaa|multisample|pipeline_cache|journalpass 3 of 3. Khronos validation 1.4.363 over the same 71 (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -V) gives 71 of 71 onmainand on this head. Neither log has a layer-missing line. Both sides report the same pre-existing 14VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605, and nothing is new in the head.Windows, on the current head
e6d81fbe9band onmain3a2b919816: Windows 11 VM, GeForce GT 1030 (NVIDIA R580), WinLibs GCC 15.2, Release,ANYPS5_REQUIRE_VULKAN=1. The 88 tests matching the same regex there pass 3 of 3 on both,agc_driver_pipeline_journalincluded. (On the earlier headff61956e21and its merge baseeb8dcfebaa, the 68 tests the regex selected then passed 3 of 3 on both.)@ycbuzi ran the previous head on AMD (comment):
6346c5f2femerged ontomain1da5d1a757, Windows 11 Home, WinLibs GCC 15.2.0, Release, AMD Radeon RDNA2 iGPU (driver 32.0.21030.2001), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. The same regex selects 72 tests there, and they pass 72 of 72 onmainand 72 of 72 with this PR. The validation layer was not run on that device.Earlier results, on the three-commit heads named in them:
Ubuntu 24.04, GCC 13.3, NVIDIA RTX 4070 Ti (595.99.02).
Khronos validation, as CONTRIBUTING.md asks, with the LunarG SDK's 1.4.363 layer loaded through
VK_LAYER_PATH:VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V -R sample_coverage.main1126abbfacreportsVUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2. With this change it reports nothing, and neither log reports the layer missing. That holds both for 6bf4a39f25, which chained the counts underVkPipelineLibraryCreateInfoKHR(outside its allowedpNextchain, as @ebosido444-ai pointed out), and for c46005c996, which chains them to the create info.With
APS5_NO_GPL=1,mainalready reports nothing, so only the library path was affected.The 58 tests matching
pipeline_library|^agc_driver_prepared|^agc_driver_graphics$|sample_coverage|msaa|multisample|pipeline_cache|journalpass with this change, as onmain.e9c9857eae, after @MarcZX10's review: the color sample counts are copied only when
colorAttachmentCountis non-zero. A depth-only pipeline'sVkAttachmentSampleCountInfoNV(zero colors, and a null array, asPipeline.cppbuilds it) then never readspColorAttachmentSamples. On Ubuntu 26.04.1 (GCC 15.2, NVIDIA 615.71.09), the same 58-test set passes 2 of 2 on this head. Khronos validation 1.4.363 oversample_coverage: the merge base1126abbfacreportsVUID-vkCmdDraw-multisampledRenderToSingleSampled-07285×2. This head reports no VUID, and neither run reports the layer missing.Overlaps (checked 10-28 against the current heads): neither still edits the lines this PR changes.
6275369b6cmerges with this PR without a conflict.3339ddd3afpredates the sample-count copy this guard sits in (7c63ee6970, which reachedmainwith #8115). It doesn't edit these three lines. It conflicts withmainitself inPipelineLibrary.cppand other files, so its rebase meets this code either way.So there's no order to agree, and
Depends onstays none.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 ebosido444-ai on 2026-10-19T22:10:42Z.
VkAttachmentSampleCountInfoNVmay only extendVkGraphicsPipelineCreateInfoandVkCommandBufferInheritanceInfo, so chaining it offVkPipelineLibraryCreateInfoKHR::pNext(both at the link and in the deferred relink) is outside the allowed chain even though the validation layer stayed quiet — layers walk nested pNext chains transitively and do not reject a struct under a parent it is not allowed to extend.Put the counts on the graphics create info instead:
counts.pNext = create.pNext; create.pNext = &counts;(counts first, then the library list where it belongs), in both the link and the relink, and re-run thesample_coveragevalidation command. If 07285 stays gone with the struct on the create info, that is the conformant form of the same fix.The copy-out and the by-value capture that keeps the array alive across the deferred relink are right — only the chain placement needs to move.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T22:15:06Z.
@ebosido444-ai thanks, you're right.
VkAttachmentSampleCountInfoNVextends onlyVkGraphicsPipelineCreateInfoandVkCommandBufferInheritanceInfo, and the layer didn't flag it underVkPipelineLibraryCreateInfoKHR. c46005c996 chains the counts to the create info in both the link and the relink (counts.pNext = create.pNext; create.pNext = &counts), and the library list stays where it was. ReranVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V -R sample_coveragewith the 1.4.363 layer:main1126abbfacstill reports 07285 ×2, and c46005c996 reports nothing, with the layer loaded on both. The description says this now.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:03:41Z.
Review: CHANGES_REQUESTED
Two issues block approval:
Please handle a zero-color-attachment pipeline safely. Vulkan permits dynamic rendering with
colorAttachmentCount == 0; a depth-only pipeline may still carryVkAttachmentSampleCountInfoNV, with no color-sample array. The currentsampleCounts.emplaceevaluatescounts.pColorAttachmentSamples + counts.colorAttachmentCountand constructs a vector from that range. If the valid zero-count pointer is null, this forms a null-pointer range. Guard the copy oncolorAttachmentCount != 0and cover or otherwise verify the zero-color case. The struct is also valid in theVkGraphicsPipelineCreateInfochain: https://docs.vulkan.org/refpages/latest/refpages/source/VkAttachmentSampleCountInfoAMD.htmlPlease coordinate the
Depends onorder with the authors of open #9508 and #5925. The current overlap scan reports direct same-line edits with #9508 inPipelineLibrary.cpp(link creation and the deferred relink capture). Manual comparison also shows #5925 changes the same link-creation setup and relink lambda. #7642's edits in this file are confined to the split-layout handling and appear disjoint. The checklist currently saysDepends on: none; after the authors agree which changes land first, update it to match the integration order. This follows the repository's overlap rule inCONTRIBUTING.md.The current hosted eligibility, conventions, labels, and report checks pass. The focused validation results are author-reported; I did not run a local build or GPU test.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T00:06:01Z.
@Raghav314 @adriadam10, @MarcZX10 pointed out that this PR edits the same lines in
PipelineLibrary.cppas #9508 and #5925: the link-time create info inLinkPipelineFromLibrariesand the deferred relink lambda.git merge-treeconfirms both conflict with this head.This change is small. It finds the
VkAttachmentSampleCountInfoNVin the rendering info's chain, keeps a copy, and chains it in front of the link's and the relink'sVkPipelineLibraryCreateInfoKHR. The relink lambda also captures the copy. So whichever lands second only has to re-add those few lines.I'm happy to go either way:
sampleCounts/attachmentSamplesand thepNextchaining in both places.Is there an order you'd prefer?
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T00:17:57Z.
Thanks @MarcZX10.
Done in e9c9857eae: the color sample array is copied only when
colorAttachmentCount != 0. The struct then carries an empty vector, andattachmentSamplesalready chains a nullpColorAttachmentSamplesfor it. Our only producer,Pipeline.cpp, passes count 0 with a null pointer for a depth-only merged-coverage pipeline, so that's the case this covers. The PR's 58-test set passes 2 of 2 on this head. A validation-layer comparison of thesample_coveragetests is queued, and I'll add it when it's done.I left the scan on the rendering info's chain on purpose. The driver only ever puts the struct there, and these create infos never come from a title.
I've asked @Raghav314 and @adriadam10 about the order above, and the body now lists both overlaps. I'll set Depends on once there's an answer.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T22:24:30Z.
Review: CHANGES_REQUESTED
The zero-color guard addresses the null-range issue, and the current one-commit diff is limited to copying color sample counts only when
colorAttachmentCountis nonzero. The author reports Linux NVIDIA validation tests and Windows AMD focused tests passing against corresponding main baselines; no new validation IDs were introduced. Hosted policy checks pass, while product jobs are skipped. I did not run a local GPU test.The current thread still describes overlap with open #5925 and #9508 in
PipelineLibrary.cpp; the checklist saysDepends on: none, and I found no agreed landing order from their authors. Please confirm whether the exact current heads still overlap this guard. If they do, coordinate which change lands first and record the order in the relevant checklists; if they no longer overlap, update the description/overlap record. I cannot complete approval until the repository's overlap-order rule is resolved.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T00:50:46Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested for current-main rerun
Your exact-head comparisons resolve the earlier overlap question: #9508 merges cleanly, and #5925's changes are separate from this guard. The remaining blocker is that this branch is still based on
cf528e78c6, while currentmainis3a2b91981651569163768854a1fcdc7193b6667b.What I ran
6346c5f2fefef8eed6745f5cf4399d868876d50fand inspected the overlap update.main, and inspected changes toPipelineLibrary.cppsince the branch base.git diff --checkand the current conventions checker against this head.Results
Raw output
merge-tree-exit=0; treee48d0cae9d46132348bbb808db1538f2a48553faRaw status
#9508 merges cleanly; #5925's link-creation/relink changes are separate from the three-line sample-count guard, though #5925 itself needs amainrebase.Raw output
git diff --check upstream/main...refs/review/pr-7985— no output; exit status 0Raw output
All conventions checks passed.Reported result
The PR body reports the focused pipeline/sample-count tests on NVIDIA and AMD with validation on the prior basecf528e78c6; these were not independently rerun here.Raw values
Merge basecf528e78c6c8fd30696ccfca6c097f9828be2cf6; currentmainis 4,703 commits ahead. Currentmainalso changes the optimization key and pipeline flags inPipelineLibrary.cpp.Negative control
The author reports that a depth-only pipeline with a null color-sample pointer previously triggered the invalid range construction, and that the guard fixes it. I did not independently run the depth-only Vulkan case on this head.
Findings
Blocking
CONTRIBUTING.mdrequires keeping the branch up to date withmain. Because currentmainhas since changedPipelineLibrary.cpp, the earlier focused comparison oncf528e78c6does not cover the current integration. Please rebase and rerun the same focused tests on currentmainand the updated PR with the required validation-layer settings.Non-blocking
Sources
6346c5f2fefef8eed6745f5cf4399d868876d50f.main:3a2b91981651569163768854a1fcdc7193b6667b.CONTRIBUTING.mdat currentmain.Not verified
I did not build or run Vulkan tests locally. The focused GPU results and negative control are author-reported on the older base. Hosted policy checks pass; full product and specialized hosted jobs are skipped.
To get this to a good state
Rebase on current
main, run the focused depth-only/pipeline tests on the same GPU onmainand the PR with validation enabled, and report the exact revisions and VUID comparison.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:49:22Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The focused GPU and validation-layer report is detailed, including the same 85/86 result on base and candidate. However, the tested base is
main3a2b919816, while currentmainis52c09d567d2fa453494dd720fcf53a98149468e4; this head is 36 commits behind. The contribution checklist requires the branch to be based on currentmain.What I ran
e6d81fbe9bf70441ed4fc17b5b2c4848c8e9298aagainst currentmain.git merge-tree --write-treeandgit diff --check.Results
mainis not in the branch historygit diff --checkVUID-messages on that old base/head pairPlease refresh onto current
mainand rerun the focused test and validation comparison there. I did not run a local GPU build, so I cannot treat the earlier base/head comparison as current integration evidence.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:38:21Z.
Review: APPROVED
Re-reviewed — approved
I reviewed exact head
5d1e214ce3de525b07e5328cb87993fc91d46439against currentmain2960e9a6e7e1fc99c4ed180c71495b5eb83464c7.What I ran
PipelineLibrary.cpp: it avoids forming a vector range frompColorAttachmentSampleswhencolorAttachmentCountis zero, and retains the existing values when the count is nonzero.git merge-tree --write-tree refs/remotes/upstream/main refs/review/upstream-7985; it returned clean tree8e92f48dd104208d3fc7de172916833f5a6a510b.git diff --check refs/remotes/upstream/main...refs/review/upstream-7985; exit 0, no output.mainhas no later change toPipelineLibrary.cppsince the author's tested base52c09d567d.Results
agc_driver_pipeline_journalfails identically on both due to the NVIDIA static-TLS limitVUID-messagesNegative control
No dedicated control for the zero-color-attachment input is reported. The author-reported base/head run is a regression sweep, not a targeted assertion for that input. I did not run a local control.
Findings
Blocking
None. The guard is limited to the zero-count case and avoids constructing the color-sample range from a null pointer; nonzero counts preserve the previous behavior.
Non-blocking
A focused zero-color-attachment regression would strengthen coverage. The current PR changes only the implementation file, so the exact null-pointer case is not directly asserted by a new test.
Sources
Not verified
I did not independently run the GPU tests, validation layer, or a title. The test results above are author-reported. The unrelated
agc_driver_pipeline_journalenvironment failure remains visible on both baseline and candidate.