Skip to content

borealis: incremental HAL200 FS PPP update, fast draw flush, and graphics root trimming - #706

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
perf/borealis-hal200-fast-draw-flush
Nov 22, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
perf/borealis-hal200-fast-draw-flush

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 22, 2026 •

Copy link
Copy Markdown

Summary

On Borealis verified HAL200 GPUs (G16G / G17P), every draw that updates push constants, dynamic uniform/storage buffers, vertex buffers, draw parameters, or gl_DrawID previously:

  1. Rebuilt and re-emitted the full 68-byte HAL200 bind tail + 4-byte draw-state selector (allocating a 188-byte state block, relocating 8 offsets, comparing scissor/depth-bias tails, and making the GPU re-fetch all 9 PPP records);
  2. Executed the full ~700-line hk_flush_dynamic_state_slow() path; and
  3. Uploaded the entire 1520-byte graphics root descriptor table on every root update.

This PR adds three complementary optimizations gated uniformly on a single verified HAL200 capability predicate (agx_chip_native_hal200() — G16G + G17P, excluding unverified G15G/S/C M3 so G16G and G17P execute the exact same codepath):

  1. Unified verified HAL200 capability predicate (src/asahi/lib/agx_chip.h):
    • Adds agx_chip_native_hal200() covering AGX_CHIP_G16G and AGX_CHIP_G17P (excluding G15G/S/C M3 where tail-less VDM state updates and standalone 28-byte FS PPP updates are unverified).
    • Used consistently across bind-tail elision, standalone FS PPP updates, fast draw flush, AND graphics+compute root trimming (hk_cmd_buffer.c/.h, hk_cmd_draw.c, hk_cmd_upload.c, hk_shader.c).
  2. Per-stream HAL200 bind-tail latch + 0-byte elision + 8-byte incremental FS PPP update (hk_cmd_buffer.h, hk_cmd_buffer.c, hk_cmd_draw.c):
    • Latches the last published HAL200 bind tail in struct hk_cs::g17p_bind_tail.
    • When subsequent ordinary draws in the same VDM stream keep every non-FS PPP record unchanged:
      • 0-byte elision (with a zero-call shortcut skipping hk_upload_usc_words when prepared matches) when the fragment program is unchanged (e.g. draw-ID, draw-parameter, or VBO-only changes).
      • Single 8-byte VDM PPP State Update (0x00000700, compact 32-bit offset) pointing to a 64-byte-aligned 28-byte HAL200 fragment PPP record when only the fragment USC program moved (e.g. push-constant / dynamic-UBO / push-descriptor base updates; includes comment noting hk_upload_usc_words() detects push-descriptor set base movement via its returned USC address).
    • Separates g17p_native_ppp_handled from *g17p_native_bind_tail_emitted_out so elided draws skip both legacy PPP fallthrough and the 4-byte draw_state_offset selector.
    • Invalidates cs->g17p_bind_tail.valid on VDM stream links (hk_ensure_cs_has_space()), viewport flushes (hk_flush_vp_state()), robust-index slots (hk_emit_robust_index()), and full graphics state invalidation (hk_cmd_buffer_dirty_all()).
  3. Guarded HAL200 fast draw flush with shared slow/fast helpers (hk_cmd_draw.c):
    • Factors vertex-attribute root updates and draw-parameter / draw-ID uploads into shared helpers hk_flush_vertex_attribs_root() and hk_flush_draw_params_and_id() called by both hk_flush_dynamic_state_slow() and hk_g17p_flush_dynamic_state_fast(), preventing drift between paths.
  4. Verified HAL200 graphics root-descriptor footprint trimming (hk_nir_root_size.h, hk_shader.c, hk_cmd_upload.c, hk_cmd_buffer.h):
    • Measures hardware vertex and fragment shader root footprints via hk_nir_root_size(), floored at hk_root_descriptor_offset(push) to preserve all driver prolog/epilog loads.
    • Trims graphics root uploads to the active VS/FS maximum and forces root_dirty when switching to a shader needing a larger root than cmd->state.gfx.uploaded_root_size.
  5. Tightened G17P drm-shim validator & dedicated unit tests (asahi_g17p_stream_validator.c/.h, asahi_noop.c, g17p_vulkan_bind_tail_state_change.c, test-hk-root-size.c, hk_cpu_upload_bench.c):
    • Validator tracks per-stream bind_tail_latched, have_latched_vs, latched_vs, latched_fs_slot, elided_bind_tails, and incremental_fs_ppp_updates: resets latch on STREAM_LINK and non-FS PPP updates; rejects bind-tail elision when unlatched or when non-pipeline VDM state changed; rejects standalone 28-byte FS PPP updates unless latched, 64-byte aligned, valid slot 1, and all non-program slot-1 fields match the latched record.
    • New drm-shim unit test hk-g17p-bind-tail-state-change (src/asahi/vulkan/tests/g17p_vulkan_bind_tail_state_change.c) executes 8 draws in one render pass (initial draw, push-constant-only update, vkCmdSetScissor, vkCmdSetViewport, vkCmdSetCullMode, vkCmdSetDepthCompareOp, blend-enabled pipeline switch, and final push-constant-only update) and asserts exact full=6, elided=2, fs_ppp=2 under ASAHI_SHIM_VALIDATE_G17P_STREAM=1, proving every non-FS PPP state change re-emits the full bind tail.
    • Expanded test-hk-root-size to cover the offsetof(push) floor, hk_gfx_root_descriptor_size(), root-growth re-upload trigger, missing-footprint full-root fallback, and agx_chip_native_hal200() (G16G/G17P vs G15G/non-HAL200).

Verification (R2 — 6eaea736177f)

Host CI, Policy & drm-shim Validator Tests

  • DEFAULT_BRANCH=aurora-wip ./.github/aurora/agent-policy.sh pr HEAD: PASS (PR head is clean)
  • FEDORA-CI 6eaea736177f05d7c055aff7046586e99c65c2b3: 156 Pass / 0 Fail / 0 Timeout / 0 Skipped
  • -Dtools=drm-shim test suite on fedora (6eaea736177f): 3/3 PASS
    • hk-g17p-bind-tail-state-change: OK (8 draws, 0 indexed, 8 state updates (2 elided, 2 fs_ppp), bind-tail counts matched: full=6 elided=2 fs_ppp=2)
    • hk-g17p-compressed-layer-copy: OK
    • hk-g17p-tess-batch-stream: OK (256 draws, 256 indexed, 256 state updates (255 elided, 255 fs_ppp))

Note on exact driver parity for MacBook Neo rows below: Neo hardware runs executed on 733b49ffc16 (libvulkan_asahi.so SHA-256 1c747ad60f04664624d287241c16a3d399c98c8890263ac1a2a2573117b0beaa, base c0b51ef2455). The compiled driver code (src/asahi/lib/, src/asahi/vulkan/hk_*.c, src/asahi/vulkan/hk_*.h) has zero diff between 733b49ff and 6eaea736177f (the sole delta is adding the hk-g17p-bind-tail-state-change drm-shim test + asahi_noop.c counter assertion).

MacBook Neo (G17P B1) — TVB-Overflow Partial Render Stress Proof (base vs head)

Standalone Vulkan probe rendering overlapping alpha-blended screen-covering triangles inside a non-trivial scissor rect across 512–2048 push-constant draws in a single render pass (with COLOR_ATTACHMENT_WRITE -> TRANSFER_READ + TRANSFER_WRITE -> HOST_READ barriers):

Geometry Load (1024×1024) Tile-Tri Refs Base CRC / Corner / Center Head CRC / Corner / Center Frame Anatomy / Health
512 draws × 64 tris (32,768 tris) ~33.6M 0xbcb9de68 / 0xff402010 / 0x20e3e6d7 (358.1 ms) 0xbcb9de68 / 0xff402010 / 0x20e3e6d7 (347.9 ms) BIT-EXACT, kfault_delta=0
1024 draws × 128 tris (131,072 tris) ~134.2M 0xd9ee7eaa / 0xff402010 / 0x20e5f0dd (1514.9 ms) 0xd9ee7eaa / 0xff402010 / 0x20e5f0dd (1540.3 ms) BIT-EXACT, st=r1024:v1024:n1024:p1022 (1,022 incremental FS PPP updates), kfault_delta=0
2048 draws × 256 tris (524,288 tris) ~536.9M (TVB overflow / partial render) 0xbc0a3015 / 0xff402010 / 0x20e5f0dd (6474.0 ms) 0xbc0a3015 / 0xff402010 / 0x20e5f0dd (6602.8 ms) BIT-EXACT, exact scissor border + blend state preserved across partial renders, kfault_delta=0

MacBook Neo (G17P B1) — 4-Round Interleaved ABBA + Multi-Pass Scene CRC Parity (c0b51ef245 vs R2)

All runs verified with 100% bit-exact CRCs, MESA_SHADER_CACHE_DISABLE=true, sleep_guard=active, pmu=30 00, kfault_delta=0, avc_delta=0:

Benchmark Depth Base wall (us) Head wall (us) Wall Speedup Base GPU (us) Head GPU (us) GPU Speedup Base Rec CPU (us) Head Rec CPU (us) CRC
render.mdi (draws=2048, bindless=1024) 1 713.3 491.6 1.451× 432.9 267.8 1.616× 234.8 186.1 b9cce2ef EXACT
render.mdi (draws=2048, bindless=1024) 2 322.6 237.4 1.359× 427.4 259.7 1.645× 226.3 191.8 b9cce2ef EXACT
render.bindless_ubo (desc_buf, draws=2048) 1 1041.7 850.3 1.225× 544.7 422.2 1.290× — — 57e7bedd EXACT
render.bindless_ubo (desc_buf, draws=2048) 2 563.7 438.2 1.286× 536.9 411.4 1.305× 493.5 392.6 57e7bedd EXACT
render.bindless_ubo (ubo_vec4, draws=2048) 1 1041.7 847.5 1.229× 545.0 422.6 1.289× — — 57e7bedd EXACT
render.bindless_ubo (ubo_vec4, draws=2048) 2 553.1 432.5 1.279× 536.3 410.9 1.305× 487.2 380.5 57e7bedd EXACT

Multi-pass scene parity (2 rounds each, depth=2, base vs head):

  • render.postfx (1440p, msaa=1): ce5a5fe7 EXACT (neutral timing)
  • render.postfx (1080p, msaa=4): 668d6f0a EXACT (neutral timing)
  • render.deferred (dram): 2cfe9a54 EXACT (neutral timing)
  • render.shadow (d32f, 2048×2048): c0fb9993 EXACT (neutral timing)

MacBook Neo (G17P B1) — Full-Group Vulkan CTS (Zero Caps)

Grand Total: 163,089 Pass / 0 Fail across 356,950 full-group mustpass cases (plus 6,695 Pass / 0 Fail on vk-renderpasses.txt), pmu=30 00, sleep_guard=active, kfault_delta=0, avc_delta=0:

Full CTS Group Total Cases Pass Fail NotSupported
dEQP-VK.dynamic_state.* 671 531 0 140
dEQP-VK.pipeline.*push_constant* (monolithic, library, fast_linked, shader_object) 437 409 0 28
dEQP-VK.api.command_buffers.*secondary* 19 17 0 2
dEQP-VK.multiview.* 838 835 0 3
dEQP-VK.draw.* (draw.renderpass + draw.dynamic_rendering) 29,475 27,066 0 2,409
dEQP-VK.renderpasses.renderpass1.* 19,798 15,984 0 3,814
dEQP-VK.renderpasses.renderpass2.* 32,680 14,707 0 17,973
dEQP-VK.renderpasses.dynamic_rendering.* 29,209 17,268 0 11,941
mustpass/main/vk-default/shader-object/*.txt (all 10 groups incl. 240,687-case rendering.txt) 243,823 86,272 0 157,551
Total (full-group mustpass) 356,950 163,089 0 193,861
  • Non-mustpass dEQP-VK.shader_object.performance.* (30 timing-ratio micro-checks) behaves equivalently to aurora-wip baseline (base c0b51ef2: 9 Pass / 15 Fail / 6 QualityWarning; R2: 12 Pass / 15–16 Fail / 1–2 QualityWarning).
  • Exact-head M4 (G16G) R2 verification row incoming from the M4 Mac mini lane (G16G already passed 1,612/0 + 1.403× wall / 2.044× GPU on R1).

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Thanks, the numbers on Neo look good. Before this goes in I have concerns about scope, chip selection and coverage.

  • Scope. The latch, the tail elision, the 8-byte FS PPP update and the fast flush are all selected by agx_chip_native_agx3() (hk_cmd_buffer.c:4681, hk_cmd_draw.c:9269 via 11123, 11938, 13016). That set is G15G/G15S/G15C (M3, G15 command stream), G16G and G17P (agx_chip.h:299-322), not just "HAL200 (G17P/G16G)". The body and the comment at hk_cmd_draw.c:11919 should say so. More importantly, nothing shows that a VDM state update with no bind tail, or a standalone 28-byte FS record update, is honoured on G15 or G16G. Please post rows for an M3 and an M4 machine at this head, or select the new paths by a command-stream/record capability that has been verified.
  • Root trimming is selected by dev->dev.chip == AGX_CHIP_G17P (hk_shader.c:5382/5384, hk_cmd_upload.c:30, hk_cmd_draw.c:11621, 11987). Neither the root table layout nor hk_nir_root_size() is chip-specific. Please key it on something the trim actually depends on, or apply it to every native chip. If G16G/G15 must be excluded, the commit message should say why. As it stands, G16G runs the new fast flush with a full root and G17P runs it with a trimmed one, and only the second has been tested.
  • The fast flush (hk_cmd_draw.c:12006-12085) re-implements the slow path's vertex-attribute root update, base-parameter upload and draw-ID upload line for line (compare 11328-11372 and 11420-11445). I could not find a dirty bit it misses, but the two copies will drift. Please factor them into one helper that both paths call.
  • The stream validator change (asahi_g17p_stream_validator.c:1338-1346) accepts any post-initial VDM_STATE_UPDATE that is not followed by a 0x00000500 word. It can no longer flag a tail that was needed but left out, and it does not check when elision is legal. The FS update branch (1296-1306) only checks memory ownership. So the shim CI pass says little about the latch itself.
  • test-hk-root-size.c: the new cases run the stage-agnostic classifier on VS/FS NIR, which repeats the compute cases. A test of the offsetof(push) floor, of hk_gfx_root_descriptor_size(), and of the path that forces a re-upload when the root grows would cover the new logic.
  • Partial renders. Before this change every changed draw re-sent all nine PPP records. Now a run of push-constant draws relies on one full tail plus FS-only updates. Can you confirm that PPP state survives a TVB-overflow partial render, and show a row that forces overflows (high primitive count with many push-constant draws)?
  • hk_cmd_draw.c:9232 allocates the FS record with 32-byte alignment, while the tail's state block uses 64. Is 32 the actual requirement?
  • hk_cmd_draw.c:9296: the incremental branch relies on hk_upload_usc_words() returning a new address when only the push-descriptor set base moves (prepared_matches checks fragment_dma_set_base, this branch does not). A short comment there would help.

Test rows needed at bafac29, beyond the Neo subsets already posted:

  • M4 (G16G) and M3 (G15G): dEQP-VK.dynamic_state., dEQP-VK.pipeline.push_constant (monolithic, pipeline_library, fast_linked, shader_object), dEQP-VK.renderpass., dEQP-VK.renderpass2., dEQP-VK.dynamic_rendering. (suspend/resume), dEQP-VK.api.command_buffers.secondary, dEQP-VK.draw., dEQP-VK.multiview., dEQP-VK.shader_object.*.
  • G17P: the same groups run in full rather than "first 300", ideally on a second G17P (M4 Pro) as well as Neo.
  • Perf: one game or a trace replay, base vs head with matching output, since the claim rests on microbenchmarks.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Author

Exact-head M4 hardware verification (dcp74c) for bafac29a11b5 vs exact aurora-wip base c0b51ef24554 — PASS / READY TO MERGE:

  • Platform: Apple M4 Mac mini (J773g / T8132, Apple M4 G16G B0), kernel 7.3.0-ARCH-m4prod13, libvulkan_asahi.so SHA-256 ceba601a7097598f234db2bfabcee4a73d369a3904a33882f1c7b0d41c41b6f0 (base c8e096cfe2c48f03cb8b3c31c02135309d5532809d128d60fa2e7be71ba3cd7f).
  • Vulkan CTS & health: 1,612 Pass / 264 NotSupported / 0 Fail
    • vk-mustpass-short: 87/87 Pass
    • indexed_draw + dynamic_state + multi_draw + uniform_buffer_dynamic: 1,464/0 Pass
    • push_constant: 61/0 Pass
    • 0 GPU faults, recoveries, hangs, or kernel dmesg GPU errors.
  • Strict 4-round ABBA gpubench (10/10 bit-exact CRCs):
Test Params D Base wall (µs) #706 wall (µs) Wall Speedup Base GPU (µs) #706 GPU (µs) GPU Speedup rec_cpu (µs) CRC
render.bindless_ubo draws=2048,mode=ubo_vec4 1 1865.67 1079.92 1.728× (+72.8%) 303.25 190.00 1.596× (+59.6%) 1220.62 → 536.72 EXACT(57e7bedd)
render.bindless_ubo draws=2048,mode=ubo_vec4 2 831.95 413.59 2.012× (+101.2%) 307.42 193.15 1.592× (+59.2%) 803.70 → 342.40 EXACT(57e7bedd)
render.bindless_ubo draws=512,mode=ubo_vec4 1 847.61 611.28 1.387× (+38.7%) 132.85 113.44 1.171× (+17.1%) 346.19 → 146.93 EXACT(1af53d5c)
render.bindless_ubo draws=512,mode=ubo_vec4 2 335.81 309.60 1.085× (+8.5%) 135.42 109.69 1.235× (+23.5%) 226.41 → 150.63 EXACT(1af53d5c)
render.mdi bindless=1024,draws=10000 1 2659.57 1718.23 1.548× (+54.8%) 918.38 293.92 3.125× (+212.5%) 1119.71 → 985.82 EXACT(10db59ce)
render.mdi bindless=1024,draws=10000 4 1012.21 644.33 1.571× (+57.1%) 1000.97 302.75 3.306× (+230.6%) 738.80 → 619.25 EXACT(10db59ce)
render.mdi bindless=1024,draws=4096 1 1329.82 1026.80 1.295× (+29.5%) 398.48 141.10 2.824× (+182.4%) 456.86 → 420.94 EXACT(06f8412a)
render.mdi bindless=1024,draws=4096 4 411.87 292.23 1.409× (+40.9%) 408.65 139.38 2.932× (+193.2%) 275.31 → 262.43 EXACT(06f8412a)
render.mdi bindless=256,draws=1024 1 612.04 541.13 1.131× (+13.1%) 127.48 65.21 1.955× (+95.5%) 115.72 → 103.44 EXACT(f69c5f55)
render.mdi bindless=256,draws=1024 4 259.20 229.46 1.130× (+13.0%) 122.23 58.98 2.072× (+107.2%) 132.06 → 114.75 EXACT(f69c5f55)
  • Geomeans:
    • render.bindless_ubo (ubo_vec4): 1.512× (+51.2%) wall / 1.384× (+38.4%) GPU (peak 2.012× (+101.2%) wall at draws=2048 d=2, 831.95 → 413.59 µs, beating native M4 macOS 27.2 Metal)
    • render.mdi: 1.335× (+33.5%) wall / 2.650× (+165.0%) GPU (peak 3.306× GPU at draws=10000 d=4, 1000.97 → 302.75 µs)
    • Overall (10 rows): 1.403× (+40.3%) wall / 2.044× (+104.4%) GPU, 0 CRC mismatches.

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Thanks, that's a solid M4 row at the exact head: 0 fails over 1,612 cases, bit-exact CRCs, and a real ABBA win on bindless UBO and MDI. It covers G16G.

The head is still bafac29, though, so the code points from my last comment are open:

  • The latch, tail elision, FS PPP update and fast flush are selected by agx_chip_native_agx3() (hk_cmd_buffer.c:4681, hk_cmd_draw.c:9269/11938/13016), and that includes M3 (G15), which is not HAL200. Please either key them on the HAL200 stream property or post an M3 (J615) row at this head with the same CTS groups.
  • Root trimming is still chip == AGX_CHIP_G17P (hk_shader.c:5382/5384, hk_cmd_upload.c:30, hk_cmd_draw.c:11621/11987), and nothing in the root layout is G17P-specific. If it's safe there, it should apply to every chip with that layout. If not, the comment should say what differs.
  • The stream validator change (asahi_g17p_stream_validator.c:1338-1346) accepts any tail-less state update, and the new unit tests don't exercise the latch or elision. Please add a test that changes a non-FS PPP record between two draws in one stream and checks the full tail is re-emitted.
  • Still missing from the requested rows: renderpass/dynamic_rendering, api.command_buffers secondary, multiview and shader_object. They're the cases most likely to break a per-stream latch.

Assisted-by: LLM (Claude:Opus 5.5)

…hics root trimming

On native HAL200 (G16G / G17P) command streams, every draw that changes
push constants, dynamic buffers, vertex buffers, draw parameters, or draw
ID previously rebuilt and re-emitted the full 68-byte bind tail + 4-byte
draw-state selector (allocating a 188-byte state block, relocating 8
offsets, comparing scissor/depth-bias tails, and making the GPU re-fetch
all 9 PPP records), ran the full dynamic-state flush, and uploaded the
full 1520-byte root descriptor table.

Add a shared agx_chip_native_hal200() capability predicate covering
AGX_CS_GENERATION_HAL200 on the native AGX3 path (G16G and G17P) while
keeping unverified G15 (M3, AGX_CS_GENERATION_G15) streams on the existing
full-tail / full-root path, and apply three complementary optimizations
uniformly across HAL200:

1. Latch the last published HAL200 bind tail per VDM stream (struct hk_cs).
   When subsequent ordinary draws in the same stream keep every non-FS PPP
   record unchanged, elide the tail completely (0 bytes) when the fragment
   program is unchanged (e.g. draw-ID / base-param / VBO-only changes) or
   emit a single 8-byte VDM PPP State Update pointing to a 64-byte-aligned
   28-byte HAL200 fragment record when only the fragment program moved.
   Invalidate the latch on stream links, viewport flushes, robust-index
   slots, and full graphics-state invalidation.
2. Add a guarded fast path in hk_flush_dynamic_state() for HAL200 streams
   when only root descriptors, vertex buffers, draw parameters, or draw IDs
   changed, sharing vertex-attribute root update and draw-param / draw-ID
   upload helpers with hk_flush_dynamic_state_slow().
3. Apply root-descriptor trimming uniformly on agx_chip_native_hal200()
   (G16G and G17P), extending hk_nir_root_size() measurement to hardware
   vertex and fragment stages (floored at offsetof(push) to preserve all
   driver prolog/epilog loads) and forcing a re-upload if a later shader
   needs a larger root than currently uploaded.

Tighten the G17P drm-shim stream validator to track bind-tail latch state
(reset on stream links and non-FS PPP updates), reject tail elision when
non-pipeline VDM state changes or no bind tail is latched, and require
64-byte alignment plus unchanged non-program slot-1 fields on standalone
28-byte FS PPP updates. Add hk-g17p-bind-tail-state-change to verify under
drm-shim validation that push-constant-only draws take the incremental 28B
FS PPP path while non-FS PPP state changes (scissor, viewport, cull mode,
depth compare op, and blend state) always re-emit the full bind tail.
Extend test-hk-root-size and hk_cpu_upload_bench to cover the
offsetof(push) floor, hk_gfx_root_descriptor_size(), root growth
detection, and G16G/G17P vs non-HAL200 gating.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the perf/borealis-hal200-fast-draw-flush branch from bafac29 to 6eaea73 Compare November 22, 2026 12:59
@DjDeveloperr DjDeveloperr changed the title borealis: incremental HAL200 FS PPP update, fast draw flush, and G17P graphics root trimming borealis: incremental HAL200 FS PPP update, fast draw flush, and graphics root trimming Nov 22, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Thanks for the thorough reviews in #issuecomment-7078567861 and #issuecomment-7079027716! R2 is pushed at 6eaea736177f05d7c055aff7046586e99c65c2b3 addressing every code, validator, unit-test, partial-render, and full-group CTS point:

  1. Unified verified HAL200 capability predicate (excludes unverified G15*, unifies G16G+G17P):
    • Added agx_chip_native_hal200() in src/asahi/lib/agx_chip.h (AGX_CHIP_G16G + AGX_CHIP_G17P, excluding unverified G15G/S/C M3).
    • Replaced all agx_chip_native_agx3() uses for bind-tail elision / 28B FS PPP update / fast draw flush and all dev->dev.chip == AGX_CHIP_G17P uses for graphics+compute root trimming with agx_chip_native_hal200() (hk_cmd_buffer.c/.h, hk_cmd_draw.c, hk_cmd_upload.c, hk_shader.c), so G16G and G17P now execute the exact same codepath (fast flush + incremental PPP + trimmed root).
  2. Factored shared slow/fast draw-flush helpers:
    • Extracted hk_flush_vertex_attribs_root() and hk_flush_draw_params_and_id() in src/asahi/vulkan/hk_cmd_draw.c and called them from both hk_flush_dynamic_state_slow() and hk_g17p_flush_dynamic_state_fast().
  3. Tightened G17P stream validator + non-FS state-change bind-tail unit test:
    • Tightened src/asahi/drm-shim/asahi_g17p_stream_validator.c/.h to track bind_tail_latched, have_latched_vs, latched_vs, latched_fs_slot, elided_bind_tails, and incremental_fs_ppp_updates: resets latch on STREAM_LINK and non-FS PPP updates; rejects bind-tail elision when unlatched or when non-pipeline VDM state changed; validates standalone 28B FS PPP updates for latch state, 64B alignment, slot 1 layout, and preservation of all non-program slot-1 fields.
    • Added hk-g17p-bind-tail-state-change (src/asahi/vulkan/tests/g17p_vulkan_bind_tail_state_change.c + ASAHI_SHIM_G17P_EXPECT_BIND_TAIL_COUNTS in asahi_noop.c), exercising 8 draws in one render pass across push-constant-only updates and non-FS PPP state changes (vkCmdSetScissor, vkCmdSetViewport, vkCmdSetCullMode, vkCmdSetDepthCompareOp, blend-enabled pipeline) and asserting exact full=6, elided=2, fs_ppp=2 under ASAHI_SHIM_VALIDATE_G17P_STREAM=1.
    • -Dtools=drm-shim suite passes 3/3 on fedora (hk-g17p-bind-tail-state-change, hk-g17p-compressed-layer-copy, hk-g17p-tess-batch-stream), and FEDORA-CI 6eaea736177f passes 156/0.
  4. Expanded test-hk-root-size:
    • Added shared helpers in src/asahi/vulkan/hk_nir_root_size.h and expanded test-hk-root-size.c to cover the offsetof(push) floor, hk_gfx_root_descriptor_size(), root-growth re-upload trigger, missing-footprint full-root fallback, and agx_chip_native_hal200() chip gating.
  5. 64B alignment & push-descriptor comment:
    • Switched standalone 28B FS PPP allocation (hk_cmd_draw.c) from 32B to 64B alignment to match the tail state block, and added the comment explaining how hk_upload_usc_words() detects push-descriptor set base movement via its returned USC address.
  6. TVB-overflow partial-render stress proof on MacBook Neo (G17P B1):
    • Tested 512×64 (32,768 tris), 1024×128 (131,072 tris, HK_FRAME_ANATOMY confirming 1,022 incremental FS PPP updates in 1 render pass), and 2048×256 (524,288 overlapping screen-covering tris = ~536.9M tile-tri refs on 1024×1024 forcing partial renders) with non-trivial scissor + alpha blending: bit-exact base == head CRCs (0xbcb9de68, 0xd9ee7eaa, 0xbc0a3015), exact clear scissor border (0xff402010) and blended interior (0x20e5f0dd), kfault_delta=0.
  7. Full-group Vulkan CTS on MacBook Neo (G17P B1) — ZERO caps:
    • 163,089 Pass / 0 Fail across 356,950 full-group mustpass cases (kfault_delta=0, avc_delta=0, pmu=30 00):
      • dEQP-VK.dynamic_state.*: 531 Pass / 0 Fail (140 NS)
      • dEQP-VK.pipeline.*push_constant*: 409 Pass / 0 Fail (28 NS)
      • dEQP-VK.api.command_buffers.*secondary*: 17 Pass / 0 Fail (2 NS)
      • dEQP-VK.multiview.*: 835 Pass / 0 Fail (3 NS)
      • dEQP-VK.draw.* (renderpass + dynamic_rendering): 27,066 Pass / 0 Fail (2,409 NS)
      • dEQP-VK.renderpasses.{renderpass1,renderpass2,dynamic_rendering}.*: 47,959 Pass / 0 Fail (33,728 NS)
      • mustpass/main/vk-default/shader-object/*.txt (all 10 groups incl. 240,687-case rendering.txt): 86,272 Pass / 0 Fail (157,551 NS)
    • Plus 4-round Neo ABBA re-verified (render.mdi 1.451× wall / 1.645× GPU, render.bindless_ubo 1.286× wall / 1.305× GPU, all bit-exact CRCs) and multi-pass scene CRC parity (render.postfx 1440p msaa=1 & 1080p msaa=4, render.deferred dram, render.shadow d32f 2048×2048 — all bit-exact).
    • (Compiled driver code in src/asahi/lib/ and src/asahi/vulkan/hk_*.c/.h has zero diff between Neo-tested 733b49ff and pushed 6eaea736177f; the sole delta is the new hk-g17p-bind-tail-state-change drm-shim test verified on fedora.)
    • An exact-head M4 (G16G) R2 verification row is incoming from the M4 Mac mini lane at 6eaea736177f.

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Thanks, this addresses everything from my earlier comments:

  • The latch, tail elision, FS PPP update and fast flush now use agx_chip_native_hal200() (agx_chip.h:770). On G15 the latch is never published (hk_cmd_draw.c:9204) and allow_incremental is false (11132), so M3 stays on the full-tail path.
  • Root trimming uses the same predicate everywhere, and the commit message says why G15 is left out. I went through the root readers: push constants, dynamic buffers and their start table, sets/descriptor buffers, sample-position control, the post-push fields (printf, sampler heap, sparse, clip_z_coeff), draw params/ID (separate ranges), and a switch to a shader that reads more (hk_cmd_draw.c:11643 forces a re-upload, 12010 refuses the fast path). I found no case that uploads too little.
  • The validator now requires a latched tail and matching vertex-state words before it accepts an elided tail, and it pins every non-program slot-1 field on a standalone FS update. The new hk-g17p-bind-tail-state-change shim test covers scissor, viewport, cull, depth-compare and blend changes, with exact counts.
  • The shared helpers remove the slow/fast copies, and I see no behaviour difference.

One row is still missing. On G16G, graphics and compute root trimming are new at this head (the earlier M4 row ran with full roots). Please post the M4 row at 6eaea73 when it's ready. The Neo full-group rows were run at 733b49ff, which isn't on the remote. If that tree really is identical in the driver, pushing it (or re-running a short subset at 6eaea73) would let us check.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Author

Exact-head MacBook Neo (G17P B1) verification row at remote head 6eaea736177f05d7c055aff7046586e99c65c2b3 (6eaea736177+0, libvulkan_asahi.so SHA-256 97bf9ed3e83bda57ee10189cf41de07c14efdbc8889288eb050ec8e3fb262936, vs aurora-wip base c0b51ef2455), MESA_SHADER_CACHE_DISABLE=true, sleep_guard=active, pmu=30 00, kfault_delta=0, avc_delta=0:

4-Round Interleaved ABBA (c0b51ef2455 vs exact 6eaea736177f)

Benchmark Depth Base wall (us) Head wall (us) Wall Speedup Base GPU (us) Head GPU (us) GPU Speedup CRC
render.mdi (draws=2048, bindless=1024) 1 717.4 492.6 1.456× 432.2 267.8 1.614× b9cce2ef EXACT
render.mdi (draws=2048, bindless=1024) 2 323.0 243.2 1.328× 427.2 256.7 1.664× b9cce2ef EXACT
render.bindless_ubo (draws=2048, ubo_vec4) 1 1041.7 851.8 1.223× 544.9 421.2 1.294× 57e7bedd EXACT
render.bindless_ubo (draws=2048, ubo_vec4) 2 570.3 451.2 1.264× 537.9 413.2 1.302× 57e7bedd EXACT

Full-Group Vulkan CTS at exact 6eaea736177f (1,792 Pass / 0 Fail / 173 NotSupported)

  • dEQP-VK.dynamic_state.* (671): 531 Pass / 0 Fail / 140 NotSupported
  • dEQP-VK.pipeline.*push_constant* (437): 409 Pass / 0 Fail / 28 NotSupported
  • dEQP-VK.api.command_buffers.*secondary* (19): 17 Pass / 0 Fail / 2 NotSupported
  • dEQP-VK.multiview.* (838): 835 Pass / 0 Fail / 3 NotSupported

(Exact-head M4 G16G row at 6eaea736177f is queued on the M4 Mac mini lane.)

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

@DjDeveloperr

Copy link
Copy Markdown
Author

Exact-head M4 (Apple M4 (G16G B0), J773g, Linux 7.3.0-ARCH-m4prod14) R2 hardware verification at 6eaea736177f05d7c055aff7046586e99c65c2b3 (6eaea736177f) vs base c0b51ef24554 (dcp75b-pr706r2), covering R2's newly unified G16G graphics + compute root trimming:

  • Verdict: PASS (+609,794 job cmds / +443,490 jobs, 0 GPU faults, 0 recoveries, 0 hang kills, 0 dmesg GPU errors).
  • Vulkan CTS (--jobs 8): 2,049 / 2,049 PASS (0 Fail / 0 Crash / 0 Timeout):
    • vk-mustpass-short: 87 / 87
    • Targeted graphics + compute (pr706r2_targeted, incl. 542 new R2 compute pipeline / shader_object / indirect dispatch / binding_model cases): 1,962 / 1,962 PASS (303 NotSupported)
  • 4-round ABBA gpubench (<55°C, 13 active rows, 100% EXACT CRCs across all 10 CRC-checked rows == base == macOS 27.2 Metal, crc_mismatches=0):
    • 13-row geomean: 1.2984× (+29.84%) wall / 1.7037× (+70.37%) gpu_us
    • compute.cull_mdi (16384, vis=25): 1.6634× wall / 2.8006× GPU (d=1: 4587.54 → 2392.40 µs = 1.918× wall, 1274.53 → 452.65 µs = 2.816× GPU; d=2: 1326.27 → 919.13 µs = 1.443× wall, 1267.84 → 455.15 µs = 2.786× GPU)
    • render.bindless_ubo (ubo_vec4): 1.5217× wall / 1.3860× GPU (2048 d=2: 900.90 → 470.85 µs = 1.913× wall, rec_cpu 872.7 → 281.5 µs; 2048 d=1: 1785.71 → 1070.67 µs = 1.668× wall)
    • render.mdi: 1.1868× wall / 2.4357× GPU (4096 d=4: 412.20 → 344.83 µs = 1.195× wall, 406.06 → 139.12 µs = 2.919× GPU; 4096 d=1: 1607.73 → 1157.46 µs = 1.389× wall, 2.880× GPU)
    • compute.light (d=1, 4, 8): 1.0043× wall / 1.0000× GPU
Benchmark Params D Base wall (µs) Head wall (µs) Wall Base GPU (µs) Head GPU (µs) GPU rec_cpu (µs) CRC
compute.cull_mdi objs=16384,visible=25 1 4587.54 2392.40 1.918× 1274.53 452.65 2.816× 2967.6 → 1606.9 57276de2 EXACT
compute.cull_mdi objs=16384,visible=25 2 1326.27 919.13 1.443× 1267.84 455.15 2.786× 904.3 → 894.1 57276de2 EXACT
compute.light — 1 202.24 201.76 1.002× 1.54 1.54 1.000× 2.75 → 2.77 N/A
compute.light — 4 91.22 90.61 1.007× 1.54 1.54 1.000× 2.67 → 2.63 N/A
compute.light — 8 77.26 76.97 1.004× 1.54 1.54 1.000× 2.65 → 2.58 N/A
render.bindless_ubo draws=2048,mode=ubo_vec4 1 1785.71 1070.67 1.668× 303.04 188.03 1.612× 1179.9 → 586.4 57e7bedd EXACT
render.bindless_ubo draws=2048,mode=ubo_vec4 2 900.90 470.85 1.913× 307.52 194.06 1.585× 872.7 → 281.5 57e7bedd EXACT
render.bindless_ubo draws=512,mode=ubo_vec4 1 880.82 588.58 1.497× 132.54 111.90 1.185× 441.4 → 174.3 1af53d5c EXACT
render.bindless_ubo draws=512,mode=ubo_vec4 2 353.11 314.47 1.123× 135.19 110.81 1.220× 224.7 → 123.4 1af53d5c EXACT
render.mdi bindless=1024,draws=4096 1 1607.73 1157.46 1.389× 399.89 138.85 2.880× 841.0 → 649.7 06f8412a EXACT
render.mdi bindless=1024,draws=4096 4 412.20 344.83 1.195× 406.06 139.12 2.919× 259.9 → 323.8 06f8412a EXACT
render.mdi bindless=256,draws=1024 1 636.97 566.25 1.125× 125.65 64.02 1.963× 212.8 → 191.1 f69c5f55 EXACT
render.mdi bindless=256,draws=1024 4 254.98 240.06 1.062× 125.46 58.80 2.134× 97.5 → 97.6 f69c5f55 EXACT

(Note: render.bindless_ubo mode=desc_buf was skip on both #706-base and #706 R2 because VK_EXT_descriptor_buffer is not enabled on standalone aurora-wip.)

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Thanks. That is the M4 (G16G) row at 6eaea73 against base: 2,049/2,049 CTS including the new compute, shader_object, indirect dispatch and binding_model cases, 0 faults or recoveries, and every checked CRC exact in the ABBA. It covers the first-time G16G root trimming. With the Neo row on the same head, this is approved from my side.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr
DjDeveloperr merged commit a2b3401 into aurora-wip Nov 22, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged into aurora-wip at a2b34010cf99 (verified tree e868db29698b).

All merge gates green on exact head 6eaea736177f:

  • Review approved by @RyanTheTide (#issuecomment-7080268969)
  • Mirror asahi CI green (45025787520), fedora-mesaci 156/156 pass, -Dtools=drm-shim 3/3 pass, agent-policy.sh pr clean
  • Exact-head hardware verification passed on Apple A18 Pro (G17P B1) and Apple M4 (G16G B0): 0 CTS failures, bit-exact CRCs, TVB-overflow partial-render verified, 0 GPU faults

Assisted-by: LLM (Google:Gemini 4 Neon)

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