Skip to content

borealis: extend sampled descriptor fast path to Gen 10 and add linear descriptor pool allocation - #1168

Merged
RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
oreater:pr/borealis-descriptor-fast-path-linear-pool
Nov 27, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
oreater:pr/borealis-descriptor-fast-path-linear-pool

Conversation

@oreater

@oreater oreater commented Nov 26, 2026 •

Copy link
Copy Markdown

What: Extend the single-plane sampled descriptor fast path to descriptor generation 10, add linear bump allocation and recycled set freelist for non-individual-free descriptor pools, and precompute has_compute_storage_backing/has_immutable_samplers layout flags.

Tested: J716c Apple M5 Max at a2f7f3566fd: 212/212 asahi unit tests PASS, vkAllocateDescriptorSets+Reset -79.98% (4.99x), vkUpdateDescriptorSets -41.18% (1.70x), 308/444 Vulkan CTS PASS across api.descriptor_{pool,set}.*, binding_model.{descriptor_update,descriptor_copy,descriptorset_random}.*, pipeline.monolithic.sampler.*, and texture.mipmap.2d.* (0 fail, 0 diffs), 0 kernel errors.

Risk: two-way door · all Macs (Gen 9 G15–G17P/G17A, Gen 10 G17G/S/C & G18G, and AGX2 for linear pools) — A plain revert restores util_vma_heap allocation and the 3-plane Gen 10 staging path. Linear allocation activates strictly when VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT is absent (with rollback on partial-allocation OOM), and the Gen 10 fast path writes identical bytes (write_g17p_sampler_bias()) to the general path.

Not yet: Upstream CI run at a2f7f3566fd, plus second-generation hardware rows on a Gen 9 machine (G17P or M3/M4), an AGX2 machine for linear pool allocation, and G18G if available. (Scope note: pools with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT stay on util_vma_heap.)

Details and verification evidence

Summary

Speeds up per-frame descriptor pool allocation/reset and sampled descriptor writes across Borealis with zero chip-model gating:

  1. Gen 10 single-plane sampled descriptor fast path (src/asahi/vulkan/hk_descriptor_set.c):

    • Extends write_sampled_image_view_desc_g17p_single() to descriptor generation 10 alongside generation 9, emitting the exact same write_g17p_sampler_bias() and null-texture bytes as the general three-plane staging path without zeroing a 3-plane staging buffer.
  2. Linear bump allocator and recycled descriptor-set freelist (src/asahi/vulkan/hk_descriptor_set.c, hk_descriptor_set.h):

    • Descriptor pools created without VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT allocate monotonically via pool->linear_offset (skipping util_vma_heap node allocation/freeing) and reset linear_offset = 0 on vkResetDescriptorPool(), rolling linear_offset back cleanly if a multi-set vkAllocateDescriptorSets() fails partway through.
    • Recycles zero-dynamic-descriptor hk_descriptor_set objects onto pool->free_sets on free/reset and frees them on pool destruction, avoiding per-frame host calloc/free churn.
  3. Precomputed layout flags (src/asahi/vulkan/hk_descriptor_set_layout.c, hk_descriptor_set_layout.h):

    • Precomputes has_compute_storage_backing (restricting set->storage_backings allocation to layouts with a compute-visible single-element STORAGE_BUFFER binding) and has_immutable_samplers at layout creation so hk_descriptor_set_create() skips two linear binding scans per allocated set.

Build & Artifacts

  • Host: J716c Apple M5 Max (G17C B1), Fedora Remix 44, kernel 7.3.0-40.j716c19.fc44.aurora.aarch64, GCC 16.2.1
  • Meson: --buildtype=release -Db_ndebug=true -Dbuild-tests=true -Dvulkan-drivers=asahi -Dgallium-drivers=
  • Base (origin/aurora-wip 822cf58723a): libvulkan_asahi.so SHA-256 d5b7e4582e1b034642e804f6477b070504ad077c2f0a3212989f6ad785228d68
  • Head (a2f7f3566fd): libvulkan_asahi.so SHA-256 c458876d283676c2f46badb9132c72129a296085157fe5d84325cc00c543cb28

Verification

  • Unit tests (meson test --suite asahi): 212/212 PASS, 0 FAIL.
  • Live M5 Max A/B (strict 3-round ABBA, MESA_SHADER_CACHE_DISABLE=1, end-to-end GPU sampling with mipLodBias = 0.5 across combined + separate sampler/sampled-image GPU_SAMPLE=PASS, plus linear-pool partial-allocation OOM rollback verified):
Workload Base median Head median Delta
vkAllocateDescriptorSets + vkResetDescriptorPool (300 × 512 sets) 46.2 ns/set 9.2 ns/set -79.98% (4.99x)
vkUpdateDescriptorSets (300 × 2,048 writes: combined/sampler/sampled/SSBO) 8.5 ns/desc 5.0 ns/desc -41.18% (1.70x)
  • Vulkan CTS (deqp-vk, base vs head):
    • 250-case dEQP-VK.api.descriptor_pool.* + dEQP-VK.api.descriptor_set.* + dEQP-VK.binding_model.descriptor_update.* + dEQP-VK.binding_model.descriptor_copy.*: 190/250 PASS, 0 FAIL, 60 NotSupported (0 status diffs vs base).
    • Added wider J716c A/B CTS at a2f7f3566fd: dEQP-VK.api.descriptor_set.* (6/6 PASS), dEQP-VK.binding_model.descriptorset_random.* (60/60 PASS), dEQP-VK.pipeline.monolithic.sampler.* (44/120 PASS, 76 NotSupported), dEQP-VK.texture.mipmap.2d.* (8/8 PASS) — 118/194 PASS, 0 FAIL, 0 status diffs vs base.
  • Host health: SELinux=Enforcing, 0 DRM/asahi/GPU kernel errors.

…r descriptor pool allocation

Speed up descriptor set allocation, pool reset, and per-frame descriptor
writes without any chip-model gating:

1. Gen 10 single-plane sampled descriptor fast path (`hk_descriptor_set.c`):
   - Extend `write_sampled_image_view_desc_g17p_single()` to descriptor
     generation 10 alongside generation 9, writing the exact same
     `write_g17p_sampler_bias()` and null-texture bytes as the general
     three-plane staging path without zeroing a 3-plane staging buffer.

2. Linear bump allocator and recycled set freelist (`hk_descriptor_set.c/.h`):
   - Descriptor pools created without
     `VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT` allocate
     monotonically via `pool->linear_offset` (skipping `util_vma_heap`
     node allocation/freeing) and reset `linear_offset = 0` on
     `vkResetDescriptorPool()`, rolling back `linear_offset` cleanly if a
     multi-set `vkAllocateDescriptorSets()` fails partway through.
   - Recycle zero-dynamic-descriptor `hk_descriptor_set` objects onto
     `pool->free_sets` on free/reset and release them on pool destruction,
     eliminating per-frame host `calloc`/`free` churn.

3. Precomputed layout flags (`hk_descriptor_set_layout.c/.h`):
   - Precompute `has_compute_storage_backing` (restricting
     `set->storage_backings` allocation to layouts with a compute-visible
     single-element `STORAGE_BUFFER` binding) and `has_immutable_samplers`
     at layout creation so `hk_descriptor_set_create()` skips two linear
     binding scans per allocated set.

Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
@oreater
oreater requested review from a team and DjDeveloperr as code owners November 26, 2026 22:53

@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 a2f7f3566fde: ready on the code; CI and hardware rows still owed

I found no code blocker. The fast path is keyed on descriptor generation (hardware data, no chip list). It writes the bytes the general path writes, and the linear pool and set recycling hold up on every path I traced. What's missing is coverage: no CI has run on this head, and the only hardware row is J716c, while the change reaches every chip.

Blockers

none

Checked

  • Which chips this reaches (agx_chip.h chip table, hk_descriptor_generation_is_agx3()):

    • generation 9 is G15G/S/C, G16G/S/C, G17P and G17A;
    • generation 10 is G17G/S/C and G18G;
    • the linear pool and recycled sets apply to every chip, AGX2 G13/G14 included.

    The body says "all Macs", which is right. It would help to name these groups, since G18G gets the Gen 10 fast path too.

  • Gen 9/10 fast path against the general path (write_sampled_image_view_desc()):

    • Layout. Generations 9 and 10 share the AGX3 layout (texture 32 B, then the software words at 32), so the general path takes its bulk-copy branch, and the fast path's single write_desc() of the struct is the same write.
    • Sampler only. Sampler index, clamp -1, lod_bias_fp16, bias words and the null texture all match. The general path never sets .sw.sampler (the key) on generation 9 or 10, so dropping it from the fast path makes Gen 9 match instead of differ.
    • Images.
      • The default sampler index is the biased index 0 on Gen 9 and 0 on Gen 10. The clamp is -1 with a sampler; without one it is -1 on Gen 9 and 0 on Gen 10.
      • scaled_conversion and the swizzle border word are Gen 9 only, and the border goes only on SAMPLED_IMAGE, as in the general path. The old fast path also wrote it for input attachments on Gen 9; that fix is a second small Gen 9 change.
      • USCALED-normalized views still fall back on Gen 9, and the general path has no USCALED handling on Gen 10.
    • Fallbacks. Custom-border samplers, multi-plane views and samplers, and a failing null texture all still take the general path.
  • Linear pool.

    • When it applies. Only pools without FREE_DESCRIPTOR_SET_BIT, where the app may not free sets individually; the only internal free is the rollback path.
    • Size. bo_size already reserves HK_MIN_UBO_ALIGNMENT * maxSets, so bumping by aligned sizes fits any allocation within the pool's limits. Alignment is relative to a page-aligned VA, and the overflow check is overflow-safe.
    • Rollback. A failed multi-set allocation restores linear_offset after freeing the sets it made, and vkResetDescriptorPool resets it to 0.
    • Zeroing. The per-set zeroing on native AGX3 still runs on every allocation, so reused bytes after a reset are cleared as before.
  • Recycled sets.

    • Only sets of layouts with no dynamic descriptors are recycled, so every recycled object has the same size.
    • vk_object_base_finish() runs before parking a set, and memset plus vk_object_base_init() run on reuse. Pool destroy frees parked sets with vk_free(&dev->vk.alloc), matching their vk_object_zalloc(&dev->vk, NULL).
    • A recycled set whose pool allocation fails goes through vk_object_free(), which also matches.
    • The dynamic count is read before the layout unref.
  • Layout flags.

    • has_compute_storage_backing now also needs a compute stage. Only hk_cmd_dispatch.c reads storage_backings, through hk_descriptor_set_storage_backing(), so that's consistent.
    • has_immutable_samplers uses the same predicate as the old scan.
    • Neither flag is serialized. That's fine: layouts with immutable samplers are never serialized, and sets are allocated only from app-created layouts.
  • Build and unit tests, on an aarch64 host (debugoptimized, -Dvulkan-drivers=asahi -Dbuild-tests=true): it builds, and none of its warnings come from the changed files. meson test --suite asahi: 212/212 OK. No unit test covers descriptor sets or pools directly.

  • Merge and text. It merges cleanly with aurora-wip. Commit and PR text carry no attribution.

Before merge

  • CI. No workflow has run on this head yet.
  • Hardware rows.
    • Only J716c (Gen 10) is listed. The pool change runs on every chip and the fast path changes Gen 9, so this shared code needs a second-generation row: a Gen 9 machine (G17P or M3/M4) and an AGX2 one for the linear pool. A G18G row is needed if one is possible.
    • The relevant CTS groups are api.descriptor_set.*, binding_model.* (descriptor pools and updates, immutable samplers), pipeline.*.sampler.* and texture.* with LOD bias.
  • CTS groups. "190/250 Vulkan CTS PASS" doesn't name the groups, and the CTS item in the details is empty.
  • Not yet. It currently holds a design note. It should list the rows and CI above.
Evidence
head a2f7f3566fde855ff4c1468124eeafbf3d243144, base aurora-wip (merge-base 822cf58723a0), merge-tree clean

agx_chip.h rows (descriptor generation): G13 7, G14 8, G15*/G16*/G17P/G17A 9, G17G/S/C 10, G18G 10
hk_native_descriptor.h: hk_descriptor_generation_is_agx3(g) = g == 9 || g == 10
  hk_texture_descriptor_size(9|10) = 32; layout: texture 0, sampler 32, stride 32 + HK_SAMPLED_IMAGE_SW_SIZE
  -> general path takes the bulk write_desc() branch, same bytes as the fast path's struct write
general path, gen 9/10: write_g17p_sampler_bias(), no .sw.sampler key; border swizzle only gen 9 SAMPLED_IMAGE
hk_CreateDescriptorPool: bo_size += HK_MIN_UBO_ALIGNMENT * maxSets
storage_backings readers: hk_cmd_dispatch.c (compute) only
hk_descriptor_set_layout_serialize(): refuses layouts with immutable samplers
ninja (asahi + tests)                  -> exit 0; warnings only in files this PR does not touch
meson test --suite asahi               -> Ok: 212, Fail: 0
CI runs for this head: none

@oreater

oreater commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks for the review at a2f7f3566fd.

Updated the PR description (**Tested:**, **Risk:**, **Not yet:**, and explicit CTS groups in Details) and ran the additional requested Vulkan CTS groups A/B against base on J716c (Apple M5 Max) at a2f7f3566fd:

  • dEQP-VK.api.descriptor_set.* (6 cases): 6/6 PASS, 0 FAIL, 0 diffs.
  • dEQP-VK.binding_model.descriptorset_random.* (60 cases): 60/60 PASS, 0 FAIL, 0 diffs.
  • dEQP-VK.pipeline.monolithic.sampler.* (120 cases): 44/120 PASS, 76 NotSupported, 0 FAIL, 0 diffs.
  • dEQP-VK.texture.mipmap.2d.* (8 cases): 8/8 PASS, 0 FAIL, 0 diffs.

Combined with the initial api.descriptor_pool.* + binding_model.descriptor_{update,copy}.* slice (190/250 PASS), that is 308/444 PASS, 0 FAIL, 0 status diffs vs base on J716c.

Listed the owed upstream CI run and Gen 9 / AGX2 / G18G hardware rows explicitly in **Not yet:** (I only have J716c locally).

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

Blockers: none

Checked: Read the whole diff. Linear pools only without FREE_DESCRIPTOR_SET_BIT (where vkFreeDescriptorSets is not allowed), the offset is rolled back on a partial allocation failure and reset on vkResetDescriptorPool. Recycled sets are zero-dynamic only, so the object size matches, are re-initialised with vk_object_base_init after a memset, and are freed with the device allocator they came from on pool destroy. has_compute_storage_backing keeps the old condition plus the compute stage bit; has_immutable_samplers only skips a loop that did nothing. The gen-10 fast path is keyed on descriptor generation, not chip IDs. Gate green. The rows you list in Not yet (a Gen 9 machine and an AGX2 machine) are ones we have; we will run them on J700 (G17P) and J473 (G14G).

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

a2f7f35 J413 M2 Air (G14G B0, 7.3.0-aurora-fleet89) PASS: api.descriptor_pool.* 6 pass / 0 fail, api.descriptor_set.* 6 / 0, binding_model.descriptor_update.* 63 pass / 60 not supported / 0 fail, binding_model.descriptor_copy.* 289 / 0 / 0, binding_model.descriptorset_random.* 6,300 / 28,848 / 0, pipeline.monolithic.sampler.* 52,774 / 129,261 / 0 (217,607 cases, every listed case ran), 0 GPU faults, Enforcing, 0 failed, 0 AVC; system Mesa untouched

Details
  • Build: exact head a2f7f35 (git archive of the PR head, no merge), release with assertions on (-Dbuildtype=release -Db_ndebug=false -Dvulkan-drivers=asahi), built natively on aarch64 Fedora 45 in a container. vulkaninfo with the overlay: Apple M2 (G14G B0), Mesa 26.3.0-devel (git-a2f7f3566f), Borealis.
  • Loaded through VK_DRIVER_FILES only. /usr/lib64/libvulkan_asahi.so sha256 82e6d1112e5e... before and after. Shader cache off.
  • CTS: deqp-vk 1.4.7.1 (3fd4ea318fe2), all six globs in full, 4 parallel processes, no crashes.
  • Kernel log over the run: 0 GPU faults, recoveries, timeouts or rejected submits. 0 AVC, 0 failed units, Enforcing.

@RyanTheTide

Copy link
Copy Markdown

a2f7f3566fde Neo (J700, Apple A18 Pro / G17P B1, 7.3.0-aurora-fleet89, default cmdline) FAIL (G17P separate-sampler border-swizzle regression): isolated Borealis overlay (-Dbuildtype=release -Db_ndebug=false, sha256: 2847594cf61f..., merged cleanly on aurora-wip@e1b5658fe695, meson test --suite asahi 214/214 PASS; J=1, MemoryMax=3G):

  • Passing: dEQP-VK.api.descriptor_pool.* 6/6, dEQP-VK.api.descriptor_set.* 6/6, dEQP-VK.binding_model.descriptor_update.* 123/123, dEQP-VK.binding_model.descriptor_copy.* 289/289, dEQP-VK.binding_model.descriptorset_random.* (--deqp-fraction=1,60) 486/614 (0 FAIL, 128 NotSupported).
  • Failing: dEQP-VK.pipeline.monolithic.sampler.* (--deqp-fraction=1,300): 310/498 PASS, 12 FAIL (176 NotSupported). All 12 failures are dEQP-VK.pipeline.monolithic.sampler.border_swizzle.*.opaque_white.gather_*_compute returning Color:(0, 0, 0, 0) instead of Ref:(1, 1, 1, 1) (e.g. b4g4r4a4_unorm_pack16.riba.opaque_white.gather_1.{no,with}_swizzle_hint_compute, r32g32b32a32_sfloat.igba.opaque_white.gather_1.{no,with}_swizzle_hint_compute, etc.).
  • A/B baseline: On aurora-wip@e1b5658fe695 without #1168, those same border_swizzle.*.opaque_white.gather_1.*_compute cases PASS 4/4 (Color:(1, 1, 1, 1)).
  • Root cause: src/asahi/vulkan/hk_descriptor_set.c in write_sampled_image_view_desc_g17p_single() removes .sampler = sampler->planes[0].hw->key, from the VK_DESCRIPTOR_TYPE_SAMPLER write, leaving desc.sw.sampler zero-initialized on descriptor_generation == 9 (G17P). Restoring .sampler = sampler->planes[0].hw->key for generation == 9 should fix it.
  • Health: 0 GPU faults/recoveries, 0 failed units, SELinux Enforcing, 0 new AVC denials, stock /usr/lib64/libvulkan_asahi.so untouched.

@RyanTheTide

Copy link
Copy Markdown

@oreater this merged at 15:44 AEDT, a few minutes before the Neo row above came in. On G17P, 12 border_swizzle.*.opaque_white.gather_*_compute cases fail with it and pass without it. I've opened the revert as #1200 so aurora-wip stays green on G17P. Please reland it with the fix in a new PR. The likely cause is the dropped .sampler = sampler->planes[0].hw->key in write_sampled_image_view_desc_g17p_single() for VK_DESCRIPTOR_TYPE_SAMPLER. We'll run the G17P border_swizzle group on the Neo for the reland. If a proven one-line fix lands first, we'll close #1200 instead.

RyanTheTide added a commit that referenced this pull request Nov 27, 2026
…gather

Revert "borealis: extend sampled descriptor fast path to Gen 10 and add linear pools" (#1168): G17P border gathers
@RyanTheTide

Copy link
Copy Markdown

Correction / 3-arm A/B/C follow-up on Neo (J700, Apple A18 Pro / G17P B1, 7.3.0-aurora-fleet89, J=1, MemoryMax=3G): the border_swizzle.*.opaque_white.gather_*_compute failures above are pre-existing and stateful across cases in one process, NOT caused by removing .sampler = sampler->planes[0].hw->key,:

  • Standalone 12-case run (--deqp-caselist-file with the 12 cases):
    • Arm A (81aa6840^1 = 99b632878ff7, pre-#1168): 12/12 PASS (0 FAIL)
    • Arm B (81aa6840, merged #1168): 12/12 PASS (0 FAIL)
    • Arm C (81aa6840 + restore .sampler = sampler->planes[0].hw->key,): 12/12 PASS (0 FAIL)
  • Full single-process sweep (dEQP-VK.pipeline.monolithic.sampler.* --deqp-fraction=1,300, 498 cases):
    • Arm A (81aa6840^1, pre-#1168): 312/498 PASS, 10/498 FAIL (176 NotSupported) — 10 of the same 12 border_swizzle.*.opaque_white.gather_*_compute cases already fail pre-#1168 (Color:(0,0,0,0) vs Ref:(1,1,1,1)).
    • Arm B (81aa6840, merged #1168): 310/498 PASS, 12/498 FAIL (176 NotSupported) — same 10 + r16g16_sfloat.r0ba.opaque_white.gather_0.{no,with}_swizzle_hint_compute.
    • Arm C (81aa6840 + restore .sampler = sampler->planes[0].hw->key,, meson test --suite asahi 214/214 PASS): 310/498 PASS, 12/498 FAIL (176 NotSupported) — identical to Arm B.

Earlier 4/4 baseline passed only because it ran 4 cases in a fresh process (matching Arm B 12/12 standalone). The stateful G17P border-swizzle failure is pre-existing in 81aa6840^1; restoring .sampler = sampler->planes[0].hw->key, does not change the result (and Arm B adds 2 more r16g16_sfloat cases in the 498-case sweep vs Arm A, likely from the same stateful cache/pool behavior).

RyanTheTide added a commit to funkzy/mesa that referenced this pull request Nov 27, 2026
…is-descriptor-fast-path-linear-pool"

This reverts commit 81aa684, reversing
changes made to e1b5658.

On the Neo (J700, G17P), twelve
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.*.opaque_white.gather_*_compute
cases fail with aurora-silicon#1168 (colour 0,0,0,0, reference 1,1,1,1). They pass on
the parent e1b5658. Revert first so aurora-wip stays green on G17P,
then reland with the fix and a G17P row.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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