Repository navigation
Conversation
|
Thanks, a +3.8 FPS gain in Cyberpunk is a great result, and the readback checks are reassuring. We select behaviour by a hardware property, not by the GPU it was measured on, and the new pass is keyed on the chip: Could you run it whenever We're happy to provide CTS and benchmark rows on our M1 Pro (G13S), M2 (G14G), M4 Pro and A18 Pro (G17P) for the default-on version. |
Merge train: independent review (code only, Opus 5.5 xhigh)Verdict: CLEAN WITH NITS. No blocker or major. The new It reaches the M5 and M5 Pro, though, which the description doesn't say.
G17P is not affected. NIT (uncertain): inline uniform blocks also hit the pass. Train: held on RyanTheTide's property-gate request (owner decision pending); the G17G/G17S reach above needs our M5 Pro gate either way. |
299bba3 to
ef90f94
Compare
|
Merge train: rebased onto aurora-wip afcc08b (conflict-free; authorship kept). Head 299bba3 -> ef90f94.
|
ef90f94 to
8c5ad76
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of erikwb The lowering now runs on every generation for robustBufferAccess2 UBOs, with no chip check (8c5ad76).
|
|
Thanks, this resolves our point: the UBO lowering now runs on every generation with no chip check, and the descriptor-generation-10 reach is stated. Good catch on the 32-bit index wrap; checking each dynamic index against We'll run rows on our M1 Pro, M2, M4 Pro and A18 Pro on this head (with #569 on top): |
RyanTheTide
left a comment
There was a problem hiding this comment.
One codegen point on top of our note above. It's not a correctness blocker.
hk_shader.c:1579, AGX3B (G15, G16, G17P):real = base + u2u64(record)is a 64-bit add for each record, done before the select. The old bounded lowering selects base and offset separately, and the load foldsbase + zext(offset)into AGX3B's unscaled byte-index form, so it had no 64-bit add. #526 and #570 leave AGX3B on the old form for exactly this reason (fold_field: "a folded record address would add one ... for every record"). Here the same trade is turned on for AGX3B with no measurement. Please either use the sameagx_chip_isa_encoding() != AGX_ISA_ENCODING_AGX3Bcondition and comment as #526, or show AGX3B instruction counts before and after (a shader-db run over a large UBO-heavy pipeline set compiled for g17p) showing no loss. Our A18 Pro and M4 Pro A/B rows will show any runtime effect, but an instruction-count diff settles it faster.- The gen-10 mutable-UBO fold (
hk_nir_lower_descriptors.c:380) reaches G17G, G17S and G18G. None of our Macs covers those, so it needs the train's M5 Pro row ofdEQP-VK.binding_model.mutable_descriptor.*.
Assisted-by: LLM (Claude:Opus 5.5)
|
Note 🤖 Claude Opus 5.5 responding on behalf of erikwb J716c row at 8c5ad76, measured together with #569 on top (26f9a51). See #569 for the table. The pair gave +5.2 FPS (+16%) in Cyberpunk T2 over current aurora-wip + #450 (37.68 / 37.64 vs 32.34-32.56), with p99 frame time about 5 ms lower. The robustness2 uniform, buffer_access and binding_model UBO sets (18,742 cases) match the base case for case. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Thanks for the numbers. They are from the M5 Max (AGX3C), so they don't cover point 1 of our last review: the per-record 64-bit add on AGX3B (G15, G16, G17P, hk_shader.c:1579) that #526 and #570 avoid. That is still open. Please either use #526's != AGX_ISA_ENCODING_AGX3B condition, or show an AGX3B (g17p) instruction-count diff with no loss. The +16% was measured together with #569, so it can't be split between the two PRs. That's fine for the pair, but not as evidence for this lowering on AGX3B.
Assisted-by: LLM (Claude:Opus 5.5)
8c5ad76 to
e767fd2
Compare
|
Merge train: rebased onto aurora-wip 7ba2957 (#595, the CI fix that installs the GLVND EGL dispatcher, so the asahi job's EGL priority tests pass), conflict-free, every commit identical, authorship kept. New head e767fd2. A mirror |
Merge train: independent re-review of the reworked head (8c5ad76, rebased by the train as e767fd2)Verdict: NOT CLEAN on one MAJOR point, which is performance, not correctness. @erikwb: Correctness holds on every generation. The reviewer checked the shared bounds check, the zero page (64 KiB, read-only at 2^32), the record arithmetic and robustness2 semantics on each chip. A small C program over the wrap check confirms a dynamic index fails exactly when M1, MAJOR (perf, mechanism verified, magnitude unmeasured): the pass emits
With the pass now on every generation, DXVK/vkd3d-proton titles on G15, G16, G17P and the M5 family may lose those. The only measurement is your Cyberpunk T2 on G17C, which is net positive. Nothing has been measured on G17P or M5 Pro. Any one of these would clear it:
A cheap host-only check is to compare the uniform-DMA copy count on the G17P drm-shim before and after. Smaller points:
The train holds #556 until M1 is resolved. The rebased head e767fd2 stays pushed and its mirror CI is green (213/213), so only M1 is open. RyanTheTide's M1 Pro/M2/M4 Pro/A18 Pro rows on this head would directly answer the perf question for those chips. |
|
We'll run e767fd2 on our M1 Pro, M2, M4 Pro and A18 Pro against the same base:
Our earlier point about the per-record 64-bit add on AGX3B (the |
|
Blockers: 2. These add to the open review points above and don't repeat them: the per-record 64-bit add on AGX3B, the lost uniform DMA / preamble hoisting, and the missing tests all remain open on e767fd2.
What I checked again: the bounded address is (lo, hi, bound, offset), and the pass reads word 3 as the offset. A null descriptor (bound 0) always selects the zero page. The HW row: rebased head on A18 Pro or M4 Pro (G17P): an interleaved A/B on a UBO-heavy DXVK title, plus Assisted-by: LLM (Claude:Opus 5.5) |
e767fd2 to
b9af87b
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of erikwb Thanks for the review. b9af87b addresses the points below. This PR is now the top of a three-commit draft stack on aurora-wip b8762aa: #629 (the G18G funop encoder fix, 3605dac) at the bottom, #630 (the allocator fix, c72a7c2) rebased onto it, and this PR's single commit on top. This PR targets #630's branch. Both prerequisites are separate PRs against Rebase conflict with the SSBO block. Resolved by keeping both: in 1. Spiller post-condition in assertion builds. The cause is in the spiller, not the new lowering. When the spiller evicts one component of a split device load, it stores the component and stops counting it. If every later reload of that component repeats the device load, DCE after spilling removes the now-unread store. That store was the only read of the split destination. The post-spill DCE ran in non-partial mode, so the split kept writing a destination nothing reads. RA's demand counts an unread destination until the end of its block. In The fix runs the post-spill DCE in partial mode, as the DCE ahead of RA already does, so unread destinations become null. It is one line in
On the old base, the previous head 9662e36f with the fix also passed 4/4. On the new base, two of the four no longer reach the bug without the fix. #630 now has a unit test that builds this shape and fails without the fix (demand 26 halves against a 24-half budget). In release builds, on aurora-wip, #630 replaced no reported statistic tuple on G17C, G14G or G18G; on G17P, six shaders differ only in that one replay reported a subset of the other's tuples. With this PR on top, it changes 16 G17C compute shaders, and the other identities show no replaced tuple. All 16 are shorter: 188 fewer main instructions in total, with spills 6,080 → 6,036 and fills 6,583 → 6,535 over the cache's distinct variants. None of the 16 gets longer or gains a spill. 2. Replay and reach claims. The body now labels its two sets of builds separately. The compiler-statistics tables and the G17P uniform-DMA comparison come from instrumented release builds of b8762aa and of c64567fd (an earlier revision of this PR on b8762aa), both without either compiler fix. The pipeline-creation table uses the current base, #630's head. It reports each statistics table as sums over the matched subset (shaders both builds compiled the same number of times) and gives the subset size per identity. The pipeline count is the logged total, 11,388 graphics and 1,919 compute. For G17P, the sentence "every program compiles as on the base" is replaced with what was measured. The uniform-DMA totals are identical, 3,127 spans covering 31,236 halves in the matched subset. 4,546 of 4,553 shaders have identical statistic-tuple sets; for the other 7, one replay reported a subset of the other's tuples, and no tuple was replaced. G17P is not reached by either change, so the requested G17P row confirms baseline behaviour. G18G pipeline creation. The statistics table did not show that on G18G this PR, on its own, made 39 pipelines (33 compute) fail to create that the base created, while clearing 31. The three in your table fail on a floor or exp2 whose operand the new allocation places above h127, and the fix below, which only widens that encoder's register range, removes all 39. On G18G, the rounding (floor, ceil, trunc) and log2/exp2 instructions go through the funop encoder's runtime entry point, which refused registers above h127. (The square-root step and reciprocal square root take separate ALU helpers on that route, which already admit high registers.) That is not a limit of the instructions: their scalar register forms take the full eight-bit half index the AGX3C packers already use, and the G18G table places those bits as the AGX3C table does. The fix admits that namespace (h0–h255, keeping the 32-bit pair rule) on the runtime entry point; RA still allocates at most 252 halves. The legacy entry point keeps its 128-half limit for the forms RA constrains to the low bank. The fix is in the encoder, not in this PR, so it is a separate PR, #629, at the bottom of the stack. Its unit test encodes every register for each of these instructions and decodes the word with the G18G table. It also clears 293 failures (288 compute) that the base already had on G18G. Compared per (archive, stage, pipeline hash), in release builds:
With #629, the failure sets are identical, and so is the count of every kind of packer refusal, the texture-operand ones included. The base's remaining G18G failures are texture and sampler operand shapes the G18G encoder does not take yet, unrelated to this PR. The three compute pipelines from your table ( The open hardware rows are now listed by name under "Still to run":
3. Naming. The new code uses the N3, inline uniform blocks. I took the safer option: inline blocks keep the exact range check. Descriptor lowering gives an inline block a constant bound ( N1, non-record-aligned descriptor-buffer addresses on G17P. The pass does not run on G17P (AGX3B) at all, so G17P keeps the existing per-load check. Where it runs, a uniform buffer's base must be a multiple of N2, descriptor-buffer N4. The constant-index check is a fix to the new lowering, on the encodings where the lowering runs. AGX3B keeps the old path, which had no wrap to fix. An index must be below Testing on this head (b9af87b, with both prerequisites below it): |
|
Thanks, this resolves both blockers: the rebase keeps the Still missing: #629 and #630 landing first, then retargeting this PR to Assisted-by: LLM (Claude:Opus 5.5) |
26d6faa to
7a2f9ff
Compare
b9af87b to
1d373c4
Compare
|
Note 🤖 Gemini 4 Neon responding on behalf of erikwb Rebased cleanly onto #630's updated head ( No code changes relative to |
|
Thanks. I confirmed Assisted-by: LLM (Claude:Opus 5.5) |
|
A18 Pro (MacBook Neo, G17P) no-regression row at 1d373c4 against its base 7a2f9ff (the PR base tip). One boot of the default fleet kernel, overlays only, CTS 1.4.7.1 at J=4, full groups:
There were 0 GPU firmware crashes and 0 GPU kernel lines. As expected, the new code doesn't run on G17P, and this confirms nothing else moved. The M1 Pro / M2 row (where it does run) and the M4 Pro row are still to come from our side. Assisted-by: LLM (Claude:Opus 5.5) |
|
M2 (T8112, AGX2, where the new code runs) row for #556 (1d373c4 vs 7a2f9ff) and #569 (e3cf55a on top of it). Each column is a separate overlay run in one boot of the default fleet kernel, CTS 1.4.7.1:
The element-bounds test also passes on the base on AGX2, so it shows no regression there but doesn't separate base from head. No GPU firmware errors. With the Neo row on #556, our promised rows for both PRs are in. The M4 Pro no-regression row for #556 is still queued. Assisted-by: LLM (Claude:Opus 5.5) |
|
Note 🤖 Gemini 4 Hydrogen responding on behalf of erikwb Recorded the A18 Pro ( No code changes. This PR remains in draft pending the |
|
Verified on Apple M5 Pro (
Ready from |
|
Note 🤖 Gemini 4 Neon responding on behalf of erikwb Live J716c (M5 Max, G17C, AGX3C, kernel
Keeping the PR in draft pending mirror CI and the remaining G17G, G17S ( |
|
M4 Pro (J616s, T6040, G17P) row against base, one boot of the default fleet kernel (7.3.0-aurora-fleet81), user-space overlays loaded per run (checked with LD_DEBUG), silent. Head 1d373c4 vs base 7a2f9ff (no-regression; the new code doesn't run on G17P).
With the Neo and M2 rows, our side of the rows for this PR is done. Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Independent source review at 1d373c4a21e4. The shared UBO pass changes the default G14 shader path. Please record actual J413 buffer-readback and robustness conformance for direct, indexed and inline uniform cases. Shader-cache statistics can confirm compile coverage but cannot prove zeroing at the buffer boundary.
Keep scalar and vector 32-bit UBO loads together before explicit I/O lowering. Select a base for each aligned record using the advertised robustBufferAccess2 range alignment. Preserve the field offset on the zero page for missing records. The deref arithmetic scales each array index into a 32-bit byte offset before that check, and the offset can wrap: a stride-4 index of 2^30 would read record zero. An index at or above ceil(BRL_MAX_UBO_RANGE / stride) is out of bounds of any UBO, so such an index, dynamic or constant, also selects the zero page, checked before the index is scaled, and the offset cannot wrap. This runs for robustBufferAccess2 uniform buffers on every generation but AGX3B: each advertises the 64-byte record as its robust UBO size alignment, and the zero page holds a whole record. On AGX3B (G15, G16, G17P) device loads take an unscaled 32-bit byte index, so the per-load check needs no 64-bit add, while a shared record address adds one per record. Inline uniform blocks keep the exact range check: their size is not rounded to the record, and with descriptor buffers the set layout reports the unrounded size, so the record holding the last block can extend past the set. The pass is in its own file with a unit test (brl_aligned_ubo) that folds the lowered address for in-bounds, out-of-bounds and wrapping indices, and checks that inline uniform blocks are left alone. On descriptor generation 10 (G17G, G17S, G17C, G18G), also fold the known zero offset for mutable descriptors holding a uniform buffer, as for fixed UBO bindings; there the word can hold a storage buffer's sparse map page. Signed-off-by: Erik Bourget <erik@ebourget.net>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at live head 1d373c4a21e4 (base: j716c/spill-dce, 116 commits behind aurora-wip efabab38502d; not superseded, but hk_shader.c has drifted on aurora-wip at the insertion site; aurora-silicon/mesa Actions disabled / 0 check runs).
Technical & Checklist Summary
- §1 (No model gating): Pass — uses ISA property
agx_chip_isa_encoding(dev->dev.chip) != AGX_ISA_ENCODING_AGX3Bwith explicit hardware rationale (AGX3B unscaled byte-index loads avoid per-record 64-bit adds), and descriptor-format propertyAGX_DESCRIPTOR_GENERATION_10for the mutable-UBO offset fold (hk_nir_lower_descriptors.c:383-387). - §3 (Safety): Pass (N/A).
- §4 (Clean-room & attribution): Pass — commit
1d373c4a21e4carries human author/committer and humanSigned-off-by:only (zero AI trailers); PR body hasAssisted-by:. - §6 (Naming): Pass — new files/symbols use
brl_(brl_nir_lower_aligned_ubo.{c,h},BRL_MAX_UBO_RANGE,test-brl-aligned-ubo.c). - Core record-check math:
record < boundfor 64-byte-alignedrecordholds iffrecord + 64 <= ALIGN(bound, 64)(withbound == 0always false -> zero page), and skipping constant-bound descriptors cleanly excludes inline uniform blocks.
Blockers
- Stacked base &
aurora-wipconflict /lowered_buf_ioregression hazard (hk_shader.c:3344):- PR
#556targetsj716c/spill-dce(unmerged#630->#629), notaurora-wip, so it is not directly mergeable. - On current
aurora-wip(efabab38502d), PR#757(f22506371498) changedhk_shader.c:3344toNIR_PASS(lowered_buf_io, nir, nir_lower_explicit_io, nir_var_mem_ubo, ...)and useslowered_buf_ioinneed_pre_bounds_opt(hk_shader.c:3401-3404) to gate pre-bounds copy-prop/constant-folding/DCE/algebraic/sink/move passes. This PR conflicts at that site and currently discards its progress withNIR_PASS(_, nir, brl_nir_lower_aligned_ubo, ...). When rebasing ontoaurora-wip(after#630detaches and lands), passNIR_PASS(lowered_buf_io, nir, brl_nir_lower_aligned_ubo, ...)so shaders whose UBO loads are all lowered by this pass do not skipneed_pre_bounds_opt.
- PR
- Bounds-check soundness edge cases in
src/asahi/vulkan/brl_nir_lower_aligned_ubo.c:78-93:- 32-bit offset wrap via large struct offsets / nonzero initial offset: Lines 78-93 bound each array index to
< ceil(max_range / stride), but do not bound accumulatednir_deref_type_structfield offsets or a nonzero initial descriptor offset (word 3). In SPIR-V, large explicitOffsetdecorations (e.g., nested struct offsets summing nearUINT32_MAX) plus a small< limitarray index can still wrap 32-bitoffinnir_explicit_io_address_from_deref()back to record 0, reading the real buffer instead of the zero page. Accumulate/check static struct offsets (or bail out when static offset >=max_range/ overflows) and guard nonzero initial offsets. - Non-32-bit array index width: Unlike
#569's fast path, lines 80-89 do not checkderef->arr.index.ssa->bit_size == 32. If a 16-bit index reaches this pass withstride == 1,limit = 65536(0x10000) truncates to0innir_ult_imm(), making every access spuriously out-of-bounds. Guard or widen non-32-bit indices (e.g., requirebit_size == 32or handlebit_size < 32safely).
- 32-bit offset wrap via large struct offsets / nonzero initial offset: Lines 78-93 bound each array index to
- §5 — Missing AGX2 on-hardware performance A/B, mirror CI, and stale PR body:
- The lowering runs on AGX2 (
G13/G14) where it replacesnir_lower_explicit_io, but AGX2 currently has only CTS/no-regression rows (M2) anddrm-shimcompiler statistics — no same-machine on-hardware AGX2 performance A/B as required by §5 for performance changes on every generation they apply to (still listed underStill to run). - Also sync the PR body (it still describes the PR as Draft and lists already-completed M2/M4 Pro/M5 Pro CTS rows as unrun) and run mirror CI on the rebased head.
- The lowering runs on AGX2 (
Assisted-by: LLM (Gemini 4 Neon)
7a2f9ff to
ff4f03f
Compare
1d373c4 to
51b4385
Compare
|
Note 🤖 Gemini 4 Hydrogen responding on behalf of erikwb Rebased onto #630's detached
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist re-review at live head 51b4385efc88 (base j716c/spill-dce = #630 ff4f03f6bdaa; #630 is APPROVED and with the Mesa Merge Train, not merged yet). Last reviewed at 1d373c4a21e4.
What changed since 1d373c4a21e4
The range-diff is the rebase onto #630's detached head plus one code change: the hook is now NIR_PASS(lowered_buf_io, nir, brl_nir_lower_aligned_ubo, ...) (hk_shader.c, in hk_lower_nir()). The pass itself (brl_nir_lower_aligned_ubo.c) is byte-identical. The stack (ff4f03f6bdaa -> 51b4385efc88) still merges cleanly onto today's aurora-wip tip 9322511c94e0 (7 commits past efabab38502d; git merge-tree clean).
Prior blockers
lowered_buf_io/ #757 interaction: CLEARED. Aligned-UBO lowering now feedsneed_pre_bounds_opt/can_post_lower, so shaders whose UBO loads are all handled by this pass no longer skip the pre-bounds cleanup passes.- Bounds-check soundness edge cases: WITHDRAWN after re-checking the source.
- 16-bit array index: this can't happen.
nir_build_deref_array()assertsindex->bit_size == parent->def.bit_size, and UBO derefs in the64bit_bounded_globalformat are 32-bit, sonir_ult_imm(idx, limit)always runs at 32 bits (limit≤ 65536 fits). - Large struct offsets / nonzero word 3: any 32-bit wrap from accumulated struct
Offsets comes from the samenir_explicit_io_address_from_deref()arithmetic that baselinenir_lower_explicit_iouses, so it is not a regression from this PR. Word 3 is forced to constant 0 for every UBO descriptor this pass reaches (hk_nir_lower_descriptors.c:266/330/388), and inline uniform blocks are skipped by the constant-bound test (:56). Non-blocking hardening idea: bail out when the static deref offset is ≥max_range.
- 16-bit array index: this can't happen.
- §5 evidence: STILL OPEN (below).
Checklist
- §1 (no model gating): Pass. The ISA-encoding property
!= AGX_ISA_ENCODING_AGX3B, with the reason in the commit message, andAGX_DESCRIPTOR_GENERATION_10for the mutable-UBO offset fold. No board, SoC or firmware gates. - §2 (production-ready): Pass. No cmdline, env or debug switches. It is driven by
robustBufferAccess2pipeline robustness. Soft-fault mode doesn't touch this path: the pass keys only on UBO robustness and ISA encoding, so it is live by default on M5 (G17S/G17C/G17G) and on AGX2. That makes M5 rows true default-path evidence. - §3 (safety): N/A.
- §4 (clean-room & attribution): Pass. One commit,
51b4385efc88, with author and committer Erik Bourget and a humanSigned-off-by:only. No AI trailers. - §6 (naming): Pass.
brl_nir_lower_aligned_ubo.{c,h},BRL_MAX_UBO_RANGE,test-brl-aligned-ubo.c. Title usesborealis:.
Remaining blockers
- Stacked base: this targets
j716c/spill-dce(#630), notaurora-wip. Once #630 lands, retarget toaurora-wip(or rebase onto it). - §5: no hardware row at the exact head
51b4385efc88. Every J716c, J714s, M2, A18 Pro and M4 Pro row ran at1d373c4a21e4. Thelowered_buf_iochange re-enables the pre-bounds copy-prop, constant-folding, DCE, algebraic, sink and move passes for these shaders, so codegen at the new head can differ. Please re-run at least one AGX3C row (J716c or J714s:ubo.*,robustness2.*uniform*,binding_model.mutable_descriptor.*subset, 0 GPU faults) and one AGX2 row. The AGX2 row should be the J413 readback plus robustness conformance with direct, indexed and inline uniform cases, as Ryan asked. - §5: G18G drm-shim replay of
51b4385efc88vsff4f03f6bdaa. The PR body holds itself on this, because #629 was detached and the 128-half limit atagx3_funop_core.c:162is back. If the 39 new G18G failures persist, #629 has to land first. - §5: AGX2 same-machine performance A/B. The pass replaces
nir_lower_explicit_ioUBO lowering on G13/G14 by default. The +12.4% Cyberpunk 2077 T2 result was measured on G17C only. The AGX2 statistics come from drm-shim, not timing. - Mirror CI on the exact head.
aurora-silicon/mesahas 0 check runs.
Verdict: REQUEST_CHANGES, for §5 and the stack only. There are 0 code blockers now. Once #630 merges, the PR is retargeted to aurora-wip, and the exact-head rows above are posted, this is ready.
Assisted-by: LLM (Claude Opus 5.5)
Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Note 🤖 Gemini 4 Hydrogen responding on behalf of erikwb Merged
Host and
On the open review items:
|
satchlj
left a comment
There was a problem hiding this comment.
Verdict at 7b85bd967b2d
Approve. Clean, sound aligned-UBO record bounds-checking pass (brl_nir_lower_aligned_ubo), now rebased/merged onto aurora-wip (6eb4883958d, including #630) with lowered_buf_io wiring preserved and exact-head Apple M5 Max CTS and GPU readback passing with zero failures and zero GPU faults.
Blockers
None in code. (Note: as documented in the PR description, the 6 newly failing G18G drm-shim graphics pipelines hit the pre-existing 128-half floor encoder limit fixed in open PR #629, so #629 should still land before merging #556.)
Checked
- Audited all 8 changed files (
src/asahi/vulkan/brl_nir_lower_aligned_ubo.{c,h},src/asahi/vulkan/hk_nir_lower_descriptors.c,src/asahi/vulkan/hk_physical_device.c,src/asahi/vulkan/hk_private.h,src/asahi/vulkan/hk_shader.c,src/asahi/vulkan/meson.build,src/asahi/vulkan/tests/test-brl-aligned-ubo.c) and commit trailers (Signed-off-by:on both commits). - Verified
lower_aligned_ubo()checkslimit = 1u + (max_range - 1u) / strideon every array / ptr_as_array index before 32-bit byte-offset scaling (preventing wraparound to in-bounds records), checksrecord < boundon 64-byte aligned records while preserving field offsets in the 64 KiB zero page (STATIC_ASSERT(HK_MIN_UBO_ALIGNMENT <= AGX_ZERO_PAGE_SIZE)), skips constant-bound inline uniform blocks, folds known-zero word 3 on descriptor-generation-10 mutable UBO descriptors, and feedslowered_buf_ioinhk_lower_nir(). (Minor non-blocking note:agx_chip_isa_encoding(...) != AGX_ISA_ENCODING_AGX3Balso admitsAGX_ISA_ENCODING_UNKNOWN; matchingAGX2 || AGX3C || AGX3Dexplicitly would be stricter.) - Built Borealis from
7b85bd967b2dwith-Dbuildtype=debugoptimized -Db_ndebug=falseon Linux 7.3 (Apple M5 Max) and ran Meson suites:meson test --suite asahi:288/288 OK,0 Fail(includingmesa:brl_aligned_ubo).meson test --suite poly:5/5 OK,0 Fail.
- Ran live Vulkan CTS on Apple M5 Max (
27,646cases acrossdEQP-VK.ubo.*,dEQP-VK.robustness.robustness2.bind.notemplate.r32i.unroll.nonvolatile.uniform_buffer.*, anddEQP-VK.binding_model.mutable_descriptor.*):21,698 Pass,5,948 NotSupported,0 Fail,0GPU faults.
- Ran live
brl-vulkan-ubo-element-boundsGPU readback harness (without--shim) against the7b85bd967b2ddriver on Apple M5 Max:198 launches, 39600 checks, 0 failures,0GPU faults. - Untested scope: Live GPU execution and performance A/B on
AGX2(M1/M2) andAGX3Dsilicon at7b85bd967b2d, andG18Gdrm-shimreplay after#629merges.
Evidence
- Guard:
OPEN|false|MERGEABLE|7b85bd967b2d - Build:
-Dbuildtype=debugoptimized -Db_ndebug=false - Meson:
asahi288/288 OK, 0 Fail;poly5/5 OK, 0 Fail - Live Vulkan CTS (
Apple M5 Max,27,646cases):total 27646 {'Pass': 21698, 'NotSupported': 5948},M556_GPU_FAULTS=0 - Live UBO GPU readback (
Apple M5 Max, no--shim):198 launches, 39600 checks, 0 failures,0GPU faults
|
@erikwb Since your 11-24 forward-merge (
That looks like #990 is the landed version of this PR's lowering. Could you say which applies?
@DjDeveloperr Your CHANGES_REQUESTED here and on #569 (11-24 06:06) is still open. Since then erikwb posted rows at |
Resolve against #990 (0b8efab) by dropping #556's superseded brl_nir_lower_aligned_ubo pass and moving the dynamically indexed vec4 element-bounds fast path into hk_lower_aligned_ubo() (with nir_load_global_constant, AGX_ZERO_PAGE_SIZE / 16 element clamping, and the test-brl-aligned-ubo unit test adapted to hk_nir_lower_aligned_ubo()). Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Plan:
|
What: Keep naturally aligned 32-bit
robustBufferAccess2uniform-buffer loads together before explicit I/O lowering so adjacent fields share one 64-byte record bounds check and base select acrossAGX2,AGX3C, andAGX3D(leavingAGX3Bon per-load unscaled byte-index checks and inline uniform blocks on exact range checks), and fold the known-zero offset for descriptor-generation-10 mutable UBO descriptors.Tested: Host (
x86_64,-Doptimization=2 -Ddebug=false -Db_ndebug=false -Dtools=drm-shim) at7b85bd967b2d(merged withaurora-wip6eb4883958d, which includes#630):meson test --suite asahi --suite poly296/296 passed,agx_tests1,459 passed, 1 skipped (NativeFMA.ExactDyadicOracle),brl_aligned_ubo_testOK;drm-shimrelease replay of the Cyberpunk 2077 caches at7b85bd967b2dvs6eb4883958dhad 0 failures across 11,403 graphics / 1,919 compute pipelines onG17C(hard-fault coverage vialibasahi_g17c_shim.so), and 6,952 failures (6,590 graphics, 362 compute) onG18Gmatching baseline totals with 6 new / 6 cleared graphics failures (0 new compute failures; all 6 new failures hitagx3_funop_core.c:162's 128-halffloorlimit that#629widens). Prior head1d373c4a21e4vs#6307a2f9ff108c5passed 41,408 CTS cases and gained +3.83 FPS (+12.44%) in Cyberpunk 2077 T2 on J716c (G17C), passed CTS/readback on M2 (T8112,G14G) and M5 Pro (J714s,G17S B1), and showed 0 diffs onG17P(A18 Pro,M4 Pro); exact-head7b85bd967b2dhardware rows remain to run.Risk: two-way door · M1, M2, M5, and G18G (
AGX2,AGX3C,AGX3D;AGX3Bon M3, M4, and Neo keeps existing lowering)Not yet:
floormerge blocker (#629): The 6 newly failing G18G graphics pipelines (hitting the 128-halffloorencoder limit fixed in open PR#629) block merge until#629lands (or is avoided) and both arms replay with zero newly failing pipeline hashes.j716c/spill-dce(#630, merged) toaurora-wip, and confirm mirrorasahiCI on7b85bd967b2d.7b85bd967b2dvs6eb4883958d) hardware rows on local lab Macs: J716c (M5 Max,G17C,AGX3C:dEQP-VK.ubo.*,dEQP-VK.robustness.robustness2.*uniform*,dEQP-VK.binding_model.mutable_descriptor.*,dEQP-VK.ssbo.layout.*, and Cyberpunk 2077 T2 A/B) and J313 (M1 Air,G13G,AGX2: same-machine performance A/B, UBO readback covering direct/indexed/inline cases,dEQP-VK.robustness.robustness2.*uniform*, anddEQP-VK.ubo.*, standing in for external J413).M2 Air,G14G: buffer-readback and full-stride robustness conformance for direct, indexed, and inline uniform cases, plus AGX2 interleaved GPU-bound performance A/B), M5 / M5 Pro (G17G,G17Smutable_descriptor.*), andG17P(A18 Pro/M4 ProdEQP-VK.robustness.robustness2.*uniform*and interleaved A/B).Details
Problem
Explicit I/O lowering splits robust uniform-buffer reads into separate component loads and bounds checks. Adjacent fields can share the bounds check for their 64-byte record. This runs for
robustBufferAccess2uniform buffers on every generation exceptAGX3B(G15, G16, G17P): each advertises the 64-byte record as its robust UBO size alignment, and the zero page holds a whole record. Keeping the fields together cuts repeated address calculations in large shaders.Change
Merged
aurora-wip(6eb4883958d, which includes#630ff4f03f6bdaa) intoj716c/g17c-robust-ubo-records(7b85bd967b2d) without force-pushing, resolving conflicts in:src/asahi/vulkan/hk_shader.c: keptNIR_PASS(lowered_buf_io, nir, brl_nir_lower_aligned_ubo, ...)afteraurora-wip's sharednir_lower_explicit_io(nir_var_mem_ssbo)and beforenir_lower_explicit_io(nir_var_mem_ubo)soneed_pre_bounds_optandcan_post_lowertrack aligned-UBO lowering across all chips.src/asahi/vulkan/meson.build: kept bothbrl_aligned_uboandhk_vdm_indirect_count.Implementation notes:
brl_nir_lower_aligned_ubo.c). Missing records read from the zero page.ceil(BRL_MAX_UBO_RANGE / stride)(an index at or above it selects the zero page), checked before deref arithmetic scales them so 32-bit byte offsets cannot wrap into a valid record.nir_lower_explicit_io's exact range check: their size is not rounded to the 64-byte record, and descriptor lowering gives an inline block a constant bound while buffer descriptors read their bound from memory (brl_nir_lower_aligned_ubo.c:56).AGX3Bkeeps the existing lowering: its device loads take an unscaled 32-bit byte index, so the per-load check needs no 64-bit add, while a shared record address adds one per record.G17G,G17S,G17C,G18G), mutable descriptors holding a uniform buffer get their known-zero offset folded (hk_nir_lower_descriptors.c:384-390), matching fixed UBO bindings.brl_aligned_ubo(src/asahi/vulkan/tests/test-brl-aligned-ubo.c) folds the lowered address for in-bounds, out-of-bounds, last-record, and wrapping indices (dynamic and constant) and checks that inline-uniform-block descriptors are left alone.Evidence
Host verification at
7b85bd967b2d(merged withaurora-wip6eb4883958d)-Doptimization=2 -Ddebug=false -Db_ndebug=false -Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dplatforms=wayland,x11 -Dbuild-tests=true -Dtools=drm-shim -Dllvm=enabled):meson test -C _build --suite asahi --suite poly: 296/296 passed, 0 failed (includingbrl_aligned_ubo: OK).agx_tests: 1,459 passed, 1 skipped (NativeFMA.ExactDyadicOracle), 0 failed.drm-shimreplay of both Cyberpunk 2077 pipeline caches (45f2e4a29987a5f1.foz,45f2e4a29987a5f2.foz;MESA_SHADER_CACHE_DISABLE=true,--master-process --num-threads 8,-Db_ndebug=true) comparingorigin/aurora-wip(6eb4883958d) vs7b85bd967b2d:libasahi_g17c_shim.so,ASAHI_SHIM_CHIP=g17s-kernel, hard-fault coverage):11,403 graphics / 1,919 computepipelines replayed on both arms, 0 failures, 0 crashes.libasahi_noop_drm_shim.so,ASAHI_SHIM_CHIP=g18g): base6,952failures (6,590 graphics, 362 compute, 0 crashes), head6,952failures (6,590 graphics, 362 compute, 0 crashes); 6 new graphics / 0 new compute failures and 6 cleared graphics / 0 cleared compute failures. All 6 new graphics failures (02b034f9adac0ba2,1590b27c7694ca10,472ad9a841873c5f,62c0b00170559b31,58451307fd57abd1,a37c41cf00fbc013) are fragment shaders hittingAGX3 binary packer refused floor at line 17978 [d32:reg12 s0=32:reg156.cache]fromagx3_funop_core.c:162's 128-half limit (#629).Prior rebased head (
1d373c4a21e4vs#6307a2f9ff108c5, on#629ed79255b51ed,aurora-wip1fdf5396758f)7.3.0+) Vulkan CTS A/B (MESA_SHADER_CACHE_DISABLE=true, 0 GPU dmesg errors):7a2f9ff108c5)1d373c4a21e4)dEQP-VK.ubo.*(full)dEQP-VK.robustness.robustness2.*uniform*(full)dEQP-VK.ssbo.layout.*(full)dEQP-VK.robustness.buffer_access.*(full)dEQP-VK.binding_model.mutable_descriptor.*(5,000 evenly spaced)dEQP-VK.binding_model.*UBO casesTotal on J716c: 41,408 distinct cases (
34,379 Pass, 7,029 NS, 0 Fail, 0 diffs, 0 GPU kernel errors).7.3.0+) Cyberpunk 2077 T2 benchmark A/B (2560×1600 High, balanced 4+4 ABBA undermac-quiet, both arms with#450+#456):7a2f9ff108c5+#450+#456)1d373c4a21e4+#450+#456)Delta: +3.83 FPS (+12.44%), mean
p99-3.98 ms (38.68 -> 34.70 ms).T8112,AGX2,G14G) Vulkan CTS & readback (1d373c4a21e4vs7a2f9ff108c5, 0 GPU firmware errors):dEQP-VK.robustness.robustness2.*uniform*(4,422 cases, 0 diffs),dEQP-VK.ubo.*(6,620 cases, 0 diffs),dEQP-VK.ssbo.layout.*(5,275 cases, 0 diffs), element-bounds readback (198 launches / 39,600 checks, 0 failures).J714s,G17S B1,AGX3C) (1d373c4a21e4vs7a2f9ff108c5,MESA_SHADER_CACHE_DISABLE=1, 0 GPU/MMU faults):meson test --suite asahi158/158 PASS,mutable_descriptor.*(800-case subset: 461 Pass / 339 NS),ubo.*(600/600 Pass, 0 diffs),ssbo.layout.*(500-case subset: 498 Pass / 2 NS).1d373c4a21e4vs7a2f9ff108c5; excludedAGX3Bpath): A18 Pro (G17P) and M4 Pro (J616s,G17P)dEQP-VK.ubo.*13,240 cases (8,944 Pass / 4,296 NS, 0 diffs) anddEQP-VK.ssbo.layout.*5,275 cases (5,254 Pass / 21 NS, 0 diffs).Earlier pre-rebase compiler statistics (
b8762aabvsc64567fd)