Repository navigation
fix(agc): discard primitives when the shader exports no position - #16059
Conversation
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, with
AI-assisted: yes. |
|
Hi @stuart-russell, thanks for the discard decode. We added one small commit on top: the shader validator still required a position output from a vertex shader even when the draw discards, so a vertex shader with no position export would have been rejected before it reached the pipeline. It now skips that check for a discarded draw, with a test that sends a position-less vertex shader through the validator, and a technical debt row for the hardware side. One question: do you have a measurement of what the console does with |
|
Windows run of the current head, with oneandonlydean's validator commit: head
No title was run. AI-assisted: yes. Claude Code ran the builds and tests and drafted this comment; a separate review agent checked it. The numbers are from the runs on this machine. |
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validation IDs already present on main (9 IDs in 588 tests)Skipped (52)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
ahmadmuj
left a comment
There was a problem hiding this comment.
Checked head 2a48866abe711d9020479cd1a96f43b1018c13e7 against main 151a2cb6e274f594a09c8a2ca42f44af2e5c40d8 on lavapipe (Mesa 25.2.8, Ubuntu 24.04), with validation 1.3.275 loaded, shader cache disabled, and APS5_NO_GPL=1.
A temporary PM4 draw fixture passes all five cases on this head: POS0=4, position-less POS0=0, and alternating POS0=0/4 with three cache configurations. Each draw checks vertex writes 0,1,2, guard words, and every color byte. Discard preserves the sentinel; POS0=4 draws red. The alternating runs record 8 lookups and 4-5 hits. On main, the control passes and all four discard cases reject POS0=0.
One validation issue: each discard case adds one VUID-VkGraphicsPipelineCreateInfo-pStages-06894. Pipeline.cpp sets rasterizerDiscardEnable but still supplies both vertex and fragment stages to vkCreateGraphicsPipelines. Vulkan requires the fragment stage to be absent here. Could you omit that stage for a statically discarded pipeline?
The only other VUID is VkDeviceCreateInfo-pNext-pNext: two messages per case on both revisions. No GPU case skips. Output checks pass, but validation does not. This checks the proposed Vulkan path, not console behavior; no title dump is used.
|
No console measurement — the debt row is right, please keep it as written. Our evidence is only the encoding (0 is Thanks for adding the validator commit — that gap was real: with the decode accepting the draw, a position-less vertex shader would still have been refused later, so the two halves belong together. |
SPI_SHADER_POS_FORMAT entry 0 is SPI_SHADER_ZERO: no position reaches the clipper, so the draw rasterizes nothing. The pipeline, draw and journal keys and the vertex-position validation already carry State::rasterizerDiscard, but the decode required a four-component position and never set it. Set it from the register, and mix and compare it in the draw lookup key and sameDecode so a discarded draw does not share a cached decode.
…raw discards The vertex position check in ShaderValidation exempted only evaluation and geometry shaders from a discarded draw, so a vertex shader without a position export was still rejected after SPI_SHADER_POS_FORMAT entry 0 set the discard. Adds a validator test with a position-less vertex shader and a debt row for the unmeasured hardware behaviour.
2a48866 to
695ba80
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
What
SPI_SHADER_POS_FORMAT(0x1c3) entry 0 discards the primitive: the shader exports no position, so nothing is rasterized. Most of the plumbing for that already exists inmain—State::rasterizerDiscard,VkPipelineRasterizationStateCreateInfo::rasterizerDiscardEnable, the pipeline, draw and journal keys, and the vertex-position validation that accepts a discarded draw — but the decode still required a four-component position and threw, so the flag was never set from the register.This adds the missing piece and the parity it needs:
POS0format 0 setsState::rasterizerDiscard; other formats other than 4 still throw with the format in the message, and0x44(POS0 with auxiliary exports) keeps rasterization.sameDecodecompares it, so a discarded and a rasterizing draw do not share a cached decode.Part of the split of #10420; independent of #10779 and #16053.
References
An export-format entry of 0 is
SPI_SHADER_ZERO; applied to POS0 no position reaches the clipper, which is exactly whatrasterizerDiscardEnablemodels.Tested
agc_driver_pm4(18 tests) andagc_driver_graphicspass, andtools/check_conventions.py --base origin/mainpasses, ond23df92b38. New checks: a four-component position does not discard, POS0 format 0 discards and is not rejected, an auxiliary position export does not discard, formats 1 to 3 throw, and the canonical state keeps the flag.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_driver_(pm4|graphics)' -Vpasses with noVUID-lines and without the "was not found but was requested by env var VK_INSTANCE_LAYERS" message. This machine has no Vulkan device, so that run covers the decode path only.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)