Skip to content

agx: let G17P ray queries commit opaque triangle hits in hardware - #21

Open
DjDeveloperr wants to merge 2 commits into
integration/aurorafrom
mirror/g17p-rq-hw-commit
Open

DjDeveloperr wants to merge 2 commits into
integration/aurorafrom
mirror/g17p-rq-hw-commit

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Collaborator

G17P ray queries run in candidate mode (control 0x9142), so the hardware queues every triangle hit, opaque ones included, for the software candidate loop. Each hit then costs a software pass of dependent loads plus a hardware round trip.

With field 12:11 set (0x9942), the hardware commits opaque triangle hits itself and queues only the hits software has to decide. This change uses 0x9942 when the ray flags leave opaque triangle hits to the hardware. That means none of these flags is set:

  • Opaque. Such rays commit every hit anyway, and incoherent ones traced slower with hardware commits.
  • NoOpaque.
  • A facing or opacity cull.
  • SkipTriangles.

After each trace or refill, the lowering takes the hardware's committed hit when it is closer than the current committed one. It builds the same packets a software commit would:

  • the distance comes from the tmax slot;
  • the hit words come from query words 256/512;
  • the instance comes from the committed-instance pointer array at query offset 8960.

The current-instance array at 9152, which candidates use, holds the instance where traversal stopped, which can be past the committed hit. The merge only looks up the committed fields the shader reads (node, instance IDs, barycentrics).

How the layout was established:

  • With 0x9942 alone, the CTS failures (procedural triangle_in_between, callable_shader, tri_and_box) came from the lowering ignoring hardware-committed hits. Merging the hardware record fixes them.
  • An image-CRC comparison then exposed a stale instance for some reflection hits.
  • A shader-printf scan of the query block, at a pixel with a wrong image, located the committed-instance array: it matched the pointer the software path commits.

Mirror of aurora-silicon#100 (merged as 3295ac7). Qualification on J700 (Neo) against aurora-wip 86ffb65:

  • gpubench-rt RT plan, alternated ×2. Every rt.scene image CRC is identical to the baseline.

    Row Change
    Solar Bay, ray query +8.3%
    Solar Bay, ray-tracing pipeline +7.7%
    extreme +11.0%
    heavy +5.9%
    light +3.7–4.2%
    medium +3.4–3.8%
    rt.asbuild unchanged
    rt.rays, coherent and incoherent, all depths −0.5…+1.2% (noise)
  • Full ray-query + ray-tracing-pipeline CTS: 47102 pass / 10088 not supported / 0 fail, identical to the baseline.

  • Host asahi meson suite: 75/75 on aurora-wip.

  • No kernel errors during the runs.

This omacom tree has the identical agx_nir_gen1_ray_query.{c,h}. The cherry-pick builds with -Dwerror=true and passes the asahi meson suite 76/76.

Candidate control 0x9142 queues every triangle hit, opaque ones included,
for the software candidate loop. With field 12:11 set (0x9942) the hardware
commits opaque triangle hits itself and queues only what software has to
decide. Use it when the ray flags leave opaque triangle hits to the
hardware: no Opaque (such rays commit every hit anyway, and incoherent ones
traced slower with hardware commits), NoOpaque, facing or opacity culls,
or SkipTriangles.

After each trace or refill, take the hardware's committed hit when it is
closer than the committed one, building the same packets a software
commit would: the distance from the tmax slot, the hit words from query
words 256/512, and the instance from the committed-instance pointer at
8960. The current-instance pointer at 9152 is wherever traversal stopped,
which can be past the hit. Look up only the committed fields the shader
reads.

(cherry picked from commit 3a20791)
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous first-hit stopping issue is fixed.

Summary

Lets G17P hardware commit eligible opaque triangle hits and copies those hits into the query’s saved result.

  • Eligible G17P ray queries now commit opaque triangle hits in hardware.

Reviews (2) · Last reviewed commit: "agx: end G17P ray queries with Terminate..." · Reviewed by Greptile

Comment thread src/asahi/compiler/agx_nir_gen1_ray_query.c
…re hit

A hardware-committed hit merged into a TerminateOnFirstHit query left the
query running: later refills could still hand nearer candidates to the
shader after a hit was committed. End the query there, as a software
commit of an opaque triangle does.

(cherry picked from commit bdd43fa)
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