Skip to content

borealis: take float image atomics, colour pruning and position order to G16G - #923

Merged
DjDeveloperr merged 3 commits into
aurora-wipfrom
djdev/borealis-m4-g16g-gate-parity
Nov 24, 2026
Merged

DjDeveloperr merged 3 commits into
aurora-wipfrom
djdev/borealis-m4-g16g-gate-parity

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 24, 2026 •

Copy link
Copy Markdown

What: Borealis on G16G (M4) now prunes unused fragment colours from depth-only pipelines and keeps vertex position arithmetic the same across pass variants, as G17P and M5 already do. The R32_SFLOAT image and texel-buffer atomic bits follow the advertised float-atomics feature (that hunk is already on aurora-wip).
Tested: M4 Mac mini (J773g, G16G B0) at f18253a63b8e: dEQP-VK.rasterization.culling.* 43/43, dEQP-VK.image.atomic_operations.* 705 pass and 0 fail, asahi unit tests 178/178, 0 failed units, 0 GPU faults. Fork CI asahi 254/254 at f18253a63b8e.
Risk: two-way · M4 (G16G) Borealis; G17P and M5 unchanged
Not yet: nothing for the two shader-pass changes. R32_SFLOAT image atomics on M4 come from aurora-wip itself, which already advertises float atomics; the row's older base did not, so those cases were NotSupported there.

Details (original description)

Summary

Three Borealis paths were enabled only on G17P and M5, although nothing in them depends on the G17P or M5 encoding or command stream. This enables them on G16G (M4).

Changes

  • borealis: offer R32_SFLOAT image atomics with float image atomics.
    • G16G advertises shaderImageFloat32Atomics, shaderImageFloat32AtomicAdd and shaderImageFloat32AtomicMinMax, but VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT on R32_SFLOAT was offered only on G17P and M5. Vulkan requires that bit wherever shaderImageFloat32Atomics is supported.
    • Both the image and the texel buffer bit now follow the advertised feature instead of a chip list. The texel buffer bit already covered every chip that advertises it, so it does not change.
  • borealis: prune unused fragment colours from depth-only G16G pipelines. hk_prune_unused_fragment_colors() is plain NIR. It now also runs on HAL200 native parts, so G16G depth-only and shadow pipelines stop computing colours that no attachment stores. G15 and AGX2 are still excluded, because the pass has not run on them.
  • borealis: preserve vertex position arithmetic across pass variants on G16G.
    • agx_nir_preserve_position_order() keeps the depth-only and colour links of the same vertex shader from rounding Position differently, which otherwise makes a LESS_OR_EQUAL depth pre-pass reject samples in the colour pass.
    • The difference comes from NIR optimisation of the two links, not from the hardware, so the pass now runs on G16G vertex shaders too.

The two shader-pass changes widen an existing chip condition rather than adding a new one.

Testing

  • CI on exact head f18253a63b8 (DjDeveloperr/mesa): asahi 254/254 pass (run 45377804983), aurora-agent-policy pass (run 45377804902).
  • Apple M4 (G16G B0), Borealis Vulkan: these changes were part of a GL/GLES/Vulkan conformance regression run of 10,771 tests with 0 regressions, 0 GPU faults and 0 recoveries.
  • git diff --check clean, and agent-policy.sh pr clean against aurora-wip.
  • The series applies to current aurora-wip without conflicts.

G16G advertises shaderImageFloat32Atomics, shaderImageFloat32AtomicAdd
and shaderImageFloat32AtomicMinMax through the shared HAL200 block of
hk_create_drm_physical_device(), but hk_get_image_plane_format_features()
offered VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT on R32_SFLOAT only
on G17P and M5. Vulkan requires that bit on R32_SFLOAT when
shaderImageFloat32Atomics is supported, and without it an application
cannot use the advertised feature on an optimal-tiled image.

Take the bit from the advertised feature instead of a chip list. The
storage texel buffer bit gets the same rule; it already covered every
chip that advertises the feature, so it does not change.

The image atomics go through the same code on every native AGX3 part:
nir_lower_image_atomics_to_global(), then agx_nir_lower_atomics(), which
keeps a native 32-bit global fadd on the AGX3B encoding and turns
fmin/fmax into compare-and-swap loops. G16G and G17P share that encoding.
G16G already exposes R32_SFLOAT texel buffer atomics and R32_UINT/SINT
image atomics through the same lowering.

Signed-off-by: Diljit Singh <hey@djdev.me>
hk_populate_fs_key() sets discard_color_outputs only on G17P and M5. With
the key set, hk_prune_unused_fragment_colors() removes a fragment
shader's colour stores before linking, when the complete pipeline state
proves there are no colour attachments and alpha-to-coverage is
statically off. Output reads, depth, sample masks, discard and memory
effects are kept.

The pass is plain NIR and uses no encoding or command-stream feature, so
nothing in it is specific to G17P or M5. Take it on G16G too. Its
depth-only and shadow passes then stop computing colours that no
attachment stores.

The gate now names the HAL200 native parts and M5 explicitly. It still
leaves out G15 and the AGX2 parts, which have not run it.

Signed-off-by: Diljit Singh <hey@djdev.me>
… G16G

agx_nir_preserve_position_order() keeps NIR from reassociating or
algebraically rewriting what vertex Position depends on. Without it, a
depth-only link and a colour link of the same vertex shader can round
the same position expression differently when an intermediate value also
feeds a live varying. A depth pre-pass with LESS_OR_EQUAL then rejects
samples of the colour pass. The pass runs only on G17P and M5.

The difference comes from NIR optimisation of the two links, not from
the hardware, so G16G links can differ in the same way. Run the pass on
G16G vertex shaders too. Multiply-add contraction and unrelated outputs
are still optimised.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Author

Live hardware verification on Apple M4 Mac mini (G16G B0, J773g), Linux 7.3.0-ARCH, Mesa 26.3.0-devel (git-05ae81b2ec) (aurora-wip@1c9fc72ce5f + #925, #902, #915, #916, #921–#924, #923 f18253a63b8e, #926):

  • Unit tests: meson test --suite asahi: 178/178 PASS.
  • Vulkan CTS (MESA_SHADER_CACHE_DISABLE=1):
    • dEQP-VK.rasterization.culling.*: 43/43 PASS (0 Fail)
    • dEQP-VK.image.atomic_operations.*: 705 PASS / 5,504 NotSupported / 0 Fail (r32i: 352 Pass, r32ui: 352 Pass, other: 1 Pass; note r32f 456/456 returned NotSupported on this aurora-wip build since shaderImageFloat32Atomics is not yet advertised on G16G here)
  • gpubench-vk (all crc_bad=0):
    • compute.conv2d 1080p gaussian d=1/4: 844.59 / 588.24 us, bilateral d=1/4: 1506.02 / 1231.53 us
  • Regression check: 0 failed systemd units, 0 new kernel errors in dmesg, 0 GPU faults/recoveries/hang kills.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict at f18253a63b8e

Approve.

Blockers

None.

Checked

  • Audited all 3 changed files (src/asahi/vulkan/hk_buffer_view.c, src/asahi/vulkan/hk_image.c, src/asahi/vulkan/hk_shader.c, +7/-6) against origin/aurora-wip (789cbde2d1f1).
  • Verified hk_physical_device.c ties vk.supported_features.shaderImageFloat32Atomics directly to EXT_shader_atomic_float, so gating R32_FLOAT storage texel-buffer and storage-image atomic format features on pdev->vk.supported_features.shaderImageFloat32Atomics keeps Vulkan format features in lockstep with the advertised device feature across every chip.
  • Verified agx_chip_native_hal200(chip) matches only G16G and G17P, extending colour-output pruning (hk_shader.c:712) and agx_nir_preserve_position_order (hk_shader.c:5493) from {G17P, M5} to {G16G, G17P, M5} with no behavioural change on M5 or AGX2.
  • Built in an isolated worktree and ran the non-layout asahi + drm-shim unit test suite: 236/236 passed (0 failed).
  • Verified live Borealis Vulkan execution on Apple M5 Max (G17C B1, Linux 7.3, MESA_SHADER_CACHE_DISABLE=1): 382 passed, 0 failed, 342 not supported across dEQP-VK.api.info.format_properties.r32_sfloat, dEQP-VK.glsl.atomic_operations.*float*, dEQP-VK.spirv_assembly.instruction.compute.float_controls.fp32.input_args.*, dEQP-VK.compute.pipeline.basic.*, and dEQP-VK.pipeline.monolithic.vertex_input.single_attribute.mat4.*, with 0 GPU faults in dmesg.
  • Untested scope: Live G16G (M4) hardware execution was not run (only Apple M5 Max hardware is available here; G16G changes were audited statically and verified via drm-shim tests). asahi_layout_tests was excluded due to a pre-existing GCC 16 designator-order build error in src/asahi/layout/tests/test-layout.cpp:374.
Evidence
  • Unit & drm-shim suite (non-layout asahi): 236/236 OK, 0 FAIL.
  • Live Borealis Vulkan CTS on Apple M5 Max (G17C B1, MESA_SHADER_CACHE_DISABLE=1, 0 GPU faults):
    • dEQP-VK.api.info.format_properties.r32_sfloat: 1/1 passed
    • dEQP-VK.glsl.atomic_operations.*float*: 52/240 passed, 0 failed, 188 not supported
    • dEQP-VK.spirv_assembly.instruction.compute.float_controls.fp32.input_args.*: 207/356 passed, 0 failed, 149 not supported
    • dEQP-VK.compute.pipeline.basic.*: 80/81 passed, 0 failed, 1 not supported
    • dEQP-VK.pipeline.monolithic.vertex_input.single_attribute.mat4.*: 42/46 passed, 0 failed, 4 not supported

@DjDeveloperr

Copy link
Copy Markdown
Author

Verdict at f18253a63b8e: MERGE. No blocking findings.

Blockers: none.

Checked: the diff against aurora-wip (3 files, +7/-6); the M4 (J773g, G16G B0) row at this head in the comment above (culling 43/43, image atomics 705 pass and 0 fail, unit tests 178/178, 0 GPU faults); fork CI at this head passes (asahi 254/254, policy); no Apple material; no new gates (the two shader passes widen existing chip conditions to G16G); no parameters; commits carry the author and Signed-off-by only, no AI attribution. An approving non-author review at this head is already here. I reformatted the PR body to What / Tested / Risk / Not yet, with the original kept folded.

Notes (not blocking)
  • The first commit's two hunks (hk_image.c, hk_buffer_view.c) are already on aurora-wip, identical, from another merge, so on merge it adds nothing. Its message says G16G advertises float image atomics; that was not true on this PR's base (the row saw the r32f cases as NotSupported) but is true on current aurora-wip.
  • Both NIR passes have no hardware dependency. A follow-up could run them on every chip instead of listing chips.

@DjDeveloperr
DjDeveloperr merged commit 729fd5f into aurora-wip Nov 24, 2026
@RyanTheTide
RyanTheTide deleted the djdev/borealis-m4-g16g-gate-parity branch November 27, 2026 13:20
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