Skip to content

hk: test the deferred occlusion-availability resolver - #82

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
test/hk-query-oq-20261027
Oct 27, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
test/hk-query-oq-20261027

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Direct tests for hk_resolve_deferred_oq_available(), the occlusion-availability resolution from #62, as Greptile asked on omacom/mesa #19.

Two commits:

  1. hk: move deferred occlusion availability into hk_query_oq.c. hk_defer_oq_available(), the per-stream decision (hk_stamp_oq_available()) and hk_resolve_deferred_oq_available() move with struct hk_oq_stamp into hk_query_oq.c and hk_query_oq.h. They need only control streams and hk_sync, but hk_query_pool.c pulls in most of the driver. No functional change.
  2. hk/tests: test the deferred occlusion-availability resolver. tests/test-hk-query-oq.c links hk_query_oq.c with the real hk_sync.c, the same way hk_sync_prior does. It runs against mock control streams, with a recording hk_dispatch_imm_writes().

Coverage (36 checks)

  • Deferral (hk_defer_oq_available()):
    • It accepts stores that all ride on one render.
    • It refuses a stream that has no stores, other immediate writes, commands, an API timestamp riding on it, a pending query reset, or stores from different renders.
  • STAMPED:
    • The render carries the store in the fragment-end slot first.
    • With API timestamps on slots 0 and 3, stores take slots 1 and then 2.
    • A slot another occlusion store already holds is skipped.
    • The stream is dropped and nothing is dispatched.
  • KEEP: the store is dispatched in place when:
    • an API timestamp came to ride on the stream while it was deferred;
    • a later query reset, or other compute, waits on the stream;
    • compute waits on the render;
    • the command buffer's tail requirement names the render;
    • the stream does not wait on the render that ended the queries.
  • MOVABLE:
    • Too few free slots and nothing later: the stores are dispatched at the end and the render's slots are left unchanged.
    • Several deferred streams, in and out of render order.

A finding about MOVABLE

With several deferred streams, the "collect into the later stream" branch of the resolver can't currently be reached.

  • While an earlier stream resolves, a later deferred stream is still in the list. It waits on its own, later render.
  • hk_stamp_oq_available() counts that wait as "compute waiting on the render subqueue", so the earlier stream is kept in place.
  • Only the last deferred stream can be STAMPED or MOVABLE, so two MOVABLE streams never meet.

The multi-stream tests document that current behaviour.

If the intent is for earlier streams to ride on their renders too, there are two options:

  • Resolve from the end of the command buffer.
  • Leave other still-deferred streams out of the waiter check, since they are themselves either dropped or folded.

That would be a functional change, so it isn't part of this PR.

Testing

Host-only meson build (-Dbuild-tests=true, asahi Vulkan only), under the usual memory cap:

  • hk_query_oq 36/36.
  • hk_sync_prior and hk_query_reset still pass.
  • libvulkan_asahi.so builds.

The end-of-command-buffer resolution of deferred occlusion availability
(hk_defer_oq_available(), the per-stream decision and
hk_resolve_deferred_oq_available()) needs only control streams and
hk_sync, but lived in hk_query_pool.c, which pulls in most of the
driver. Move it, with struct hk_oq_stamp and its description, into
hk_query_oq.c and hk_query_oq.h so it can be tested on its own.

No functional change.
Link hk_query_oq.c with hk_sync.c against mock control streams, as
hk_sync_prior does, with a recording hk_dispatch_imm_writes().

Cover hk_defer_oq_available() accepting stores that all ride on one
render and refusing streams with no stores, other immediate writes,
commands, an API timestamp, a pending query reset or stores from
different renders; the render carrying the store (fragment-end slot
first, skipping slots an API timestamp or another store holds); the
store kept in place for a later API timestamp on the stream, a later
query reset or other compute waiting on it, compute or a tail
requirement waiting on the render, or a stream not waiting on its
render; and too few free slots, alone and with several deferred streams
in and out of render order.
@DjDeveloperr
DjDeveloperr merged commit eebf55e into aurora-wip Oct 27, 2026
astaff pushed a commit to astaff/mesa that referenced this pull request Oct 28, 2026
aa733fc is the Mesa the J616s runs every day. Bring aurora-wip 2a5fd4a
into it: DJ's G17P refit and H-PLOC fixes (aurora-silicon#79, aurora-silicon#81), the deferred
occlusion resolver (aurora-silicon#82, aurora-silicon#83), the zink split-query readback fix (aurora-silicon#84)
and the virtio queue-limits fix (aurora-silicon#86).

The conflicts in the acceleration-structure sources and hk_query_pool.c
are resolved as in the earlier PR aurora-silicon#80 merge 8b7395e. That merge also
carried 2a541c6, which is held back here (see the PR).

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RyanTheTide
RyanTheTide deleted the test/hk-query-oq-20261027 branch October 30, 2026 03:23
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