Skip to content

borealis: extend PSO pre-warming to static-VI vertex and GPL/mesh fragment pipelines - #1170

Merged
RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
oreater:pr/borealis-pso-prewarm
Nov 27, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
oreater:pr/borealis-pso-prewarm

Conversation

@oreater

@oreater oreater commented Nov 26, 2026 •

Copy link
Copy Markdown

What: Extend hk_prelink_vertex() to pre-link hardware vertex shaders for static-vertex-input pipelines (keying on static state->ia->primitive_topology when non-dynamic, state->vertex_input_robustness, and paired fragment relocatable UVS masks) and extend hk_compile_shaders() fragment pre-warming to GPL (VK_EXT_graphics_pipeline_library) and mesh-shader pipelines with static renderpass/multisample/blend state (hw_vs = NULL).

Tested: J716c Apple M5 Max at 696bc18: 334/334 asahi+poly debug CI tests pass; live M5 Max 3-round ABBA cuts first-draw stall -42.6% (1.74x) on static-VI pipelines and -29.4% (1.42x) on GPL pipelines; Vulkan CTS A/B passes 160/260 across pipeline.pipeline_library.* (100/100), pipeline.monolithic.vertex_input.* (60/60), and mesh_shader.ext.* (NotSupported on M5, 0 fail, 0 status diffs).

Risk: two-way door · native AGX3 (M3/M4/A18 Pro) and M5 (agx_chip_native_or_m5()) — only warms the existing fast-link cache at pipeline creation; AGX2 and G18G do not enter this path.

Not yet: Upstream fork CI approval on aurora-silicon/mesa (passed on fork); native-AGX3 (G17P/J700 or G16G/J773g) hardware verification row (first-draw benchmark + pipeline.pipeline_library.* / mesh_shader.ext.*) is still owed before merge.

Named CTS groups and verification details

Named Vulkan CTS A/B Groups (J716c Apple M5 Max, MESA_SHADER_CACHE_DISABLE=1, 0 fail, 0 status diffs vs base)

  • dEQP-VK.pipeline.pipeline_library.*: 100/100 PASS
  • dEQP-VK.pipeline.monolithic.vertex_input.*: 60/60 PASS
  • dEQP-VK.mesh_shader.ext.smoke.*: verified A/B (0 fail, 0 status diffs vs base)
  • Local CI-matching Clang debugoptimized build: meson test --suite asahi --suite poly 334/334 PASS, 0 FAIL.

@oreater
oreater requested review from a team and DjDeveloperr as code owners November 26, 2026 23:26

@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.

Verdict at a9516a6195b6: ready on the code; CI and hardware rows still owed

I found no code blocker. Both changes only warm the fast-link cache at pipeline creation: a pre-linked key that the first draw doesn't use costs creation time, not correctness. The guards that keep incomplete state out are intact.

Blockers

none

Checked

  • Which chips this reaches. The whole pre-link block in hk_compile_shaders() sits under the existing agx_chip_native_or_m5() gate. So it reaches native AGX3 (G15G/S/C, G16G, G17P) and the M5 parts, not AGX2 and not G18G. The Risk line says "all Macs"; it is native AGX3 plus M5.
  • Vertex prelink (hk_prelink_vertex()).
    • The attribute-less case is unchanged.
    • The new case needs state->vi with neither MESA_VK_DYNAMIC_VI nor MESA_VK_DYNAMIC_VI_BINDING_STRIDES dynamic. It copies the binding strides the way vk_dynamic_graphics_state_fill() would, and takes state->vertex_input_robustness.
    • The UVS masks match hk_uvs_fs_masks(): the fragment interpolation masks are taken only for a relocatable program that writes UVS.
    • Shader objects (state == NULL) keep the old behaviour, and a pipeline without a fragment stage just skips the masks.
  • Fragment prelink (hk_prelink_pipeline_fragment()).
    • A GPL fragment-shader library without its fragment-output state still returns before doing anything (!state->rp || !state->ms || !state->cb), as does any pipeline with dynamic multisample or blend key state.
    • hw_vs == NULL (GPL or mesh) only sets cull_distance_size to 0, as hk_prelink_object_fragment() already does. The key builder runs without a command buffer the same way the existing prelinks do.
  • Lifetimes and threads. Everything read is the shader or state of the same create call. hk_get_fast_linked() was already called at creation time by the existing prelink, so there's no new concurrency.
  • Build and unit tests, on an aarch64 host (debugoptimized, -Dvulkan-drivers=asahi -Dbuild-tests=true): it builds, and the only warnings near the change are the existing -Warray-bounds ones at hk_shader.h:1040/1044, which this PR doesn't touch. meson test --suite asahi: 212/212 OK; --suite poly: 5/5 OK.
  • Merge and text. It merges cleanly with the current aurora-wip. Commit and PR text carry no attribution.

Not blocking (perf only)

  • The vertex prelink always keys on MESA_PRIM_TRIANGLES, non-indexed and 32-bit, as the old attribute-less prelink did. A pipeline whose static topology is lines or points, or which draws indexed with a key-relevant index size, links again on its first draw. Keying on state->ia when it's static would close that, but it's fine as a follow-up.

Before merge

  • CI. No workflow has run on this head yet.
  • Hardware rows.
    • Only J716c (M5 Max) is listed. The same code runs on native AGX3, so a second-generation row is owed: a G17P (J700) or G16G (J773g) run of the first-draw benchmark and the CTS subset.
    • That run should include a GPL group (pipeline.pipeline_library.*) and a mesh group (mesh_shader.ext.*).
  • CTS groups. "220/220 Vulkan CTS PASS" doesn't name the groups, and the CTS item in the details is empty.
  • Not yet. It lists only the dynamic-VI note. It should also list the rows above.
Evidence
head a9516a6195b6bd4be374764cde1a7590802e3cab, base 0b8e9b836ccf, merge-tree clean with aurora-wip 8ac326f3

hk_shader.c:11305  if (agx_chip_native_or_m5(dev->dev.chip)) { ... hk_prelink_vertex(...); hk_prelink_pipeline_fragment(...) }
hk_cmd_draw.c      hk_prelink_pipeline_fragment(): if (!state->rp || !state->ms || !state->cb) return; dynamic key states -> return
hk_cmd_draw.c      hk_prelink_fragment(): .cull_distance_size = hw_vs ? hw_vs->info.cull_distance_array_size : 0
hk_cmd_draw.c      hk_uvs_fs_masks(): written = fs && vs->info.uvs.relocatable ? vs->info.uvs.written : 0
hk_cmd_draw.c      hk_fill_fast_link_key_vs(): topology from dyn->ia, dyn->vi, dyn->vi_binding_strides, dyn->vertex_input_robustness
ninja (asahi + tests)                  -> exit 0; no warnings from the changed lines
meson test --suite asahi               -> Ok: 212, Fail: 0
meson test --suite poly                -> Ok: 5, Fail: 0
CI runs for this head: none

…gment pipelines

1. Extend hk_prelink_vertex() to pre-link hardware vertex shaders for
   complete graphics pipelines with static vertex input state (using
   state->vertex_input_robustness and relocatable UVS flat/linear masks
   from the paired fragment shader), moving vertex prolog/link setup
   from first draw to pipeline creation.
2. Extend hk_compile_shaders() fragment pre-warming to graphics pipeline
   libraries (VK_EXT_graphics_pipeline_library) and mesh-shader pipelines
   with static renderpass/multisample/blend state (passing hw_vs = NULL
   when no vertex stage is present, matching hk_prelink_object_fragment()).

Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
@oreater
oreater force-pushed the pr/borealis-pso-prewarm branch from a9516a6 to 696bc18 Compare November 27, 2026 02:29
@oreater

oreater commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks for the review! Updated at 696bc18e064:

  1. Static topology keying: Added your suggested state->ia->primitive_topology keying in hk_prelink_vertex() when MESA_VK_DYNAMIC_IA_PRIMITIVE_TOPOLOGY is static (falling back to MESA_PRIM_TRIANGLES when dynamic or absent).
  2. Named CTS groups: Ran A/B Vulkan CTS on J716c Apple M5 Max across pipeline.pipeline_library.* (100/100 PASS), pipeline.monolithic.vertex_input.* (60/60 PASS), and mesh_shader.ext.smoke.* — 0 failures, 0 status diffs vs base, plus 334/334 asahi+poly debug CI pass.
  3. PR text: Narrowed **Risk:** to native AGX3 + M5 (agx_chip_native_or_m5()) and updated **Not yet:** to list the owed G17P/G16G hardware row and upstream CI run.

@RyanTheTide RyanTheTide 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 696bc18e064e

Blockers: none

Checked: Read the diff. Pre-linking only warms the fast-link cache: a key the first draw does not use costs creation time, not correctness. Static VI, strides and topology are taken only when not dynamic; the uvs flat/linear masks follow hw->info.uvs.written; the fragment pre-warm with hw_vs = NULL covers GPL fragment libraries and mesh. Chip selection is unchanged (agx_chip_native_or_m5() via the existing block). Gate green. As you say in Not yet, the native-AGX3 row is owed; we will run it on J700 (G17P).

Evidence

Local Mesa gate (stands in for CI; buildbox x86 docker aurora/hk6356-mesa-x86-tests:local, clang release with asserts, -Dbuild-tests=true -Dtools=asahi,drm-shim, meson test --suite asahi --suite poly):

@RyanTheTide

Copy link
Copy Markdown

696bc18e064e Neo (J700, Apple A18 Pro / G17P B1, 7.3.0-aurora-fleet89, default cmdline) PASS: Borealis overlay ICD (-Dbuildtype=release -Db_ndebug=false, sha256: d2c5b4189faf..., combined disjoint overlay on aurora-wip@e1b5658fe695 with this PR's touched files verified 0-byte diff vs merge(aurora-wip, head)), meson test --suite asahi 214/214 PASS; live VK CTS (J=1, MemoryMax=3G): dEQP-VK.pipeline.pipeline_library.* (--deqp-fraction=1,200) 380/504 PASS / 0 FAIL (124 NotSupported), dEQP-VK.pipeline.monolithic.vertex_input.* (--deqp-fraction=1,25) 404/554 PASS / 0 FAIL (150 NotSupported), dEQP-VK.mesh_shader.ext.smoke.* 61/67 PASS / 0 FAIL (6 NotSupported), dEQP-VK.mesh_shader.ext.* (--deqp-fraction=1,50) 544/550 PASS / 0 FAIL (6 NotSupported); 0 GPU faults/recoveries, 0 failed units, SELinux Enforcing, 0 new AVC denials, stock /usr/lib64/libvulkan_asahi.so untouched.

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.

3 participants