Skip to content

hk: fix ray tracing hit attributes and hit kinds - #139

Merged
RyanTheTide merged 3 commits into
aurora-silicon:aurora-wipfrom
jgoyvaerts:pr/hk-rt-hit-state
Nov 2, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:aurora-wipfrom
jgoyvaerts:pr/hk-rt-hit-state

Conversation

@jgoyvaerts

Copy link
Copy Markdown

Three fixes to ray tracing hit state. They take the Vulkan ray tracing CTS lists on the M4 Pro from 5 failures to 0.

1. hk: give a hit object recorded from a triangle its own hit kind. A hit object recorded from a query took the hit kind and attributes the application passed. Those only describe a generated hit. A triangle now takes its own, from the facing bit and the barycentrics. This comes first so that no commit leaves a triangle with the application's attributes.

2. spirv: read OpHitObjectRecordFromQueryEXT operands in spec order. The grammar is Hit Object, Ray Query, SBT Record Index, Hit Object Attributes, then an optional Hit Kind. When the optional operand was missing, vtn took word 4 as the hit kind and dropped the attributes. Word 4 is the attributes pointer.

3. hk: keep the committed attributes of a generated hit on G17P. The intersection stage writes attributes straight into the ray's frame, whether or not the candidate is committed. A later candidate that is rejected overwrites the closest hit's attributes, so the closest-hit shader reads the wrong values. The attributes are now copied aside when a report commits, and put back in the frame when traversal ends on a generated hit. Any application with procedural geometry can hit this one.

Fixes

  • dEQP-VK.ray_tracing_pipeline.misc.hitattribute_closest_hit_correctness
  • dEQP-VK.ray_tracing_pipeline.ser.builtin_var: record_from_query_procedural_attribs, its _loc1 variant, multi_attrib_locations and query_hitkind_tri

Testing, M4 Pro (J616s, T6040), firmware 25G83

  • ray-query, ray-tracing-pipeline and the acceleration structure cases of binding-model and api, 74,833 cases: before 49,706 Pass, 25,122 NotSupported, 5 Fail. With these fixes 49,711 Pass, 25,122 NotSupported, 0 Fail, 0 GPU recoveries. Only those 5 cases changed. The sweep ran on aurora-wip 9fe179d plus our other commits, with the two fixes applied as one change.
  • This branch itself, on aurora-wip 8990cdb, with a kernel that accepts ray traversal: the 5 cases above and 86 ray query cases, 91 of 91 Pass.
  • A real application: a Vulkan ray tracing demo with 16.8 M instanced triangles, a TLAS rebuilt every frame, and procedural spheres whose intersection shader reports both surfaces, near one first. The far report loses and must not disturb the near hit's attributes. Without these fixes the spheres render inside out. With them they are right.
  • 8 parallel deqp-vk jobs can hit kernel capacity refusals (LowerVa, LogicalQueues, ComputeReserve). Every case affected passes alone, and it does not depend on these fixes.

Not checked

  • This needs ray traversal enabled on 25G83, which is the kernel side and goes in its own PR. Until then hk_g17p_rt_enabled keeps ray tracing hidden on the M4 Pro, so these fixes change nothing there.
  • Fix 3 covers native G17P traversal only. The M5 and software traversal paths are not changed and I could not test them. They may have the same gap.
  • vtn_hit_object_attribute_deref accepts only 32-bit scalars and vectors, as for the other record instructions. The three-operand form used to skip that check because it dropped the attributes, so a struct there now fails at compile time.

A hit object recorded from a query took the hit kind and attributes the
application passed. Those only describe a generated hit: a triangle has
its own, from the facing bit and the barycentrics, whatever the
application supplied. Choose by the committed intersection type.

Fixes the ser.builtin_var query_hitkind_tri case.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
The operands after the query are SBT Record Index, Hit Object Attributes
and an optional Hit Kind. vtn took word 4 as the hit kind when the optional
operand was missing, and took the attributes only when it was present, so
the common three-operand form passed a pointer as the hit kind and lost
the attributes.

Fixes dEQP-VK.ray_tracing_pipeline.ser.builtin_var cases that record a
procedural hit from a query: record_from_query_procedural_attribs, its
_loc1 variant and multi_attrib_locations.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
The intersection stage writes hit attributes straight into the ray's
frame, whether or not the candidate is then committed. With native
traversal a later candidate that is rejected, or that reports no hit at
all, overwrites the attributes of the closest hit, and the closest-hit
shader reads the wrong values.

Copy the attributes aside when a report commits and put them back in the
frame when traversal ends on a generated hit. The software and M5
traversal paths are not changed here and have not been checked for the
same gap.

Fixes dEQP-VK.ray_tracing_pipeline.misc.hitattribute_closest_hit_correctness.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
@RyanTheTide
RyanTheTide merged commit b15472e into aurora-silicon:aurora-wip Nov 2, 2026
@RyanTheTide

Copy link
Copy Markdown

Merged into aurora-wip with the rest of the tested G17P set (130, 111, 112, 117, 119, 120, 134, 136, 139). The resulting aurora-wip tree, b15472e, is byte-identical to the test merge that was tested.

  • Build and host: x86 build clean, meson test --suite asahi --suite vulkan 76/76.
  • J616s (M4 Pro), overlay A/B against the installed c208afc, 26,303 dEQP-VK cases (multisample, depth/stencil, resolve, subgroups.quad, ray query/RT, plus controls): no Pass lost, 0 Fail/Crash, 0 GPU recoveries.
  • Neo (A18 Pro), same list: no Pass lost, 1,100 NotSupported to Pass, 0 Fail, 0 recoveries.
  • On the Neo, the five RT cases PR 139 targets went from 0/5 to 5/5 with the overlay (driver sha 6161479f against 7d03eb83).

RyanTheTide pushed a commit to aurora-silicon/linux that referenced this pull request Nov 3, 2026
Ray-traversal work is refused on the M4 Pro's 25G83 firmware because a
stalled traversal was thought to wedge the GPU with no firmware recovery.
That does not reproduce.

A BLAS overwritten with a node cycle got a firmware reason-0 recovery in
1.76 s from a compute shader and 0.12 s from a fragment shader, with no
MMU fault, and the GPU worked afterwards. Valid traversals are not cut
off: one ray that must visit every leaf ran correctly for 31 s in compute
and 14 s in fragment, and 16,384 of them finished in a 5 s fragment job.
A compute job stops at the driver's own 38 s limit in timeout.rs, and only
that client fails.

The Vulkan ray tracing CTS lists, 74,833 cases, gave 49,711 Pass, 25,122
NotSupported, 0 Fail and 0 GPU recoveries with the Mesa fixes in
aurora-silicon/mesa#139.

Two limits remain. A recovery can still fail a running render of another
client, as with any GPU hang. And all render work waits behind a fragment
job, so a fragment traversal of many seconds freezes the desktop, and
past about 24 s the compositor fails with ETIMEDOUT.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
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.

2 participants