Skip to content

asahi/apple9: Vulkan graphics on M4 with timestamps, MSAA, resolves, mipmaps, points and long render passes - #3

Open
audreyt wants to merge 1543 commits into
GravityLinux:mainfrom
audreyt:apple9-graphics-port-draft
Open

audreyt wants to merge 1543 commits into
GravityLinux:mainfrom
audreyt:apple9-graphics-port-draft

Conversation

@audreyt

@audreyt audreyt commented Oct 27, 2026 •

Copy link
Copy Markdown

Apple9/G16G native Vulkan bring-up used by Zink on an M4 J715 desktop.

The head is ad9f485bf72b607c65f46a8ac0e1e68c126bca6e. It contains the
tested upstream merge ad4404e0360145f6ca1d1aa03ad1e8b4820f7422, followed
by a one-line test-fixture correction that removes a sample-mask narrowing
warning. Production source is identical to the M4-tested merge.

Stacked on #2: its exact five commits through b479054 remain unchanged.
All previously published commits through aa05e78 are preserved.

Upstream integration

The merge takes upstream snapshot
f66f380c648551249df5ba8538983279ca800985 as its second parent.
There is no rebase or history rewrite.

The implementation now uses the current native renderer, shared launch
and geometry interfaces, native descriptor ABI and tile layout. Superseded
private backends are removed; their meaningful compiler, descriptor, MSAA
and index cases run against the current owners.

The integration retains software FP64, narrow-integer arithmetic,
DrawID/restart behavior, mip and attachmentless rendering, and the shared
meta-clear fix for uncleared color attachments. It also fixes:

  • Split-address NIR loads incorrectly promoting declared alignment from the
    offset alone.
  • Indexed-draw count/offset overflow and range underflow, including G13's
    zero-page decision and copy-source calculation.
  • Late fragment memory side effects with depth test NEVER. A synthetic
    depth export now makes the substituted hardware test fail even without
    an explicit FragDepth output or depth/stencil feedback loop.
  • Native stencil-output ordering and the SM5 bitfield operations needed
    by software FP64 helpers.

The alignment, index and NEVER changes have failing-before/passing-after
tests at their production owners. The initial independent review found
the latter two gaps; they are fixed and covered by the tests below.

Validation

Builds ran on aarch64 DGX. A coherent seven-library runtime from ad4404e
was pinned by SHA-256 and tested in a private M4 prefix.

Check Result
Complete ASAHI Meson suite 114/114 pass
Complete NIR suite 6225/6225 pass; 10 pre-existing disabled tests
Zink formats, primitive restart and Gallium auxiliary CPU targets All pass
Final test-fixture-only change 34/34 Vulkan CPU tests pass, no compiler warning
DrawID/client and VBO restart/multidraw Four pixel/ID paths pass
Native MSAA color/stencil and GPU timestamps Pass
Clear preservation 22 cases pass in both threading modes
Packed UFLOAT clear/draw/DST_ALPHA 18 exact-bit cases pass
NEVER color, depth, stencil and SSBO behavior 24 cases pass at 1x/2x/4x
i16/u16 compute/fragment arithmetic CTS 1100 Pass
Semantic diagnostic All 14 Pass, including the two former D16 failures
D32 transfers Seven Pass
Attachmentless allocation Two Pass
RGBA8 render-to-mip One Pass
Geometry, tessellation/point size, polygon point mode, precise occlusion and pipeline statistics Eight CTS Pass
Sample shading and alpha-to-one Four CTS Pass
BC1/BC3/BC7, ETC2 and ASTC sampling Six CTS Pass
RGBA32 float/uint/sint clear/draw/resolve at 2x/4x 12 exact-pixel cases pass

All reported CTS results are Pass, not NotSupported. The strengthened
NEVER probe clears depth to .75 while the fragment's interpolated depth is
.5: an accidental LESS would pass and is detected by both depth and stencil
checks, rather than being hidden by preserved color.

The unchanged capability probe from aa05e78 expects the former backend's
feature exclusions and therefore reports 26 differences. The current
upstream backend advertises those features, compressed formats and wide
MSAA; the additional CTS and pixel tests above verify their delivery.
That old probe is retained and is not represented as a passing test.

Raw logs, QPAs, manifests, probe sources and the acceptance record are in:
/mnt/w/mesa-ffnative-01a179c0/run/pr3-upstream-20261116-w86/.

Earlier series and desktop acceptance

The original series shares launch/geometry helpers (30e2fa8), adds the
compute compiler support and snapshot (02adc29, fe2d172), then native
graphics (d0f5a14) and fragment side effects (d0396ba).
The Maps fixes through 4831e52 cover mip attachments, attachmentless
rendering, D32 transfers, pending clears, packed UFLOAT and depth-one 3D
sampling. The following nine commits through aa05e78 address the review
findings, DrawID, Z/S-only rendering, unsupported old-backend capability
advertisement and meta-clear color preservation.

The installed normal Firefox/Maps acceptance remains specifically for
aa05e78: original launcher and profile, native WebGL1, complete Globe and
terrain/traffic imagery, pointer pan/zoom, no context loss and 17 passing
manual QA rows. This refresh did not replace that installed runtime or
restart the compositor. It does not claim new normal-profile browser
acceptance for the private prefix.

Remaining scope

  • This is targeted J715 testing, not full Vulkan/OpenGL conformance.
  • G13 has CPU regression and kernel-build coverage, but no physical G13 run.
  • Successful render runs include non-fatal Zink
    vkGetPipelineCacheData (VK_INCOMPLETE) diagnostics from the unchanged
    upstream cache exporter; those diagnostics are not claimed fixed.
  • Fresh Signal soak, long browser sessions and XR30 compositor integration
    are not claimed. No compositor restart or reboot was performed.

Upstream cherry-pick f043b2c (Mike Blumenkrantz, mesa-stable) as
c09d7ab, authorship kept. zink_set_last_vertex_key only set
last_vertex_stage_dirty, which does not make the next draw update the
program; when the threaded context merged separate glDrawElements into
a multi-draw, a push_drawid flip left the DrawIndex-reading VS bound and
gl_DrawID read hk's incrementing draw index (tests/drawid single mode).

Evidence: mini PASS (tests/drawid single and multi); host lavapipe
single and multi pass.
hk: pass the draw's indices to the restart-aware IA counter
(c2a5be3), correcting ba4f4d2. For direct draws
agx_draw_index_range_el is relative to the first index, so the counter
needs agx_draw_index_buffer(draw) with first index 0 in the descriptor;
ba4f4d2 paired the binding base with that reduced range, so loads
past it read element 0 and the restart marker was counted.

Evidence: Air PASS (native vkstats, firstIndex 8: candidate
3/3, base 0/3) and mini PASS.
hk_occlusion_prepare_draw ends a control stream whose occlusion segment
slots are exhausted and starts a new one. It ran after
hk_apple9_prepare_draw had committed the draw's render state to the old
stream: the new stream lacked the depth bias representation (asserted
in hk_apple9_draw_impl; in release builds D16 and forced-UNORM bias
were then emitted as float bias), the sample positions, and the
write/pre-raster read classes. dEQP-GLES3.stress.occlusion_query.*
hit it on the host shim.

Do that split at the start of hk_apple9_prepare_draw, so the state lands
on the stream the draw records into; the later segment selection then
always has a free slot.

Generated-by: LLM
GL lets a vertex buffer be bound at or past the end of its buffer
(every fetch is then out of bounds); Vulkan requires
vkCmdBindVertexBuffers offsets to be less than the buffer size. Zink
passed the GL offset through, which hit vk_buffer_range's
offset <= size assertion on hk in
dEQP-GLES31.stress.vertex_attribute_binding.buffer_bounds.* (host
shim, assertion build).

Bind VK_NULL_HANDLE for such bindings, as for bindings without a
buffer; Zink requires nullDescriptor, so their fetches read zero.

Generated-by: LLM
hk: reuse Apple9 sysvals when dirty inputs are unchanged (6126f01).
Pipeline binds and state restoration dirtied blend constants and color
write enables without changing them, so the 3,712-byte graphics sysval
block was uploaded again. The block is a device-constant base plus
exactly the keyed inputs, so the two dirty-bit tests become exact value
comparisons (bitwise floats, the 32-bit enable mask); a hit consumes the
dirty bits where the rebuild always did, and failure keeps the old key.

Evidence (PASS_AVAILABLE_WORKLOADS): 12/12 probes at 1/2/4x MSAA, 2,304 pixels;
Factorio dynamic state 64 -> 32 B/draw, CPU -0.95% median (STK and
Luanti skipped: no traces). Host: strict identity 7,008 + 11 entries,
316/316 diagnostic captures identical.
asahi: retire BOs on a device reaper outside submit threads
(7a6cb02), avoid redundant reaper wakes and detach inherited devices
after fork (9ae458b), and reject inherited cache entries in a forked
child (0dc196d). Final BO releases cache or enqueue; a per-device
agx-bo-reaper thread does munmap, PRIME fd close, GEM_CLOSE and VA free
outside bo_map_lock and the cache lock, so GEM_CLOSE's whole-VM wait no
longer runs on GL, threaded-context or submit threads. Import can
resurrect a queued shared BO, a same-handle import waits only for that
close, VA is freed only after a successful close, and teardown joins
before freeing the handle map, heaps and fd. Wakes are signalled only on
empty-to-nonempty transitions. In a forked child (pthread_atfork, all
device locks held across fork) releases only discard: no GEM_CLOSE, VA
free, wait, join or cache reuse on the shared drm_file.

Conflict: src/asahi/lib/meson.build, where both this series and the
draw-tables merge added a test; both tests are kept.

Evidence: application-thread GEM_CLOSE 0 in every workload (asahi STK 1,057 -> 0,
Luanti 584 -> 0, Zink STK 331 -> 0), all on the reaper; 4/4 probes
pass. Host: 60/60 release and assertion suites; reaper unit including
a real fork with the worker blocked in a mocked GEM_CLOSE.
A GEM close while the VM has work queued only marks the old mappings
closing: the kernel removes them once the work queued at the close has
completed, since it cannot tell which of that work used the object. A
bind over a closing range waits for all of it. The heaps allocate
top-down, so the VA the reaper has just freed is the next one handed
out, and an ordinary allocation (a texture upload) then waits for the
whole backlog: 7-23 s per stall in the churn attribution test on the
mini (4 processes, 128 queued Works each).

Retired VAs now wait in a FIFO and return to their heap once a per-heap
byte cap (heap / 8, at most 8 GiB) is exceeded. An allocation that would
fail first returns the quarantine and retries once: for a fixed address
only the overlapping entries, otherwise the heap's. A forked child never
flushes. The capture-replay heaps keep a cap of 0. Explicit unbinds
(agx_va_free with unbind) are unchanged: the kernel already waited.

Generated-by: LLM
Retired VAs, the largest total quarantined, and releases by cap, by
allocation failure and by fixed-address conflict. AGX_VA_QUARANTINE_STATS
prints them at device teardown, so an A/B can show which path fired.

Generated-by: LLM
…-cap heaps

Review: the counters relied on a zero-allocated device. The replay heaps'
cap of 0 is no quarantine, so their retires are not counted as cap
releases.

Generated-by: LLM
Recompute push reads at the final Honeykrisp NIR handoff in assertion builds. Restore root identity from the Apple9 UBO lowering on an analysis clone, preserve loaded-pointer boundaries, and reject any read absent from the owning API shader mask.

Exercise lowered direct and indirect reads, dynamic offsets, descriptor pointers and unrelated address phis. The 7,008-shader corpus plus 11 state entries and internal/meta recording coverage report zero subset violations.
… size push descriptors

hk: limit Apple9 root uploads to live push-constant ranges (a90d395),
reuse identical attachment metadata across renders (64e07ab), size
push-descriptor uploads from their layout (266aa17), and assert
final Apple9 push readers fit the upload mask (ed7451f).

- Each API shader records which push-constant words it reads (constant
  push loads and root-relative global loads; anything unmodelled reads
  all). Roots reuse the last upload when the newly read words are a
  subset of the last upload's and equal, copy only read words, and end
  at the push region when no root constants or dynamic buffers exist.
  Container version 0x484b0005.
- Per-render attachment metadata is reused when per-RT dimensions and
  sample counts are equal; clear parameters use the content-compared
  upload-last slot.
- Push descriptor sets upload their layout extent instead of 8 KiB.
- Debug builds recompute the push-read mask on the final lowered NIR
  (root loads restored on a clone) and assert it is within the recorded
  mask: 0 hits over 7,008 corpus shaders plus internal and meta, 24,325
  checks.

Evidence (PASS on
available workloads): 12,288 VK + 2,304 GL pixel checks; Factorio CPU
-1.04%, descriptor tables 140 -> 73 B/draw, root 753 -> 497 B/draw.
Host: strict identity 7,008 + 11 unchanged, 316/316 captures identical.
… state

hk: split for occlusion segments before preparing Apple9 render state
(ff4b0da). A stream split for exhausted occlusion segments ran after
hk_apple9_prepare_draw had committed the depth-bias representation,
sample positions and read/write classes to the old stream; it now runs
first, with the same condition and END_QUERY hint.

Evidence: dEQP-GLES3.stress.occlusion_query cases crash (dbias_is_int assert) on
base, pass on candidate; regress 95 + 2 crashes -> 97/97; 0 regressions.
… end

zink: bind no vertex buffer for offsets at or past the buffer's end
(54e30c7). GL allows vertex binding offsets at or past the buffer
size; Vulkan requires them inside it. Such bindings now bind
VK_NULL_HANDLE (nullDescriptor: fetches read zero).

Evidence: dEQP-GLES31.stress.vertex_attribute_binding.buffer_bounds.* crash
(vk_buffer_range assert) on base, pass on candidate; 0 regressions.
…t once

asahi: quarantine VAs of closed BOs instead of recycling them at once
(bf68435), count VA quarantine releases by cause (aa4bdc7) and
the counter init/zero-cap fix (caef29d). The BO reaper returned a
closed BO's VA to its heap right after GEM_CLOSE; the heaps allocate
top-down, so it was the next VA handed out, and a VM_BIND over the
still-closing range waited for the whole VM's backlog (7-23 s churn
stalls). Retired VAs now wait in a FIFO with a per-heap byte cap
(min(size/8, 8 GiB); replay heaps 0), returning early only when an
allocation would fail: all of the heap, or for a fixed address only the
overlapping entries. Never in a forked child. Early release at worst
restores the old stall, never a stale mapping.
AGX_VA_QUARANTINE_STATS prints retired/high-water/release-cause counts
at teardown.

Evidence: same-boot A/B (post-hoc re-score;
rule pre-registered for future runs; v5's count rule FAILed 33 > 32 only
through extra OWN_BACKLOG submit-throttle waits): PASS. VM_BIND stalls
5 -> 0, total stalled time 102.8 -> 51.4 s, worst stall 23.8 -> 3.3 s,
iterations P1/P2/P4 741/872/1069 -> 741/873/1129; all v5 correctness
checks hold, 0 candidate hard/hung cells by structure and string.
hk: preserve shader memory effects across binary reloads (22247a1).
On a non-deferred binary cache hit, hk_deserialize_api_shader_inner
rebuilt writes_memory as "any non-fragment stage, or a backend fragment
writer", so a read-only vertex shader became an application memory
writer and its render lost tiling overlap with fragment work. Freshly
compiled shaders already take writes_memory from the API NIR (graphics
path and deferred path). The value is now serialized and restored as
is, matching the fresh model; container version 0x484b0006 (pipeline
and shader-binary UUIDs already reject old blobs by build hash).

Release and assert
Asahi suites 63/63; the new hk-variant-cache case (read-only VS stays
read-only and an FS with a real store stays a writer after reload) fails
on the old deserializer. Shader binaries/ASM identical over the full STK
(141 unique) and Luanti (69 unique) traces; 24 cold/warm Vulkan
command/upload cases exact. On the traces, fragment-only dependency
renders rise 3,443 -> 21,765 (STK) and 28,000 -> 46,995 (Luanti) with
render, draw and merge records unchanged. GPU timing is a separate test.
A suspended dynamic render must preserve its colour attachments for a later resumed instance even when its final storeOp discards them. Emit the partial colour end-of-tile program when the suspended render cannot stay open. Keep the original first-stream ZLS clear/load state: zls_last already preserves suspended stores, while partial ZLS would lose a stencil clear.

This applies independently of feedback compression. The focused dynamic-rendering suspend/resume list matches stock (20 pass, 72 skip), including ten stencil cases that caught the incorrect partial-ZLS version.
Rebase the reviewed recording-local feedback decompression model onto 201a583. Retain unsupported-format, depth, multisample and 3D bans; integer alias blits preserve storage bits. The independent suspended-render EOT fix is a separate parent commit. Review follow-ups and renewed validation follow in this topic branch.
Prepare feedback before classic and mesh draws, including hybrid native mesh. Reject later BeginRendering/draw/end work after a failed decompression instead of inspecting uninitialized rendering state. Assert that integer self-blit render tiles cover complete compression blocks and metadata fills cover integral uint4 records. Add a host recording test that injects a decompression allocation failure and exercises later classic/mesh draw and end entry points; extend format geometry checks across texel sizes.
Track calls, logical texel bytes, hits and misses per command recording, then accumulate them per actual submission in HK_CPU_TIMING. Differences of HK_FEEDBACK reports give counts per presented frame, including resubmitted command buffers. Label GPU_PASS groups for meta, decompression blits and feedback renders. No GPU program or command change is intended; all reporting remains opt-in.
Shader bodies no longer get a BO each. 3f7dcdf separates body ownership
from BO storage, 9d3cd81 packs immutable Apple9 bodies into shared,
reclaimable slabs, and 68145f3 reserves a mapped tail after each body
so instruction prefetch past the end of a body stays inside mapped memory.

Mini r2 PASS (35 + 14
ER processes, baseline ed7451f):
- body readback probes (4,352 bodies), Vulkan, native GL and Zink at
  1x/2x/4x MSAA pass in both arms; the edge probe ran a 576-byte body with a
  1 KiB mapped tail and 256 same-address replacements;
- ER screenshots byte-identical between arms;
- GEM: body probe -63 MiB, ER -17 MiB median, Luanti +33 MiB (+6.6%, one
  replay); STK and Luanti CPU timing within noise.
On G16 the kernel-private heap sits at the top of the 4-GiB compact render
context, and PPP/VDM records get what's left above the low 64 MiB of fixed
aliases. Mesa only rejected kernel heaps below 64 MiB, so a kernel advertising
nearly 4 GiB would have wrapped the context heap's size. Fail VM setup
cleanly unless at least 1 GiB remains for records. The TVB v3 kernel
(vm_kernel_min_size 1152 MiB) leaves 2,880 MiB.

AGX_VA_QUARANTINE_STATS now also prints the context heap's high water
(live plus quarantined VA) against its size, so record use can be measured
instead of estimated. Heap use is tracked for every heap under vma_lock.

Generated-by: LLM
…p use

bdeaeb9: VM setup fails cleanly on G16 unless the compact render
context keeps at least 1 GiB for PPP/VDM records after the kernel heap
(TVB v3 advertises 1152 MiB, leaving 2,880 MiB), and
AGX_VA_QUARANTINE_STATS reports the context heap's high water.

Host-only; merge-gate --no-codegen-change.
agx_set_framebuffer_state copied the new state into ctx->framebuffer and
then decompressed attachments whose view format is incompatible with
their compressed layout. On Apple9 the decompression copy runs through
u_blitter, which saves and restores the current framebuffer: restoring
re-entered agx_set_framebuffer_state with the still-compressed resource
and decompressed it again, recursively, allocating a new copy each
time. An RG16F view of a compressed R32F texture as a render target
charged ~2.1 GB to its 2 GiB cgroup on T8132 and was OOM-killed
(sparsert, view-sparse). Legalize the incoming
attachments first; a nested blit then restores the previous, already
legal framebuffer.

Host (G16 noop shim): view-sparse/view-dense now decompress once and
peak at 35 MB instead of exhausting memory.

Generated-by: LLM
@audreyt
audreyt force-pushed the apple9-graphics-port-draft branch from 36a9b3f to 4831e52 Compare November 5, 2026 08:29
@audreyt audreyt changed the title WIP: asahi/apple9: Vulkan graphics on M4 with timestamps, MSAA, resolves, mipmaps, points and long render passes asahi/apple9: Vulkan graphics on M4 with timestamps, MSAA, resolves, mipmaps, points and long render passes Nov 5, 2026
@audreyt
audreyt marked this pull request as ready for review November 5, 2026 08:33
Copilot AI balanced review requested due to automatic review settings November 5, 2026 08:33

Copilot AI 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.

🟡 Changes recommended

Zink restart splitting mishandles draw IDs and client-memory indices, while Asahi can fail configuration without glslang and advertises sample counts and features its native paths reject.

5 open issues
What changed in this PR

This PR brings native Apple9/M4 Vulkan graphics and compute support into Honeykrisp for Zink desktop workloads, alongside shared compiler, resource-management and rendering fixes. It builds on the common Zink fixes described in PR #2.

Changes:

  • Integrates native rendering, timestamps, multisampling, resolves, transfers and bounded diagnostics.
  • Adds shared launch helpers, software FP64 support and cooperative-matrix lowering.
  • Expands regression coverage for descriptors, shader compilation, tile layouts and memory allocation.
File Description
src/​vulkan/​runtime/​vk_meta_private.h Exposes the internal blit shader builder for tests.
src/​vulkan/​runtime/​vk_meta_blit_resolve.c Shares the production blit shader builder.
src/​gallium/​drivers/​zink/​zink_types.h Tracks failed graphics-pipeline lookup.
src/​gallium/​drivers/​zink/​zink_screen.c Adjusts Honeykrisp rendering workarounds.
src/​gallium/​drivers/​zink/​zink_program_state.hpp Corrects topology caching and failed-pipeline handling.
src/​gallium/​drivers/​zink/​zink_draw.cpp Handles pipeline failures, topology changes and restart splitting.
src/​gallium/​drivers/​zink/​zink_clear.c Corrects pending-clear overlap decisions.
src/​gallium/​drivers/​asahi/​test/​test-apple9-launch.cpp Tests allocation sizes and launch encodings.
src/​gallium/​drivers/​asahi/​test/​test-apple9-geometry.cpp Uses the shared geometry interface.
src/​gallium/​drivers/​asahi/​README.apple9-launchers.md Documents supported threadgroup allocations.
src/​gallium/​drivers/​asahi/​meson.build Builds tests with relocated shared helpers.
src/​gallium/​drivers/​asahi/​agx_pipe.c Uses writeback caching for scanout buffers.
src/​gallium/​drivers/​asahi/​agx_apple9.h Replaces local declarations with shared interfaces.
src/​compiler/​spirv/​vtn_cmat.c Validates native matrix memory-access restrictions.
src/​compiler/​spirv/​spirv_to_nir.c Initializes diagnostic options before header validation.
src/​compiler/​spirv/​nir_spirv.h Adds a matrix memory-access restriction option.
src/​compiler/​glsl/​float64.glsl Fixes rounding and adds software FMA/division.
src/​asahi/​vulkan/​test/​test-hk-apple9-spirv-scan.cpp Tests matrix imports and malformed modules.
src/​asahi/​vulkan/​test/​test-hk-apple9-msaa.cpp Tests multisampling, resolves and packed-float attachments.
src/​asahi/​vulkan/​meson.build Registers native modules, FP64 generation and tests.
src/​asahi/​vulkan/​hk_shader.h Adds native shader metadata and mapping interfaces.
src/​asahi/​vulkan/​hk_queue.c Submits native render jobs and attachment records.
src/​asahi/​vulkan/​hk_query_pool.c Restricts native query pools to timestamps.
src/​asahi/​vulkan/​hk_physical_device.c Adjusts native capabilities and device limits.
src/​asahi/​vulkan/​hk_nir_lower_descriptors.c Adds buffer-only descriptor lowering.
src/​asahi/​vulkan/​hk_meta_upload.h Defines raw transfer shaders and addressing helpers.
src/​asahi/​vulkan/​hk_image.c Adjusts storage features, compression and linear-image admission.
src/​asahi/​vulkan/​hk_device.h Stores the device-owned FP64 library cache.
src/​asahi/​vulkan/​hk_device.c Initializes native entries, experiments and FP64 state.
src/​asahi/​vulkan/​hk_device_memory.c Reuses synchronized read-only buffer mappings.
src/​asahi/​vulkan/​hk_cmd_draw.c Routes native rendering and draws.
src/​asahi/​vulkan/​hk_cmd_clear.c Adds image-clear diagnostics.
src/​asahi/​vulkan/​hk_cmd_buffer.h Adds native pools, render state and dispatch hooks.
src/​asahi/​vulkan/​hk_cmd_buffer.c Manages native command-buffer resources and initialization.
src/​asahi/​vulkan/​hk_buffer_view.c Filters native storage-texel format support.
src/​asahi/​vulkan/​hk_apple9.h Defines native descriptor mappings and resource interfaces.
src/​asahi/​vulkan/​hk_apple9_trace.h Declares categorized diagnostics.
src/​asahi/​vulkan/​hk_apple9_trace.c Implements bounded rendering diagnostics.
src/​asahi/​vulkan/​hk_apple9_softfp64.h Defines the FP64 cache and lowering interface.
src/​asahi/​vulkan/​hk_apple9_softfp64.c Imports and inlines software FP64 operations.
src/​asahi/​vulkan/​hk_apple9_root.h Declares native root-descriptor lowering.
src/​asahi/​vulkan/​hk_apple9_root.c Resolves root and descriptor-set addresses.
src/​asahi/​vulkan/​hk_apple9_msaa.h Declares tile and multisample helpers.
src/​asahi/​vulkan/​hk_apple9_msaa.c Builds native tile layouts and clear/reload/store shaders.
src/​asahi/​vulkan/​hk_apple9_graphics.h Defines native graphics state and encoding interfaces.
src/​asahi/​vulkan/​hk_apple9_coopmat.h Guards against residual cooperative-matrix operations.
src/​asahi/​lib/​tests/​test-tilebuffer.cpp Tests native single-color tile layouts.
src/​asahi/​lib/​meson.build Registers shared compute and geometry helpers.
src/​asahi/​lib/​agx_bo.h Tracks read-only shadow mappings per buffer object.
src/​asahi/​lib/​agx_bg_eot.c Adapts precompiled-kernel memory qualifiers.
src/​asahi/​lib/​agx_apple9_launch.h Updates shared launcher declarations and C linkage.
src/​asahi/​lib/​agx_apple9_launch.c Adds allocation experiments and larger launch encodings.
src/​asahi/​lib/​agx_apple9_geometry.c Uses the shared compute header.
src/​asahi/​lib/​agx_apple9_compute.h Centralizes compute launch and sampler interfaces.
src/​asahi/​layout/​tests/​test-layout.cpp Tests two-layer linear transfer footprints.
src/​asahi/​compiler/​test/​test-apple9-tg-experiment.cpp Tests experimental threadgroup allocation limits.
src/​asahi/​compiler/​test/​test-apple9-meta-upload.cpp Tests transfer addressing and native compilation.
src/​asahi/​compiler/​test/​test-apple9-fp64.cpp Tests integer helpers and raw-double rejection.
src/​asahi/​compiler/​test/​test-apple9-descriptors.cpp Tests root-based buffer access compilation.
src/​asahi/​compiler/​test/​test-apple9-coopmat-machine.cpp Tests matrix lowering through native compilation.
src/​asahi/​compiler/​meson.build Registers lowering code and compiler tests.
src/​asahi/​compiler/​agx_nir.h Declares cooperative-matrix lowering.
src/​asahi/​compiler/​agx_nir_lower_apple9_math.c Lowers interleave and reduced-angle sine operations.
src/​asahi/​compiler/​agx_nir_lower_apple9_cooperative_matrix.c Implements bounded subgroup matrix lowering.
src/​asahi/​compiler/​agx_compile.h Exposes native preprocessing and sample-lowering interfaces.
src/​asahi/​compiler/​agx_compile.c Separates native fragment-side-effect preprocessing.
src/​asahi/​compiler/​agx_compile_apple9.h Extends native formats, system values and robust vertex interfaces.
src/​asahi/​compiler/​agx_apple9_profile.h Defines allocation limits and experiment state.

Review effort: Balanced

Comment on lines +105 to +107
prog_python, '@INPUT@', '@OUTPUT@', prog_glslang,
'--vn', 'hk_float64_spv', '--glsl-version', '450', '-Olib',
glslang_depfile,
Comment on lines +535 to +537
for (unsigned i = 0; i < num_draws; i++)
util_draw_vbo_without_prim_restart(pctx, dinfo, drawid_offset + i,
NULL, &draws[i]);
Comment thread src/gallium/drivers/zink/zink_draw.cpp Outdated
Comment on lines +536 to +537
util_draw_vbo_without_prim_restart(pctx, dinfo, drawid_offset + i,
NULL, &draws[i]);
Comment thread src/asahi/vulkan/hk_apple9_msaa.c Outdated
Comment on lines +21 to +22
if (sample_size_B * samples * tile_size > 32767)
return false;
Comment thread src/asahi/vulkan/hk_physical_device.c Outdated
Comment on lines +660 to +661
features->vertexInputDynamicState = false;
features->extendedDynamicState = false;
audreyt and others added 22 commits November 5, 2026 09:40
The Honeykrisp FP64 target always invokes glslangValidator. Require the
tool for Asahi Vulkan so an Asahi-only configuration reports the missing
dependency before using its depfile settings.

Co-authored-by: sisyphus-dev-ai <[email protected]>
Filter image-format sample counts through the same tilebuffer admission
used when native rendering begins. RGBA32 2x and 4x targets exceed the
reserved 32-KiB tile budget and must not be advertised.

The public Vulkan query regression changes from three sample-count
failures to none, while RGBA8 and RGBA16 float retain 1x, 2x and 4x.

Co-authored-by: sisyphus-dev-ai <[email protected]>
Native graphics rejects geometry and tessellation stages, sample shading,
alpha-to-one, non-solid fill, and non-timestamp query pools. Clear the
corresponding feature bits and the dependent shader point-size feature.

The public Vulkan feature query regression changes from eight failures
to none on M4.

Co-authored-by: sisyphus-dev-ai <[email protected]>
Submit each restart-free range separately with its logical draw ID. This
keeps increment_draw_id from advancing between segments and lets drivers
upload every client index range. Honor the flag when advancing between
the original Zink draws.

Exercise the production Zink entry point and real upload manager with
user/resource indices, 16/32-bit widths, both ID modes, nonzero starts
and draw-ID offsets, and distinct base vertices. All eight new cases
fail before the fix and pass after it.

Co-authored-by: sisyphus-dev-ai <[email protected]>
Preserve the draw ID supplied by the Vulkan draw loop and publish it in
vertex sysval word 2. Lower load_draw_id through the same uniform path
as first/base vertex and first instance. The slot precedes sampler bias
data at byte 16.

Native multidraw now observes nonzero IDs instead of rejecting the
vertex shader. The existing base-parameter words retain their offsets.

Co-authored-by: sisyphus-dev-ai <[email protected]>
GL batch pools grow from 16 KiB to 256 KiB slabs instead of starting at
256 KiB, VDM encoders start at 16 KiB (CDM keeps 512 KiB), and a submit
reaps every completed batch rather than at most two. Plasma shell drops
from 43-128 MB to about 5 MB of GPU memory. Driver-side only; codegen
identity unchanged.
On Apple9 the texture transfer mode is DEFAULT, so glReadPixels and
texture maps of imported buffers read the BO directly from the CPU.
agx_prepare_for_map only synced this context's writers, so a reader in
another process could see a buffer another process was still rendering.
KRdp hit this: it downloads each KWin screencast dma-buf with
glReadPixels right after KWin's glFlush, and under GPU load from a game
it captured frames with an unfinished, tile-ragged band (popups missing,
the window below showing through).

Wait on the dma-buf's implicit fences for shared BOs: writers before a
CPU read, writers and readers before a CPU write.

Generated-by: LLM
…ae2d7b)

Fixes torn KRdp/screencast captures: CPU readback of a shared dma-buf now
waits for its implicit fences.
… memory

hk_defer_render_wait() lets a render's tiling start before earlier renders'
fragment work finishes when its pre-rasterization stages cannot observe that
work. The rule assumed vertex pipelines never store, but
vertexPipelineStoresAndAtomics is exposed on G16 (and to DXVK/vkd3d), and
the classifier only looks at loads. A vertex, task or mesh shader that
stores or runs atomics after a FRAGMENT_SHADER -> VERTEX_SHADER barrier
could then overwrite memory an earlier render's fragment shader had not yet
read (write-after-read) or written (write-after-write).

Mark draws whose bound pre-rasterization shaders write memory and never
elide their render's tiling wait. Transform feedback, tessellation and
geometry already keep it. HK_TILING_ELISION_STATS counts these renders as
"stores".

Generated-by: LLM
Render 1's fragment shader spins and then reads a buffer into its
attachment; after a FRAGMENT_SHADER -> VERTEX_SHADER barrier, render 2's
vertex shader stores to that buffer. Every pixel must see the old value.
Each round uses a fresh device, since the first render pair of a queue is
the one the tiling-wait elision could reorder.

On the M4 mini, 8 of 20 rounds failed before the tiling-wait fix and 0 of
20 after it, and 0 of 20 with the elision disabled.

Generated-by: LLM
asahi-agx2-fails.txt is upstream's expected-failure list for M1-class CI.
Restore its upstream content and move the M4 (G16) expectations to
asahi-m4-fails.txt, which the M4 runner now reads instead, so nothing
carried here changes M1 CI expectations.

Generated-by: LLM
Every process that enumerated Vulkan devices (vulkaninfo, Steam, every
game) printed "WARNING: experimental Apple9 Honeykrisp; not conformant" to
stderr. The conformance version in VkPhysicalDeviceDriverProperties
already reports that the implementation is not conformant.

Generated-by: LLM
DXVK and vkd3d run with border emulation disabled (driconf), so the first
sampler with a custom border colour printed six lines to stderr saying the
border would be wrong. On G16 the hardware applies a custom border with a
known format natively, so the warning is false there. Print it only when
the border really needed emulation.

Generated-by: LLM
HK_ABORT_BEFORE_SUBMIT and HK_NULL_SUBMIT were looked up in the environment
on every queue submit. Read each once, as the other hk debug options are.

Generated-by: LLM
-Dhk-gpu-busy-counters defaulted to true, so every build carried the
collector, although its documentation says the option defaults off. With
HK_GPU_BUSY_FILE unset every entry point already returns before touching
a command or allocating anything, so compiling the counters out does not
change what the driver records or submits. Default the option to false;
measurement builds keep enabling it with -Dhk-gpu-busy-counters=true.

Generated-by: LLM
Scalar exports complete in the publication namespace. A GPR instruction
which overwrites one of their borrowed inputs must not consume that
completion through its own GPR dependency field.

Check publication consumers before the generic ordering-only shortcut.
This emits a standalone wait before GPR reuse while keeping folded waits
for the matching varying, grid-export and coverage consumers.

Exercise the physical completion pass and packer with both scalar export
forms, ALU and load overwrites, and one through six pending publications.
Keep the physical allocation fixed and retain shared inputs between the
publishers so allocation cannot hide the missing handoff.

Generated-by: LLM
Mark the last vertex stage dirty when changing the draw-ID source.
The pipeline update gate consumes dirty_gfx_stages before the program
updater can propagate last_vertex_stage_dirty, so the key change must
make the stage visible to that gate.

Fixes logical draw ID 1 incorrectly using native DrawIndex 0 after
primitive restart splits. All four exact-ID GPU cases, MSAA, timestamps
and all seven CPU test targets pass.
Share native Z/S attachment validation and ZLS setup between colored and colorless rendering. Treat a null color slot as colorless while retaining real depth/stencil dimensions, samples, loads and stores. Ignore clear values for LOAD and DONT_CARE. The public GL regression changes six color-preservation failures and a teardown timeout to zero bad pixels and normal exit. All seven CPU targets and adjacent GPU regressions pass; normal-profile Maps acceptance remains separate.
Native buffer/image transfers reject block-compressed images in both
directions. Clear the compression feature bits and format features on
the native path so clients select supported texture representations.

Verified all seven CPU targets and 28 public Vulkan capability checks
on Apple M4.
Meta clear shaders only write attachments selected in the clear mask.
Disable color writes for the other bound attachments so undefined
fragment outputs cannot overwrite their existing contents. This also
preserves color during depth-only and stencil-only clears.

The public GL regression keeps all 16 earlier cases and adds six
depth-tested color-preservation cases. Those six fail without the fix;
all 22 pass with it under both default and unthreaded Zink. Seven CPU
targets also pass.
Adopt the current native renderer and retain the validated FP64, descriptor, MSAA, DrawID and meta-clear behavior at their shared owners. Preserve split-address alignment, wide robust index offsets, and late NEVER depth/stencil ordering. Retire superseded private backends and move their live coverage to the canonical interfaces.
@mgbilby

mgbilby commented Nov 25, 2026

Copy link
Copy Markdown

Known client-side visibility gap: Linux Vulkan clients that omit portability enumeration

The driver reports conformanceVersion = 0.0.0.0 (correctly, for a WIP bring-up). Per the loader contract, non-conformant physical devices are hidden from applications whose instance does not set VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_KHR. Verified on an M4 with the private-prefix build (/etc/vulkan/icd.d/asahi-wip.json pointing at /opt/mesa-vulkan-wip/lib64/libvulkan_asahi.so):

  • vulkaninfo --summary (requests the bit): enumerates Apple M4 (G16G B1), driverID = DRIVER_ID_MESA_HONEYKRISP, Mesa 26.3.0-devel, deviceType = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU.
  • wgpu 30.0.2 (Rust, Vulkan backend): reported no adapter originally. Two independent client-side gates are involved:
    1. wgpu-hal requested VK_KHR_portability_enumeration only under cfg!(target_os = "macos"), so Linux instances never set the loader bit;
    2. wgpu-hal's adapter exposure additionally hides drivers with conformance_version.major == 0 unless InstanceFlags::ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER is set (also env-settable via WGPU_ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER).

With both gates open (a local wgpu build carrying the one-line fix below, plus the flag), the G16G enumerates and a device opens at default limits:

wgpu Vulkan: backend Vulkan | device Apple M4 (G16G B1) | type IntegratedGpu
wgpu Vulkan: downlevel: Sm5 shader_model=["compute", "fwstorage", "indirect", ...]
wgpu Vulkan: COMPUTE available
wgpu Vulkan: device opened (default limits)

Recommended downstream edit (one line, no-op where the extension is absent; desired_extensions() retains only supported extensions). In wgpu-hal/src/vulkan/instance.rs, desired_extensions():

if cfg!(target_os = "macos") {
    // VK_EXT_metal_surface
    extensions.push(ext::metal_surface::NAME);
    extensions.push(khr::portability_enumeration::NAME);   // <-- remove this line from the block
}
extensions.push(khr::portability_enumeration::NAME);       // <-- add it unconditionally, here

Filed upstream for tracking: gfx-rs/wgpu#11121 (issue) and gfx-rs/wgpu#11122 (PR carrying the edit against trunk). No driver-side change is indicated: instance creation, device enumeration, downlevel capability reporting and compute availability all behave per spec once the client sets the portability bit and opts in.

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.

6 participants