Skip to content

hk: let only G17-runtime renders carry occlusion availability - #94

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
fix/hk-oq-stamps-g17p-only
Oct 29, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
fix/hk-oq-stamps-g17p-only

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Oct 29, 2026 •

Copy link
Copy Markdown

Fixes the blocker on omacom#19, raised by maralcbr and chriskearney and confirmed on M3 Pro hardware by chriskearney.

Problem. Native AGX3 occlusion pools let a render carry a query's availability in one of its four retirement timestamp slots (e07644e). A CPU read that finds such a timestamp skips the submission wait. That assumes the kernel writes every slot when it retires the render, after the end-of-render maintenance that makes the counts visible.

  • The G17 kernel does that.
  • On G15 (M3), the firmware writes each slot from its stage's own start or end record. The vertex-end stamp lands when tiling finishes, before the fragment work writes the counts.

So with two queries in one render, the second rides on the vertex-end slot. vkGetQueryPoolResults, even with WAIT_BIT, then returns its count as available before the fragment work has written it. chriskearney's M3 Pro probe read the later query first, before the fence: 48/48 early reads returned 0, while every read after the fence was correct.

Change.

  • hk_oq_render_stamps_supported() gates the stamped pool. It returns true for G17P and for M5 (G17G/G17S).
  • M5 runs the same G17 kernel runtime for render retirement. A render completes only once its completion stamps cover it, after the end-of-render maintenance (g17/queue/render/retirement.rs, complete_poll()). The host then writes the four stage timestamps into the slots before signalling the fence (g17/completion.rs, Output::publish()). Only the render publication and notification differ on M5. This is from the M5 kernel source (m5/push-20261025, T6050 probed through probe_g17()); M5 hasn't been measured on this path.
  • G15 and G16G keep the queued availability store and the submission wait on readback, as before e07644e.

Testing (host only):

  • hk_query_oq_test: 55/55, including the new chip checks (G17P and M5 stamp; G15G/S/C and G16G don't).
  • hk_query_oq.c and hk_query_pool.c build with -Dwerror=true.
  • G17P and M5 behaviour is unchanged. On M3, the queued-store path is the one chriskearney's control arm (7f0206e) ran with 0/48 early reads.

Native AGX3 occlusion pools let a render carry a query's availability
in one of its four retirement timestamp slots, and a CPU read that
finds such a timestamp skips the submission wait. That assumes the
kernel writes every slot when it retires the render, after the
end-of-render maintenance that makes the counts visible. The G17
kernel does. On G15 (M3) the firmware writes each slot from its
stage's own start or end record: the vertex end lands when tiling
finishes, before the fragment work writes the counts. With two
queries in one render, the second one rides on the vertex-end slot,
and vkGetQueryPoolResults, even with WAIT_BIT, returns its count as
available before the fragment work wrote it. On an M3 Pro, reading
the later query first before the fence returned 0 in 48 of 48 reads,
against the correct count after the fence.

Add hk_oq_render_stamps_supported(), true only for G17P, where the
path was measured, and gate the stamped pool on it. Every other chip
keeps the queued availability store and the submission wait on
readback, as before the stamped path. Other chips whose kernel writes
the slots at retirement can be added once qualified.

test-hk-query-oq checks the chip decision.
M5 (G17G/G17S) runs the same G17 kernel runtime as G17P for render
retirement. A render completes only once its completion stamps cover
it, after the end-of-render maintenance (g17/queue/render/retirement.rs,
complete_poll()). The host then writes the four stage timestamps into
the requested slots before signalling the fence (g17/completion.rs,
Output::publish()). Only the render publication and its notification
differ on M5. A stamp in a query's availability slot therefore means
the counts are visible there too, so include G17G and G17S in
hk_oq_render_stamps_supported(). G15 and G16G keep the queued store.
@DjDeveloperr DjDeveloperr changed the title hk: let renders carry occlusion availability only on G17P hk: let only G17-runtime renders carry occlusion availability Oct 29, 2026
@DjDeveloperr
DjDeveloperr merged commit 13cb39e into aurora-wip Oct 29, 2026
@RyanTheTide
RyanTheTide deleted the fix/hk-oq-stamps-g17p-only branch October 30, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant