Skip to content

borealis: native preambles on M3 when the firmware takes the spill-carrying launch - #1335

Merged
RyanTheTide merged 3 commits into
aurora-wipfrom
feat/borealis-g15-hal200-preamble
Nov 29, 2026
Merged

RyanTheTide merged 3 commits into
aurora-wipfrom
feat/borealis-g15-hal200-preamble

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 29, 2026 •

Copy link
Copy Markdown

M3 (G15) kept native constant programs and preambles off because the legacy G15 firmware (RTKit 2419) has no thread-invariant spill field in its direct compute launch. The 27.2 firmware does: J615 takes the HAL200-form launch for every dispatch. That's a firmware fact, not a chip one, so this keys it on the firmware, for compute only. It needs aurora-silicon/linux#3603, which reports DRM_ASAHI_FEATURE_COMPUTE_TI_SPILL_LAUNCH (bit 47) from the g16 runtime's T8122 row. HAL reporting and the sampler-stream path stay as they are.

What changes

  • agx_dev_g15_spill_launch() (agx_device.h) is true for G15 when the kernel reports the bit. agx_dev_native_compute_preamble() is the chip table's qualified chips plus that.
    • The compute sites use it: the compute constant-program decision and no_preamble for compute kernels, hk_agx3_compute_cprog_supported(), and hk_g17p_compute_shader_supported().
  • Render paths are unchanged on G15: the vertex constant program (hk_allow_vs_cprog()), fragment and local-read preambles, and epilog uniform exports stay on agx_chip_native_preamble().
  • agx_chip_supports_cprog(): the hardware can carry a constant program (qualified chips plus G15*). The Ioto packers and validators use it, and the device decides whether to form one.
  • The direct compute launch takes a per-dispatch g15_hal200_launch flag from the device. The direct dispatch wrappers and the indirect dispatch's geometry helper (hk_agx3_g17p_native_indirect_compute_dispatch_append()) both pass it.
    • With the flag, G15 packs the HAL200 layout: word 1 = VA[47:38] << 22 | template word 1, word 3 = 0x40000000 | VA[47:40], the same bytes as G16G.
    • Without it, G15 keeps the legacy layout and refuses spill, byte for byte as before.
  • The uAPI define is mirrored, and there's a drm-shim switch (ASAHI_SHIM_G15G_TI_SPILL_LAUNCH).
  • Tests:
    • test_g15_hal200_launch: direct and indirect (helper) launches. Spill is refused without the flag; with it, the HAL200 words; without spill, the legacy layout.
    • asahi-agx-dev-native-preamble: the bit present and absent, legacy G15S, G16G/G17P/G14G.
  • The Gallium driver is unchanged; it gets the same change with its own rows.

Rows at 7186c68 (base aurora-wip 06e34ec)

Host tests: 328 Ok / 26 Fail, the same 26 as base. asahi-agx3-compute-program-core passes 586 checks, including the indirect helper packing; asahi-agx-dev-native-preamble passes 9.

J615 (M3 G15G), one-shot of the linux#3603 kernel (7.3.0-aurora-ungg15tis+, dead-man armed, back on saved Edge after):

check base this PR
CProg, ubo.random.16bit.all_out_of_order_offsets.1* 0/11 11/11 (main 130 -> 11 instrs, 23 -> 19 GPRs), 11/11 pass
indirect workload compute.pipeline.indirect_dispatch.* (geometry helper path) 24 P / 12 NS / 0 F, CProg 0/60 24 P / 12 NS / 0 F, CProg 60/60
CTS (compute.pipeline, ubo, glsl, descriptor_indexing, push_constant, ssbo, subgroups, atomics, sync2 barriers, tessellation, geometry, occlusion) 16,254 P 16,254 P, 0 regressions, 0 GPU fault lines

Control, J615 on the stock Edge kernel (no bit): identical to base. CProg 0/60 on indirect_dispatch (24 P / 0 F), CTS 16,254 Pass -> Pass.

gpubench-vk, interleaved A/B on the paired kernel: neutral, within about ±1% except render.bindless_ubo d2 +2.9% time. compile.pso is +8.7% (2.7 -> 2.9 ms), the constant-program compile. This puts M3 compute on the G16G/G17P path; it is not a measured speedup on these benches.

Neo, G17P (second generation, shared packer/launch code), at 0ca2309: 16,475 Pass -> Pass, 0 regressions. 7186c68 only narrows G15 behaviour and adds the indirect flag, which is false off G15.

J713 (G16G): row to follow when the Mac is free.

Machines restored to their saved defaults (Enforcing, 0 failed units). Traces: traces/gpu/20261129-gpu-ungate-g15hal/j615, traces/gpu/20261129-gpu-ungate-g15fw/j615-g15g-stock-7186c689, traces/gpu/20261129-gpu-ungate-g15fw/neo-g17p.

…HAL200 firmware

G15 (M3) kept native constant programs and preambles off because the
G15 command-stream generation (RTKit 2419) has no thread-invariant spill
field in its direct compute launch. That is a property of the legacy
firmware. On macOS 27 firmware the kernel reports
DRM_ASAHI_GPU_HAL_200 for G15G, the same condition
agx_stream_sampler_state() keys on, and the HAL200 launch layout is
accepted for every launch, including ones that carry spill.

Key the decision on the firmware instead of the chip:

- agx_dev_g15_hal200() / agx_dev_native_preamble() in agx_device.h decide
  per device; the Vulkan driver's preamble, constant-program and
  uniform-export sites use them.
- agx_chip_supports_cprog() says the hardware can carry a constant
  program (the qualified chips plus G15*); the Ioto packers and
  validators use it, the device decides.
- The compute launch takes a g15_hal200_launch flag, set per dispatch from
  the device, which selects the HAL200 layout on G15. Without it G15 keeps
  the legacy layout and refuses spill, byte for byte as before.

Legacy G15 firmware (J516s M3 Pro reports HAL_LEGACY) is unchanged. The
Gallium driver keeps its current path; it gets the same change with its
own rows.

Measured on J615 (MacBook Air M3, G15G, macOS 27.2 firmware) with an
earlier arm of this change: 12,369 CTS cases Pass -> Pass, 0 GPU faults;
constant programs engage (a uniform-heavy compute shader's main program
drops from 130 to 11 instructions).

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
…LAUNCH

Both M3 firmwares report DRM_ASAHI_GPU_HAL_LEGACY, so the HAL
generation cannot tell the 27.2 firmware from the legacy one, and
reporting HAL200 would also turn on the separately-qualified sampler
stream path. The kernel instead reports a dedicated bit where the
firmware takes the spill-carrying compute launch (the g16 runtime's
T8122 row). Key agx_dev_g15_spill_launch() (renamed from
agx_dev_g15_hal200()) on that bit, mirror the define, add a drm-shim
switch (ASAHI_SHIM_G15G_TI_SPILL_LAUNCH) and a predicate test covering
the bit present and absent, legacy G15S and the qualified chips.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 29, 2026 07:15
@RyanTheTide

Copy link
Copy Markdown
Author

Note for the merger: the first commit (90b8557) says the kernel reports DRM_ASAHI_GPU_HAL_200 for G15G on 27.2. That was my wrong premise; both M3 firmwares report HAL_LEGACY. The second commit (0ca2309) keys everything on DRM_ASAHI_FEATURE_COMPUTE_TI_SPILL_LAUNCH instead, and the PR description is the accurate summary. Please squash-merge with the PR description as the message, so the wrong premise doesn't land in history. Kernel side: aurora-silicon/linux#3603.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 0ca230974b78

Blockers: None (coordinate with aurora-silicon/linux#3603 — Borealis safely ignores bit 47 until the kernel reports it — and squash-merge using the PR description so commit 90b8557a's superseded HAL_200 premise does not land in history).

Checked:

  • uAPI & device capability (include/drm-uapi/asahi_drm.h, agx_chip.h, agx_device.h, asahi_noop.c): Mirrors DRM_ASAHI_FEATURE_COMPUTE_TI_SPILL_LAUNCH (bit 47, matching linux#3603 with no bit collisions), cleanly separates hardware capability (agx_chip_supports_cprog()) from device/firmware enablement (agx_dev_g15_spill_launch() / agx_dev_native_preamble()), and adds ASAHI_SHIM_G15G_TI_SPILL_LAUNCH.
  • Direct launch packing & Borealis Vulkan wiring (agx3_compute_program_core.{c,h}, hk_agx3_ioto_program_core.{c,h}, hk_cmd_dispatch.c, hk_cmd_draw.c, hk_shader.{c,h}):
    • agx3_g17p_native_compute_launch_pack() switches G15 onto the HAL200 direct compute launch (including word1 TI spill reservation and 1D subkernel masking) only when program->g15_hal200_launch is set; without the feature bit, legacy G15 packing and spill refusal are byte-identical to before.
    • All Borealis Vulkan preamble, constant-program, uniform-export, precompiled, fused, and direct compute dispatch sites consistently query agx_dev_native_preamble(&dev->dev) / agx_dev_g15_spill_launch(&dev->dev).
    • Unit tests (test_g15_hal200_launch, asahi-agx-dev-native-preamble, updated test-hk-m5-vs-cprog.c and test-hk-agx3-ioto-program-core.c) cover both bit-set and bit-absent paths.
  • Exact-head two-generation hardware evidence (0ca23097):
    • J615 (M3 G15G) with linux#3603: CProg 11/11 on ubo.random.16bit.all_out_of_order_offsets.1*, 16,254/16,254 CTS Pass -> Pass, 0 regressions, 0 GPU faults; without bit on stock Edge kernel: CProg 0, 16,254 Pass -> Pass.
    • Neo (G17P): 16,475/16,475 CTS Pass -> Pass, 0 regressions.
  • Checked for Apple material, tool attribution, private serials, and gating: clean.
Evidence
  • Head: 0ca230974b78 (base: aurora-wip, mergeable: MERGEABLE, +344/-77 across 22 files).
  • Non-blocking note: in hk_g17p_append_indirect_launch() (src/asahi/vulkan/hk_cmd_dispatch.c:1633-1638), helper_program.launch.g15_hal200_launch is left false, so the 1x1x1 grid-helper direct launch still packs the legacy G15 format (safe today since the grid helper has word1 == 0, but worth threading agx_dev_g15_spill_launch(&dev->dev) in a follow-up for consistency with all other G15 direct launches).

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold at 0ca230974b78.

  • Bit 47 advertises a direct CDM launch layout. agx_dev_native_preamble() also releases the G15 vertex CProg path in hk_allow_vs_cprog(), fragment preambles in hk_compile_nir_impl() and hk_prepare_local_read_nir(), and render epilog uniform exports in hk_cmd_draw.c. The kernel says nothing about those render paths. Keep the new capability scoped to compute, or qualify and gate the render paths independently.
  • hk_g17p_append_indirect_launch() passes helper_program.launch directly to the indirect dispatch packer. That packer emits a direct helper launch and bypasses the new wrappers that set g15_hal200_launch. Zero spill does not establish layout equivalence because the legacy and HAL200 layouts also place address and control fields differently. Pass the capability through to the direct helper and verify the emitted packet with bit 47 present and absent. Include one J615 indirect workload that exercises that helper.

The mirrored UAPI bit has no collision on this base. Both shader cache identities already include the feature mask.

…direct helper

Review of the first version: DRM_ASAHI_FEATURE_COMPUTE_TI_SPILL_LAUNCH
says the firmware takes a direct compute launch layout. It says nothing
about render work, but agx_dev_native_preamble() also released the
vertex constant program, fragment preambles and render epilog uniform
exports on G15. And the indirect dispatch's geometry helper, a direct
launch, went to the packer without the per-dispatch layout flag.

- Rename the device predicate to agx_dev_native_compute_preamble() and
  use it only where the compile or launch is compute. The vertex,
  fragment and epilog-export sites go back to agx_chip_native_preamble(),
  so G15 forms a preamble only for a compute kernel.
- hk_agx3_g17p_native_indirect_compute_dispatch_append() takes the flag
  and gives it to the main program and to the helper.
- test_g15_hal200_launch also packs an indirect dispatch: a helper that
  reserves spill is refused without the flag and packs the HAL200 words
  with it; a helper without spill keeps the legacy layout.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH at 7186c68.

The delta restores the chip-table gate for vertex constant programs, fragment preambles and epilog exports. The indirect dispatch now sends the device capability to the geometry helper, and the packing test checks the helper record in both launch formats.

Please provide an exact-head J615 indirect-dispatch result that exercises this geometry helper with bit 47 enabled, plus a stock-kernel control, and report the targeted host packing test result. The published 0ca2309 rows predate the helper layout fix. Please also update the PR description before it becomes the squash message. It still names the old helper and says the new capability applies to uniform export sites. Describe the compute-only scope and the indirect geometry helper there.

@RyanTheTide

Copy link
Copy Markdown
Author

Review fixes (7186c68), answering Dj's two findings at 0ca2309:

  1. Scope: the bit now only releases compute. agx_dev_native_preamble() is renamed agx_dev_native_compute_preamble() and used only where the compile or launch is compute. The vertex CProg (hk_allow_vs_cprog()), fragment preambles and local-read, and the render epilog uniform exports go back to agx_chip_native_preamble(), so on G15 they behave exactly as on base.
  2. Indirect helper: hk_agx3_g17p_native_indirect_compute_dispatch_append() now takes the launch flag and gives it to the main program and to the geometry helper. The library test packs an indirect dispatch:
    • a helper that reserves spill is refused without the flag;
    • with the flag it packs the HAL200 words (word 1 = VA[47:38] | template word 1, word 3 = 0x40000000 | VA[47:40]);
    • a helper without spill keeps the legacy layout (word 3 = 0x40).

Host tests: 328 Ok / 26 Fail, the base set; compute-program-core 586 checks.

J615 row at the paired heads (one-shot linux#3603 kernel, dead-man armed, back on saved Edge after; base 06e34ec vs 7186c68):

check base this PR
CProg, ubo.random.16bit.all_out_of_order_offsets.1* 0/11 11/11 (130 -> 11 instrs), 11/11 pass
indirect workload compute.pipeline.indirect_dispatch.* 24 P / 12 NS / 0 F, CProg on 0 of 60 compute shaders 24 P / 12 NS / 0 F, CProg on 60 of 60
CTS list (as in the description) 16,254 P 16,254 P, 0 regressions, 0 GPU fault lines

Absent-bit (stock Edge) and Neo G17P rows are as in the description; the render paths they cover are unchanged by this commit. Traces: traces/gpu/20261129-gpu-ungate-g15hal/j615 (this run), .../j615-0ca23097 (previous head).

@RyanTheTide

Copy link
Copy Markdown
Author

Requested items, all at exact head 7186c68:

  • J615 indirect workload with bit 47 (one-shot linux#3603 kernel): compute.pipeline.indirect_dispatch.* gives 24 P / 12 NS / 0 F on both arms, with CProg on 60/60 compute shaders vs 0/60 on base. Posted above.
  • Stock-kernel control (J615 on 7.3.0-aurora-edge, no bit), new: identical to base. indirect_dispatch is 24 P / 0 F with CProg 0/60; the CTS list gives 16,254 Pass -> Pass, 0 regressions. Traces: traces/gpu/20261129-gpu-ungate-g15fw/j615-g15g-stock-7186c689.
  • Targeted host packing test: asahi-agx3-compute-program-core passes 586 checks, including the indirect helper in both layouts. asahi-agx-dev-native-preamble passes 9. The full asahi+poly suites give 328 Ok / 26 Fail, the same 26 as base.
  • PR description: updated for the squash message. It now describes the compute-only scope and the indirect geometry helper, and drops the old helper and uniform-export wording.

@RyanTheTide

Copy link
Copy Markdown
Author

J713 (M4 Air, G16G) no-change row at 7186c68, saved fleet85 kernel, isolated ICDs, base 06e34ec: 6,497 Pass -> Pass, 3,316 NS -> NS, 3 DeviceLost -> DeviceLost (pre-existing on this old kernel, same cases on both arms), 0 regressions. Restored: Enforcing, 0 failed units. The old kernel cuts the list short, as it did for the base. That makes three generations for the shared code: G15G (feature on and off), G16G, G17P (Neo). Traces: traces/gpu/20261129-gpu-ungate-g15fw/j713-g16g.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 7186c689.

Blockers: The prior review findings are resolved. Keep hosted CI and land Mesa ahead of Linux #3603, which exposes the feature bit.

Checked: The compute-only predicate leaves the render call sites on the existing chip capability. Indirect dispatch passes the launch flag to both the main program and geometry helper. The squash description now matches both paths. The stock-kernel control exercises the legacy path before the kernel advertises the feature.

Evidence
  • J615 on the paired kernel: 24 indirect workload passes on both sides, zero failures, and constant programs on 60/60 compute shaders with the change.
  • J615 on stock Edge: 24 indirect workload passes, zero failures and constant programs on 0/60 shaders. The wider CTS list retained 16,254 passes.
  • Reported host packing: 586 checks passed, including both helper layouts. J713 G16G retained 6,497 passes and the three pre-existing device losses.
  • #1335 (comment)
  • #1335 (comment)

@RyanTheTide
RyanTheTide merged commit 22d31fe into aurora-wip Nov 29, 2026
@RyanTheTide
RyanTheTide deleted the feat/borealis-g15-hal200-preamble branch November 29, 2026 13: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.

2 participants