Repository navigation
hk: read occlusion results only after their submission completes - #57
Merged
RyanTheTide merged 1 commit intoOct 24, 2026
Merged
Conversation
A render's occlusion counts reach memory with its end-of-render cache maintenance. The availability word is written by a post-graphics compute stream that the firmware starts once the render's fragment work is done, which can be before that maintenance. vkGetQueryPoolResults then saw availability 1 and a count of 0 that was right after the queue went idle: a 64-pass repro with one query per pass hit it in ~3% of submissions, every wrong value late and none lost, and the CTS occlusion_query get_* cases flaked with results such as 3,0,0. The kernel signals a submission only after the maintenance of all its renders, which is also what the gallium driver relies on when it reads query results after the batch fence. Record, at submission, the queue timeline point that signals the submission ending each occlusion query, and on the CPU treat the query as available only once that point has signalled: wait for it with VK_QUERY_RESULT_WAIT_BIT, report VK_NOT_READY otherwise. A host reset forgets the point. vkCmdCopyQueryPoolResults still orders its reads by the availability word on the GPU. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com> Assisted-by: LLM
RyanTheTide
added a commit
that referenced
this pull request
Oct 24, 2026
hk: keep #57's occlusion fix to the native AGX3 path and wait once per submission
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.
hk: read occlusion results only after their submission completes.
A render's occlusion counts reach memory with its end-of-render cache maintenance, but the availability word is written by a post-graphics compute stream the firmware may start before that maintenance.
vkGetQueryPoolResultscould then see availability 1 with a count of 0 that became right shortly after: a 64-pass repro with one query per pass hit it in about 3% of submissions (every wrong value late, none lost), and the CTSocclusion_queryget_*cases flaked with results such as 3,0,0.The kernel signals a submission only after the maintenance of all its renders, which is what the gallium driver already relies on when it reads query results after the batch fence. So each occlusion query records, at submission, the queue timeline point that signals the submission ending it, and the CPU treats the query as available only once that point has signalled:
VK_QUERY_RESULT_WAIT_BITwaits for it (in bounded steps, so a lost device is noticed), otherwiseVK_NOT_READY. A host reset forgets the point; the point and its syncobj are published so a concurrent reader never pairs one submission's syncobj with another's point.vkCmdCopyQueryPoolResultskeeps ordering on the availability word on the GPU. Queries ended in secondary command buffers are covered because they are replayed into the primary.Hardware tested on: Apple MacBook Pro (16-inch, M4 Pro, 2024), J616s / T6040, macOS 26.6.2 firmware, kernel 7.3.0-m4.14 (aurora
integration/aurora1aa2857509d+ #406, #408-#413).How tested: Built as a system Mesa (aurora's mesa-aurora options: asahi, zink, softpipe Gallium; asahi Vulkan) and run on the M4 Pro with deqp-runner (vk-gl-cts main mustpass), 6 jobs. A 64-pass program with one occlusion query per pass, reading every result on the CPU right after the queue goes idle: 118 late reads (availability 1, count 0 that is correct shortly after) without this change, 0 with it; results copied with
vkCmdCopyQueryPoolResultswere never wrong, so only CPU reads need the change. Under CPU load an 18-caseocclusion_querygroup repeated 2,000 times gave 10 non-pass results before (late counts).query_pool.occlusion_query.*(441 cases) passes three times in a row with this change (434 pass, 7 skip); the CTS hits the race rarely on this machine, the same three runs also pass without it.🤖 Generated with Claude Code