Repository navigation
agx: apply kills at the end when a discarding shader uses subgroup ops - #245
Merged
Merged
Conversation
On G13/G14, agx_nir_lower_sample_mask() kills demoted samples where the demote happens. Once no non-helper lane of a quad is left, the kill ends the quad, and its rasterizer helper lanes go with it although they never demoted or terminated. Non-quad subgroup operations that the remaining lanes run afterwards then miss those helpers: a ballot of the lanes that are still running counts fewer lanes than the same ballot taken before the terminate. dEQP-VK.reconvergence.terminate_invocation.bit_count checks exactly this (terminated + alive == all) and failed on every run, in the subgroups whose quads held helper lanes. When a shader discards and also has non-quad subgroup operations, use the deferred lowering instead: demotes accumulate into a kill mask that is applied at the end of the shader, after the last subgroup operation, and no dead-quad kill is inserted before it. Every other shader keeps the immediate kill. The gallium driver uses the same entry point, so GL shaders get the same treatment on every chip that uses it. Assisted-by: LLM Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
Assisted-by: LLM Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On G13/G14,
agx_nir_lower_sample_mask()kills demoted samples where the demote happens. Once a quad has no non-helper lane left, the kill ends the quad, and its rasterizer helper lanes go with it although they never demoted. Non-quad subgroup operations that the remaining lanes run afterwards then miss those helpers.dEQP-VK.reconvergence.terminate_invocation.bit_countchecksterminated + alive == allwith ballots taken before and afterterminateInvocation, and failed on every run.A per-pixel probe (same shader, counts written to an RGBA32UI target) shows it: in subgroups that hold 3 or 6 helper lanes, the post-terminate ballot counts 14 or 12 lanes instead of 16. Subgroups without helpers count correctly.
Shaders that discard and also use non-quad subgroup operations now take the deferred lowering. Demotes accumulate into a kill mask that is applied at the end of the shader, and no dead-quad kill is inserted before it. Every other shader keeps the immediate kill. The gallium driver uses the same entry point, so GL shaders get the same treatment.
New unit test
DemoteEarlyKill.ImmediateLoweringDefersKillsForSubgroupOperations;agx_tests957/957 pass.CTS 1.4.7.0, user-space overlays, base = aurora-wip 8135d4d:
M4 Pro (G16S), where native GL takes the same entry point: GL broad (13,223) 12,620 Pass / 0 Fail with and without the change, 0 cases changed. Vulkan on G16S/G17P uses the AGX3 deferred lowering, which this change leaves alone (vk-broad on G16S: 18,621 Pass / 0 Fail on the base).