Repository navigation
agx: introduce agx3b support & HAL200 - #1
Closed
DjDeveloperr wants to merge 234 commits into
Closed
DjDeveloperr wants to merge 234 commits into
DjDeveloperr wants to merge 234 commits into
Conversation
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Keep the heap counter eight-byte aligned through the shared cache pointer. Use Mesa's atomic wrapper for both its storage and its pointer type. Remove the stale comment for a deleted qualification switch. Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
A half add has no immediate form on G17P besides -x + #1.0 and the signed-zero adds that implement conversions, with or without a modifier beside the immediate: mediump c - x and x - c (dEQP trig range reduction, the brief's "f16 add with a non-1.0 immediate beside -x") were refused. Load such an immediate as an exact half, make a modifier an explicit sign-bit operation as d0b47452228 does, and emit the result as the register HADD that NIR's own 16-bit fadd produces; a 16-bit FADD has no form at all. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 22713589ca6226620616eeb16302d9bd807ee074)
The AGX3 path of fsin_agx kept a 16-bit operand's precision, but the native sinc is a 32-bit funop with no half form, so mediump fragment trigonometry was refused at sinc_agx3. Widen the quadrant, evaluate at full precision and narrow the result. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit dad7277ba9e1ec3a9f1887a43425296c417b1b57)
agx_nir_lower_g17p_f16_classify() read a comparison's constant with nir_src_as_float(), which asserts a one-component source; isinf() of a vector compares each lane with a swizzled vector constant (dEQP-GLES3.functional.shaders.builtin_functions.common.isinf.vec2_*). Read the lane the comparison uses. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 5206d1fc862eea07ea125b3416d0305ecaf2c9f3)
Zink precision shaders leave an absolute half next to a multiply literal, or a negated half comparator selecting f32 results. Preserve half precision and exact IEEE abs/negation through the existing sign-bit legalization, materializing only the unsupported multiply literal form. A new half multiply compiler control fails before the change and passes after; both focused cases and the full graphics compiler suite pass on the M1 Pro. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit fd3280067b964dd7088180056240588cbd417cd2) Generated-by: LLM
VS/TES all-targets image tests reach a bindful 3D image read with register LOD. The native fetch encoder requires coordinate staging for register LOD, but only texture_load selected it for a vertex stage. image_load uses the same native SMP and must select the same staging ABI. The focused vertex image register-LOD fixture fails before the change, passes after it, and the full graphics compiler suite passes on the M1 Pro. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 931439ffdbb5c60724cb3a69b6d80f8625f6a224) Generated-by: LLM
Bring the native descriptor, resource table, program and command-stream paths from mesa-aurora agx3 at 9eafce2 so the follow-up image fixes have their required implementation. Include the existing descriptor and shim regressions. Preserve public Mesa 26.3 configuration, heap limits and capabilities; do not import the CPU transfer fallback or non-fragment half-precision restriction. Source-tree: mesa-aurora@9eafce282ccf Generated-by: LLM
Software vertex and geometry stages communicate through memory between internal compute launches. Strengthen the native ordering barrier after these stages, matching the cache flush already performed by the AGX2 path. Include indirect launches in that contract. Add a Vulkan regression checking transform feedback vertex data and byte-counter resumption across provoking-vertex pipeline changes and direct/indirect draws on four line topologies. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 825f23d)
Allow larger vertex batches to exercise memory passed between software graphics stages, while checking the same capture words, counters and guard values. Bound the command-line sizes and retain small default batches. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 812b484)
Exercise vertex-buffer fetches as well as VertexIndex while changing the first vertex, provoking pipeline and direct/indirect draw form. Keep the source GLSL alongside the embedded SPIR-V so the regression shaders are reviewable. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit f47c47f)
Add an independent Vulkan pixel test for a one-dimensional array image. Clear each layer, draw a distinct signed integer color through a half-width scissor, wait after each mip, and verify every pixel from all levels in one readback. Preserve shader GLSL alongside the generated SPIR-V. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 19ca645)
Record the counter write-to-read barrier in a legacy render pass with the matching self-dependency. Dynamic rendering without local-read features cannot contain that barrier. Keep rasterization enabled and use an empty fragment shader so the pipeline has valid fragment state without unused color outputs. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit e4e3f4e)
Renderpass self-dependencies must order transform feedback and geometry on CDM as well as the render stream. Keep their source cuts and destination requirements local to the pass instance, and close software streams before continuing across the dependency. A render also consumes a pre-graphics stream opened by a counter copy before the draw created the render stream. Add coverage of resumed software captures, exact physical engine prefixes, and both boundaries of the pass-local dependency scope. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 65bc2ee)
Finalizing an empty render can execute its clear on the compute engine. Record in-pass source cuts after finalization so the self-dependency names that physical producer. Cover the replacement with the existing synchronization fixture. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit d42e0a3)
KHR-GL46.shader_image_size.basic-nonMS-cs-int returns zero for its 16-texel buffer image. Its Gen9 native descriptor does not contain the AGX2 logical-size sideband read by the old query path. Publish the view texel count through the existing stage uniform table and use it for buffer imageSize, including robustness bounds checks. Other image dimensions keep their descriptor queries. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit f959be0)
Gallium has 64 image slots and 32 sampler slots. Use the actual table count for buffer-image metadata rather than inheriting the sampler bound. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 8cbdda7)
Gallium exposes 64 image slots, but the binding mask and individual bit operations used 32 bits. Keep all 64 slots. Complement the already-shifted unbind range so an unbind beginning at a nonzero slot preserves lower image slots. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 78d8829)
agx_gallium_pack_native_pbe() said it applied hk_pack_native_pbe()'s gate field for field, but hk has since gained the Gen9 3D and 2D-array mip packets, the layered multisample packet, sRGB and the GPU-tiled compressed 2D packet, all through the same shared agx_pbe_agx3 packers. Gallium kept refusing them, so a 3D or mipmapped array storage image aborted at "storage PBE has no proven native descriptor encoding". Apply hk's gate unchanged. Gallium never compresses on AGX3 (agx_gallium_native_compressed_pbe_supported() stays AGX2-only), so the compressed arm is not reachable from here. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit cd8463d)
The native descriptor test pinned the old AGX3 PBE gate: it expected sRGB on store and a mipmapped 2D array to be refused. Check instead that both, and a mipmapped 3D image, encode on Gen9 exactly as the shared agx_pbe_agx3 packers do and stay refused on Gen10, and that Gallium's agx_g17p_pack_image_atomic_sw() writes the word hk_pack_g17p_image_atomic_sw() does, at the offsets libagx_image_texel_address_gen9() reads. asahi-native-descriptor: 365 checks pass. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit eac2050)
TES preserves its original API stage for sysvals after its NIR is normalized to a vertex shader. The native resource-prefix flag and graphics sampler-pair admission only recognized vertex and compute API stages. A Linux CTS TES image program consequently compiled but the graphics builder returned zero with 24 descriptors and an unset flag. Include TES in the existing vertex resource ABI and its overlap check. A CPU shim replay of basic-allTargets-loadStoreTES changes from a resource-pair rejection to publishing the pair, with no null-program draw drop. Add an image-only TES mode to the existing tessellation probe, requiring the loaded sentinel to produce a green triangle; no API samplers are bound. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 3195b0f)
The Linux image-store/memoryBarrier/image-load CTS case can read an earlier stored value. Image writes get their scoreboard slots from the packer staging allocator after the general slot scheduler, so its device-fence drain misses these issued writes. Retire the actual outstanding slots before the fence and release their staging banks. The compute and fragment regression fails before the change and passes after it; all 428 AGX3 packer tests pass. Compiler regression cases remain in the qualification harness; their original source files and targets were removed from the parent branch. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 355b5e8)
The optimizer folds 16-bit integer extensions into a 32-bit IADD or IMAD as half sources, which have no mixed-width AGX3 form: Zink's int16 shaders failed pipeline creation at imad, and dynamically indexed uniform struct arrays at iadd. Extend each half register explicitly before constant materialization lowers the SIGNEXT: AGX IR plain half sources are signed, abs selects zero extension, and negation and the add's shift stay on the widened operation. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 1cc4de6)
Put the M3 Max (T6031, G15C) on the native AGX3 path beside G15S. It is the same G15 generation with four clusters instead of two: Gen9 descriptors in a 32-byte sampler heap, the G15 command stream, the Gen4 sampler, the classic queue model and the AGX3B encoding. - agx_chip_native_agx3(), agx_chip_native_imageblock() and agx_chip_native_indirect_compute() name G15C, so it takes every G15S choice in Honeykrisp and Gallium. - agx_chip_driver_supported() checks G15C's axes as it does G15S's, and agx_params_driver_supported() requires the exact T6031 parameters: chip 0x6031, one die, four clusters, AGX3 shaders on the legacy HAL. The core masks are not checked, so binned parts are admitted. Both land together, since an unlisted chip would pass the parameter check. - The device loads the G15S build of libagx: G15C executes the same encoding and needs no scheduling stalls. - The CDM barrier packer accepts the wide-visibility form for G15C, which agx_chip_cdm_wide_visibility() asks for on every native G15 part. - A refused G15C names the parameters it expected. Ray-query encodings stay refused on G15C. A new admission test covers both G15 identities and the parameters that must be refused, and the CDM barrier test covers the wide form. Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
On the M3 Max (G15C), half of each compute dispatch and of each draw ran without its uniform state: compute-check got 4096 of 65536 words wrong, and the vk and gl render checks got 2048 of 4096 pixels wrong. Without kernel-side backing for it, the shader cores also faulted reading the page after the USC window base page. The profile prefix ends in a computed helper call. On G15C that call can index past the base page's two ten-entry helper tables for some shader cores, and the slots after the tables were zero, so the call did not return. It ran on through the rest of the page and into the following unbound guard page, and the uniform state it was meant to load was skipped. On the native path every G15 program carries that prefix. Build the base page with agx3_build_usc_base_page(), which on G15C fills every 16-byte slot from +0x2c0 to +0x340 and from +0x350 to the end of the page with the helper table's terminal record, so any such call returns inside the page. The zero block-size dword at +0x340 that ends the page's container chain is left alone. Only G15C is changed; G15S, G17P and every per-shader container get the same bytes as before. A host test checks the page for G15C, G15S and G17P. The same fill was tested on J516C (M3 Max, 40 cores) with the earlier G15C driver, where compute-check, vk-render-check and gl-render-check passed (0 wrong over ~2700-5700 runs each) with no kernel-side page backing. Signed-off-by: Naeem Malik <malik2015naeem@gmail.com>
A coordinate FMA fused into a texture publication writes the sampler-private staging file directly. Its waits come from the resource allocator, which does not model the fixed bank an unpublished sample stages its coordinates into and reads through completion. A fused stage landing on that bank could overwrite the coordinates of a sample still in flight. Retire the conflicting staging readers first, as publications and unpublished samples already do. On J514S this fixes intermittent dEQP-GLES3.functional.texture.units *_units.mixed.* failures (4_units.mixed.2 failed 18 of 25 runs). Signed-off-by: Eryk Wieliczko <eryk@wieliczko.ninja>
…ts only The comparison clamps the border depth to [0, 1] for a fixed-point depth format and uses it unclamped for a floating-point one. Commit "asahi: clamp the border depth of a comparing sampler" clamped it for Z32F too. That is against the spec and no longer changes any result: the border_clamp depth_compare_mode iterations it targeted pass without it on J514S. Keep the clamp for fixed-point depth only. Z24 is still clamped by fixup_border_zs() before its promotion to Z32F. Signed-off-by: Eryk Wieliczko <eryk@wieliczko.ninja>
asahi, hk: G15C (M3 Max) on the native AGX3 path
Widening every half source of a 32-bit square-root step also changed G17P, which already emits Apple's half-input step there (agx3_alu_sqrt_step_half, a 16-bit source with a 32-bit result). Under the drm-shim, dEQP-VK.pipeline.shader_object_unlinked_binary. blend_operation_advanced.ops.color_attachments_4_blend_overlap_conjoint_ ext_nonpremultiplieddst_20 then produced a different G17P shader. That step is grounded only with a cached source and result, and the packer refuses the other forms, which is what the widening fixes on G15. Keep it off G17P, so its output is unchanged from agx3b. Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
Both fail to build with -Dbuild-tests=true on agx3b: - test-hk-sync-prior still asserts the 88-byte compute payload. The ray-query tail made it 136 bytes, matching the kernel's drm_asahi_cmd_compute. Assert the new size and the offsets of the auxiliary allocation, intersection pool and default control. - test-hk-sampler-bias undefines NDEBUG before including NIR, so it declares nir_validate_shader(), which libnir only provides in debug builds; release builds fail to link. Undefine NDEBUG after the includes instead. Assisted-by: LLM Signed-off-by: Diljit Singh <hey@djdev.me>
asahi, hk: G15S (M3 Pro) on the native AGX3 path
This was referenced Nov 21, 2026
DjDeveloperr
added a commit
that referenced
this pull request
Nov 23, 2026
…diate selects On AGX3B (G16G / G17P), native hardware witnesses only pair a uniform comparand in isel with 32-bit register select alternatives ((u < r) ? r : r, (r < u) ? r : r), and in fsel with register or immediate-zero alternatives (never non-zero integer immediates such as the #1/#0 produced by lowering FCMP). Two gaps allowed unwitnessed uniform comparands with immediate selects to pack on AGX3B, silently misexecuting bounds checks and RT/BVH comparisons on live M4 (G16G B0) silicon: - agx3_isel_uniforms_kept() admitted AGX3B uniform comparands without checking reg32[2] && reg32[3], and encode_explicit() in agx3_isel_core.c only rejected uniform select alternatives (tu || fu) beside a uniform comparand while omitting immediate select alternatives (ti || fi). agx3_widen_uniform_compare() amplified this by rewriting 16-bit ICMP(r, u) directly into unwitnessed 32-bit ICMPSEL(r, u, #1, #0). - agx_lower_uniform_sources() admitted AGX_OPCODE_FCMP and FCMPSEL with non-zero immediate selects alongside AGX3B uniform comparands, and agx3_alu_fcmp_select() encoded them even when integer_select was true. Tighten both the uniform lowering pass and the ISA encoders to keep only witnessed AGX3B uniform-comparand select shapes while preserving M5 (AGX3C) encoder-validated uniform lowering, and update the unit tests accordingly. Signed-off-by: Diljit Singh <hey@djdev.me>
AxxzyWasTaken
pushed a commit
to AxxzyWasTaken/mesa
that referenced
this pull request
Nov 24, 2026
A comparison whose comparand is a uniform copied it into a GPR first whenever the comparison itself was not the native select shape, though the native select it lowers to reads the uniform directly: - fcmp(r, u) lowers to fcmpsel(r, u, aurora-silicon#1, #0) in agx_lower_pseudo(). On AGX3B give it the uniform rules of that select: a slot-1 uniform beside a register (f59 = 3), a uniform against an immediate zero (f42 = 3), and a uniform first comparand exchanged into slot 1. - Every native uniform ISEL form writes a 32-bit result, so a 16-bit integer comparison (a boolean) always copied its uniform comparand. When the 32-bit select of the same comparison keeps the uniform, compute that and take its low half. The alternatives are 8-bit immediates or results widened the same way, so the upper half is zero and the low half is the 16-bit result; the split coalesces with the select's register. The decision is the existing ISEL uniform rule, now one helper shared by both paths, and on M5 its encoder query. - A slot-0 uniform comparand of fcmpsel is always exchanged into slot 1, whose field holds half indices up to 511, so admit it up to there. Signed-off-by: Diljit Singh <hey@djdev.me>
This was referenced Nov 24, 2026
Merged
funkzy
pushed a commit
to funkzy/mesa
that referenced
this pull request
Nov 24, 2026
When lowering a single-sample AGX3B sample_mask_agx whose target is a constant with bit 0 set (such as unconditional or alpha-test discard targeting ALL_SAMPLES), sample 0 is unconditionally affected. Previously the backend materialized the constant target, masked it with aurora-silicon#1, widened both target and coverage word to 32 bits, and multiplied them with imad only to multiply the coverage word by 1. Pass immediate 1 directly as the sample_mask_agx3 target (which agx3_pack_binary already accepts on AGX3B) and zero-extend the 16-bit coverage word directly to 32 bits via agx_mov_to(), which packs to a single agx3_encode_zext_half() instruction. This removes 4-5 instructions and a temporary register from single-sample discard shaders on AGX3B. Signed-off-by: Diljit Singh <hey@djdev.me>
AxxzyWasTaken
pushed a commit
to AxxzyWasTaken/mesa
that referenced
this pull request
Nov 25, 2026
Eliminate redundant per-iteration ALU instructions in inner compute loops across AGX/AGX3: - Cancel double IEEE-754 fneg across the preamble boundary in agx_nir_cancel_preamble_fneg() when a preamble slot stores fneg(x) and every main-shader reader only applies fneg or fabs. - Reassociate single-use loop-variant constant-offset equality tests (x + C) == inv / != inv into x == (inv - C) / != (inv - C) in agx_nir_reassociate_loop_invariant_eq(), hoisting the pure integer adjustment directly to the loop preheader for unconditional loop-body blocks (bounded per loop). - Fold single-use boolean xor(fcmp/icmp, aurora-silicon#1) into fcmp/icmp by flipping invert_cond in agx_optimizer_not(). - Rewrite 4-way 16-bit boolean OR trees feeding if_icmp(x, #0, UEQ) in agx_opt_pack_bool_or_branch(): pack single-use leaves into one 32-bit OR over two collected pairs, or rewrite multi-use serial icmpsel chains into a balanced depth-2 16-bit bitwise OR tree without copies. - Allow a 4-half headroom for agx_opt_licm() on dynamic-register-file AGX3 encodings without static register splits so loop-invariant uniform moves hoist cleanly out of hot loops. Signed-off-by: Diljit Singh <hey@djdev.me>
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same ISA is used across M3, M4 and A18 Pro GPUs, but for now this PR only targets G17P i.e. A18 Pro GPU.