Repository navigation
borealis: extend sampled descriptor fast path to Gen 10 and add linear descriptor pool allocation - #1168
Conversation
…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>
DjDeveloperr
left a comment
There was a problem hiding this comment.
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.hchip 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_conversionand the swizzle border word are Gen 9 only, and the border goes only onSAMPLED_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.
- 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
-
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_sizealready reservesHK_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_offsetafter freeing the sets it made, andvkResetDescriptorPoolresets 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.
- When it applies. Only pools without
-
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, andmemsetplusvk_object_base_init()run on reuse. Pool destroy frees parked sets withvk_free(&dev->vk.alloc), matching theirvk_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_backingnow also needs a compute stage. Onlyhk_cmd_dispatch.creadsstorage_backings, throughhk_descriptor_set_storage_backing(), so that's consistent.has_immutable_samplersuses 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.*andtexture.*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
|
Thanks for the review at Updated the PR description (
Combined with the initial Listed the owed upstream CI run and Gen 9 / AGX2 / G18G hardware rows explicitly in |
RyanTheTide
left a comment
There was a problem hiding this comment.
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):
- base
aurora-wip90211df6816: 335/335 OK. - batch build:
90211df6816with 22 open PR heads merged on top (#1133 #1137 #1155 #1136 #1140 #1157 #1158 #1160 #1164 #1165 #1167 #1168 #1170 #1171 #1172 #1175 #1182 #1183 #1185 #1187 #1190 #1191; each also merges cleanly alone, and into currentaurora-wipd2e883ab2e3): 335/336 OK. The one failure,agx3_cmat_mixed_mma8, reproduces with #1187 alone on the base (329/330) and is caused by that PR's new test; nothing else in the batch fails.
|
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
|
|
|
|
@oreater this merged at 15:44 AEDT, a few minutes before the Neo row above came in. On G17P, 12 |
…gather Revert "borealis: extend sampled descriptor fast path to Gen 10 and add linear pools" (#1168): G17P border gathers
|
Correction / 3-arm A/B/C follow-up on Neo (J700, Apple A18 Pro / G17P B1,
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 |
…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>
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_samplerslayout 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 acrossapi.descriptor_{pool,set}.*,binding_model.{descriptor_update,descriptor_copy,descriptorset_random}.*,pipeline.monolithic.sampler.*, andtexture.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_heapallocation and the 3-plane Gen 10 staging path. Linear allocation activates strictly whenVK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BITis 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 withVK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BITstay onutil_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:
Gen 10 single-plane sampled descriptor fast path (
src/asahi/vulkan/hk_descriptor_set.c):write_sampled_image_view_desc_g17p_single()to descriptor generation 10 alongside generation 9, emitting the exact samewrite_g17p_sampler_bias()and null-texture bytes as the general three-plane staging path without zeroing a 3-plane staging buffer.Linear bump allocator and recycled descriptor-set freelist (
src/asahi/vulkan/hk_descriptor_set.c,hk_descriptor_set.h):VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BITallocate monotonically viapool->linear_offset(skippingutil_vma_heapnode allocation/freeing) and resetlinear_offset = 0onvkResetDescriptorPool(), rollinglinear_offsetback cleanly if a multi-setvkAllocateDescriptorSets()fails partway through.hk_descriptor_setobjects ontopool->free_setson free/reset and frees them on pool destruction, avoiding per-frame hostcalloc/freechurn.Precomputed layout flags (
src/asahi/vulkan/hk_descriptor_set_layout.c,hk_descriptor_set_layout.h):has_compute_storage_backing(restrictingset->storage_backingsallocation to layouts with a compute-visible single-elementSTORAGE_BUFFERbinding) andhas_immutable_samplersat layout creation sohk_descriptor_set_create()skips two linear binding scans per allocated set.Build & Artifacts
J716c Apple M5 Max (G17C B1), Fedora Remix 44, kernel7.3.0-40.j716c19.fc44.aurora.aarch64, GCC16.2.1--buildtype=release -Db_ndebug=true -Dbuild-tests=true -Dvulkan-drivers=asahi -Dgallium-drivers=origin/aurora-wip822cf58723a):libvulkan_asahi.soSHA-256d5b7e4582e1b034642e804f6477b070504ad077c2f0a3212989f6ad785228d68a2f7f3566fd):libvulkan_asahi.soSHA-256c458876d283676c2f46badb9132c72129a296085157fe5d84325cc00c543cb28Verification
meson test --suite asahi):212/212 PASS, 0 FAIL.MESA_SHADER_CACHE_DISABLE=1, end-to-end GPU sampling withmipLodBias = 0.5across combined + separate sampler/sampled-imageGPU_SAMPLE=PASS, plus linear-pool partial-allocation OOM rollback verified):vkAllocateDescriptorSets+vkResetDescriptorPool(300 × 512sets)46.2 ns/set9.2 ns/set4.99x)vkUpdateDescriptorSets(300 × 2,048writes: combined/sampler/sampled/SSBO)8.5 ns/desc5.0 ns/desc1.70x)deqp-vk, base vs head):250-casedEQP-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(0status diffs vs base).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,76NotSupported),dEQP-VK.texture.mipmap.2d.*(8/8 PASS) —118/194 PASS,0 FAIL,0status diffs vs base.SELinux=Enforcing,0DRM/asahi/GPU kernel errors.