Skip to content

hk: dispatch ray tracing continuations through balanced searches - #321

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
rtrec/hk-rt-cont-dispatch-pr
Nov 14, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
rtrec/hk-rt-cont-dispatch-pr

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Follow-up to #278. Continuation mode (ray tracing pipelines deeper than 3 on G17P) mapped a shader binding table handle to its stage entry with one compare-and-select per shader group. That chain sits in a single basic block. It also ran the scheduler's parts behind one compare each.

For a pipeline with thousands of groups this made compilation superlinear. With continuation mode forced, dEQP-VK.ray_tracing_pipeline.large_shader_set.*.4096 (one raygen calling one of 4,096 callables) compiled in 86-307 s, against 2.5-5 s for the inlined megakernel. A deep pipeline with that many hit or callable groups would hit the same cost.

Change

  • Handle → entry: a balanced search over the sorted group handles, with leaves of at most 8 selects.
  • Part dispatch: a balanced search over the consecutive part numbers, with leaves of at most 4 ifs.
  • Effect: log2(n) compares per lookup at run time, and no basic block grows with the group count.
  • Scope: the megakernel's callable dispatcher (hk_callable_pc) is untouched, so pipelines up to depth 3 compile exactly as before.

Tests

  • Unit test: test-hk-rt-cache-control now also builds depth-4 pipelines with 8 and 48 callable groups and requires the same largest basic block for both. On the host it measures 102 instructions for both; with the old chain the block grows with the group count. The existing continuation checks are unchanged (no calls, code size independent of depth, linear stack).
  • Neo (J700, G17P): with the default-off diagnostic switch that forces continuation mode (not part of this PR), all 32 large_shader_set.* cases pass under a 90 s per-case cap, *.4096 included, with no GPU kernel log lines. Run on a second J700, branch rtrec/r4-ryan (this change on hk: run deep ray tracing pipelines as continuations on G17P (maxRayRecursionDepth 3 -> 31) #278).

🤖 Generated with Claude Code

Continuation mode mapped a shader binding table handle to its entry with
one compare-and-select per group, a chain that sits in a single block,
and ran the parts behind one compare each. A pipeline whose raygen calls
one of 4096 callables then compiled for 90 to 300 seconds on G17P, against
5 seconds for the inlined megakernel.

Search the sorted handles and the consecutive part numbers with balanced
trees instead: log2(n) compares per lookup and no block grows with the
number of groups.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Author

Landing this as step 4 of a tree-checked batch merge (batch 6). The batch is gated on the G17P Neo:

  • the full fast CTS gate, compared against a base arm on the current aurora-wip (0 confirmed regressions);
  • targeted parts for the new features: mesh shader, descriptor buffer, nested command buffers;
  • asahi unit tests on the exact landing tree.

The hk meta-stages fix (#329) lands first. Without it, mesh-by-default made 14 shader_object 8-attachment rendering cases fail at vkEndCommandBuffer; with it, all of them pass on hardware. The expected tree after this merge is fb207e385504.

@DjDeveloperr
DjDeveloperr merged commit e54b411 into aurora-wip Nov 14, 2026
@RyanTheTide
RyanTheTide deleted the rtrec/hk-rt-cont-dispatch-pr branch November 16, 2026 05:17
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