Repository navigation
M5 series: the agx3c line since #47, the M5 Max and the J813 G17G work - #160
Merged
Merged
Conversation
…vice hk_sync_stream_created() read hk_cmd_buffer_device(cmd)->frame_anatomy unconditionally. The synchronization unit tests build command buffers without a device, so hk_sync_prior_test crashed in its first case and none of the merged synchronization checks ran. sync_m5() already treats a missing device as a fixture. Check for the device first. Every real command buffer has one, so driver behaviour is unchanged. All 2821 hk_sync_prior checks now pass.
M5 shaders always carried the custom-border emulation: every sample of a clamp-to-border sampler duplicated the texture operation behind a branch on the sampler's border kind. The lazy path that leaves the emulation out until the device creates a sampler with a custom (or emulated) border colour, and then switches bound shaders to their emulating twins, was gated to native G16G/G17P graphics. Its late-switch and twin compilation paths are not specific to those GPUs. Enable it on M5. Skyrim SE creates no sampler that needs emulation; its two most expensive full-screen fragment shaders drop from 971 to 707 and from 698 to 436 instructions (79 to 71 registers for the first).
A single-sample RGBA8 render-target-0 fragment shader that exports a straight-line colour from push constants recomputed the colour and ran the separate blend epilog for every pixel. Inline the source-alpha blend epilog into such a shader and move its uniform arithmetic into the constant program, so the per-pixel main is the blend alone. Only shaders that read nothing but push constants, have no control flow and blend RT0 of an RGBA8 single-sample target qualify; everything else is compiled as before. Full-screen 1080p uniform-colour blended fill: 182 -> 125 us.
…lits On M5 a dependency from graphics work to pre-rasterization stages orders a render's vertex half only after the latest render that wrote memory a later vertex stage could read other than through an image (HK_SYNC_GFX_MEM). Two kinds of render were counted although they write only images: - Every transfer render (image copies, depth/stencil copies, clears recorded as render passes), regardless of what it wrote. - Every render into a swapchain image, because WSI creates those with VK_IMAGE_CREATE_ALIAS_BIT. Swapchain memory can be aliased by images only, never by a buffer. DXVK records a global memory barrier ahead of nearly every pass, so in Skyrim SE each frame's present blit and depth copies became a cross-submission prior on every later render's vertex half. That prior cannot ride with fragment-only header barriers, so every render was submitted fully ordered after the previous one and no tiling ran under earlier fragment work. A transfer render is now marked by the draws it records when they write other memory (shader stores, linear or aliased attachments), like any render, and swapchain images no longer count as aliased attachments.
A dependency whose source scope includes transfer work kept the transfer class in the vertex half's requirement on the render queue, so a later render's tiling still waited for every earlier transfer render, from this or an earlier submission. Transfer renders that write memory other than their attachments are now tagged HK_SYNC_GFX_MEM like any other render, so narrow the transfer class there exactly as the graphics class. Skyrim SE: 618 of 4434 sampled renders now carry fragment-only barriers (none before). 78,289 synchronization/barrier/copy/query CTS cases: 0 failures.
A buffer upload that the raw tiled copier refuses reaches the graphics upload. On M5 it rendered colour destinations through the image's own format, while image copies and readbacks already use the bit-exact integer alias (the compressed copy format for a compressed image). A normalized view canonicalizes what it copies: SNORM -1.0 has two encodings, so 0x80 came back as 0x81. Select the same alias for M5 colour uploads as for G17P. Depth and stencil keep their existing per-plane views. dEQP-VK.image.queue_transfer.* with compressed SNORM8 destinations: 8 failures -> 0 (1335 pass).
M5 compressed a colour image only when it was a colour attachment, so a sampled texture uploaded with vkCmdCopyBufferToImage and every transfer-only image stayed plain. A transfer destination is already made renderable at creation, and every write to a compressed colour image goes through the PBE paths (uploads, copies, clears, blits), the same ones a compressed attachment uses. Admit colour attachments or transfer destinations, with the existing format, layer, sample, mip and usage restrictions unchanged; shared and WSI images stay plain. gpubench copy.bw kind=buf2img (64 MiB into a 4096x4096 RGBA8 image): d1 868/862 -> 454/447 us, d4 706/706 -> 275/274 us.
M5 fragment shaders that export a uniform colour now keep their NIR, as G17P inline-blend shaders do, so a fast-link can build the uniform-blend variant. Serialization writes that NIR, but deserialization still accepted it only on native AGX3 and refused every such M5 binary as incompatible: binary shader objects and pipeline libraries built from them failed to load. Accept the section on M5 too. dEQP-VK.pipeline.shader_object_*_binary and related cases: 357 failures -> 0.
D3D float-to-integer conversions saturate and map NaN to 0. DXVK emits them as a conversion followed by clamping selects (signed: v > 2147483520.0 -> INT_MAX, v < -2147483648.0 -> INT_MIN, NaN -> 0; unsigned: max(v, 0) converted, v > 4294967040.0 -> UINT_MAX), and every such conversion costs three compares and three selects. The M5 conversion instructions already have exactly these semantics: on hardware, f2i32 saturates both ways and returns 0 for either sign of NaN, and f2u32 clamps to [0, UINT_MAX] with NaN -> 0. Native compiles of the same shaders use the bare conversion. Fold the DXVK sequences into it on M5. Skyrim SE pipeline cache (37,318 executables): instructions -0.49% (vertex -3.4%), preamble instructions -1.6%, GPRs -1.1%.
DXVK orders most passes after the previous one with global memory and image barriers. hk already resolves the narrower prefix the vertex half of such a render needs (dep_ta), but could hand it to the kernel only when that prefix had no render part at all (FRAGMENT_BARRIERS) or differed in its compute part alone. Everywhere else the vertex half waited for the whole prefix, so a render's tiling started only after the previous render's fragment work: in Skyrim SE 84% of the renders of a frame tiled strictly after the previous render, with tiling and fragment work overlapping 0.3% of the time. Kernels with DRM_ASAHI_FEATURE_RENDER_STAGE_PREFIXES take both tiling prefixes in the command tail (drm_asahi_cmd_render_with_stage_prefixes). Send them for every render whose vertex half needs less than the whole render, and rebase them like the header's when a submission is split. Skyrim SE (Riverwood, 3024x1964 Ultra): 55.9 -> 60.9 FPS, p99 frame 27.5 -> 17.6 ms; tiling/fragment overlap 0.3% -> 25% of the frame.
The kernel orders renders that write the same attachments without a dependency between them, because the stores of partly covered tiles also write pixels outside the render area. When the render area is the full extent of every attachment there are no such pixels: flag those renders (DRM_ASAHI_RENDER_WHOLE_ATTACHMENTS) so the kernel can leave two of them unordered. hk splits one API render pass into several streams (continued passes). Those carry no barrier between them and rely on the kernel ordering renders that write the same attachments, and each piece also covers the full extent. Flag only a stream that begins and ends its pass: flagging the pieces let them run unordered, and CS2 hung in 2 of 3 runs. CS2 High: 4 of 4 runs clean (73.9-74.5 FPS), no scheduler timeouts. gpubench render.light, one image from several queues: d4 145 -> 34.6 us per submit, d8 153 -> 32.6 us.
The G17G texture unit bounds the 16-bit layer it receives to the view, the way G17P does: on hardware, samples of 2D array views (12 layers, and 2 layers at base layer 1) and of cube array views (2 cubes, and 1 cube at base layer 6) return the correctly clamped layer for layers 0..9, 100, 4095, 65535, 100000, 1e9 and negative ones, and texel fetches past the view's last layer return zero. Only the 16-bit truncation escapes the clamp: layer 65536 reads layer 0. So drop the software layer clamp, which decodes the texture descriptor for every array sample, on G17G as on G17P, and saturate the float layer to 65535 before truncating it on both. Without image robustness an out-of-range texel fetch layer only has to stay memory safe, so the txf layer check that moved such a layer to coordinate 0xFFF0 is only needed for robust images there. SCP:SL pipeline cache: preamble instructions -5.7%; HDRP deferred lighting kernel 4094 -> 4027 instructions.
M5 lddev and stdev add a signed 16-bit byte offset after scaling the register index, and native G17G code reads struct members and constant array elements through it (offsets of 16, 32, 48 ... 1696 bytes in the SCP:SL HDRP lighting kernel). We had no offset, so every such access computed `index + constant` with ALU first: 285 more iadds than native in that kernel. Carry the offset in bits 16..31 of the load_agx/load_constant_agx/ store_agx BASE index and on the IR as memory_byte_offset, and let agx_nir_lower_address split it out of the matched index when that cannot change a valid address: - a sign-extended index: sext(x + c) = sext(x) + c for any valid index; - a zero-extended index whose remainder is a sum of nir_lower_explicit_io amul products, with c >= 0: each product scales an array index that is nonnegative for a valid access, and UBOs and SSBOs are limited to INT32_MAX bytes, so the sum cannot wrap; - an array index i + c scaled by amul, which is likewise below 2^31 / stride for a valid access, so (i + c) * stride = sext(i) * stride + c * stride. A power-of-two stride also moves into the index scale where the hardware shift allows. Other zero-extended indices may be negative (a reversed index N - i folds to c + -i) and are left alone. SCP:SL pipeline cache: instructions -1.41%, code size -1.9%, 1061 shaders helped, none hurt.
M5 fragment samples already read their texture and sampler handles from a pair of aligned 64-bit uniforms. Compute samples still copied both handles into GPR pairs first: four moves per sample site, 57 of the 128 uniform-to-register copies in the SCP:SL HDRP lighting kernel. Native G17G compiles of those kernels read the handles straight from uniforms in compute too (both handle-kind fields clear on 54 of their 64 samples, against none of ours). Forward the pair in compute shaders as well. SCP:SL pipeline cache: compute instructions -1.6%. Compute-sampled 2D, 2D array and cube array reads verified on hardware.
Native G17G code selects constants such as 1.0 or 2.0 straight from a minifloat immediate (fself32: 102 of them in the SCP:SL HDRP lighting kernel), while we materialized each one with a mov_imm. Our FCMPSEL encoder already composes that form for selected minifloats; the optimizer just never produced one, because select immediates are raw integer bits and most of these selects only become FCMPSEL when the compare is fused into them, after immediate inlining. Fold a minifloat-exact f32 constant into one selected operand of an M5 FCMPSEL, opposite a register, both while inlining immediates and after compare-select fusion, and mark the instruction so the packer, CSE and the constant-compare fold read it as a minifloat. Pipeline caches: Skyrim SE instructions -0.05%, GPRs -0.5%; SCP:SL instructions -0.04%.
…orage Letting a render's tiling overlap the fragment work of earlier renders corrupts the state its pre-rasterization programs keep in thread-private storage: in Counter-Strike 2, renders whose vertex constant programs take their inputs in a thread-private frame (or whose vertex programs spill) show one-frame garbage geometry and blocks whenever their tiling started before an earlier render's fragment work ended, and only then. Renders whose vertex programs keep no such state, and fragment programs that do, overlap without corruption. Mark a render whose pre-rasterization program publishes primary storage, a spill frame or constant-program frame, and keep its vertex half on the whole render-subqueue prefix. Its compute prefix may still narrow.
Unbounded storage-buffer reads reach hk_lower_nir as load_global, which nir_opt_sink was not asked to move. Large M5 compute and fragment kernels then load whole structs up front and carry them across branches that do not read them, where they are spilled. Sink the reorderable ones like the bounded and constant loads. nir_opt_sink only moves loads that may be reordered and never moves them into or out of a loop. Host shader-db (M5 profile), SCP:SL: instructions -0.25%, spills -6.28%, fills -12.12%, GPRs -0.09%; Skyrim and CS2 unchanged.
A value an M5 device load produced, or one component of it, is spilled and filled like any other, although the load could simply be repeated: one load replaces a fill per component, and once no fill reads the slot DCE drops the spill stores as well. Repeat the load only when nir_opt_access proved that nothing writes the memory and the access is not volatile (ACCESS_CAN_REORDER, which allows rematerializing it) and it is not coherent, so the repeated load yields the value of the original anywhere that value is live. Its register sources must be in the register file at the reload by the spiller's own register file sets: before an instruction, those it holds there, and on an edge, those held on both sides. The reload then never extends a live range, so the spilled program's register demand is unchanged. agx3_order_fragment_device_loads keeps adjacent fragment loads of one base at immediate indices ascending. Reloads can put such loads next to each other again, so restore the order after RA where two adjacent loads are independent. Host shader-db (M5 profile), SCP:SL: instructions -0.15%, spills -8.41%, fills -9.02%; Skyrim and CS2 unchanged.
Accesses to one element of an array of structs reach M5 address lowering as amul(i, stride) scaled by whatever power of two the member's offset allowed, so a 240-byte light struct read at 16-, 8- and 4-byte aligned members computes i * 15, i * 30 and i * 60 separately and keeps all three live. The index scale has room for up to two more doublings than the element size, and the bounds that let a power-of-two stride move into the scale hold for any power-of-two factor of the stride. So an access may use i * (stride >> t), scaled by t more, which lets those members all use i * 15. Only take a multiple the program already computes before the access to address memory with: a fresh one would be merged with any equal value, which may be computed far away for another purpose and would then stay live up to the access (that cost CS2 compute shaders an occupancy step). Host shader-db (M5 profile): SCP:SL instructions -0.23%, spills -4.25%, fills -2.71%, GPRs -0.01%; CS2 instructions -0.11%, spills -0.96%, fills -0.61%, no occupancy lost; Skyrim instructions -0.00%.
nir_opt_licm hoists every invariant instruction of a loop, and each hoisted result the loop still reads stays live across all of it. DXVK compute shaders that address hundreds of shared-memory taps from one invariant base then carry hundreds of hoisted addresses through a loop whose accumulators already fill the register file, and fill them from spill slots on every iteration, which costs more than the additions hoisting saved. One Skyrim compute shader spills 1350 values that way. Estimate each loop's peak register demand from NIR liveness, in 16-bit halves and without constants and preamble values, and the demand that the hoisted values the loop reads add to it. Run nir_opt_licm only if every loop still fits the file a workgroup allows, less what spilling reserves. Host shader-db (M5 profile), Skyrim: spills -67.69%, fills -64.76%, instructions -0.11% (compute -3.99%), GPRs -0.03%, 33 shaders helped; SCP:SL and CS2 unchanged.
Repeating a device load to reload its spilled result works just as well for arithmetic that reads nothing but its operands: when those operands are in the register file at the reload, one instruction recomputes the value in place of a fill, and the spill stores go once no fill is left. Generalize the load reloads into reloads that repeat the defining instruction, and let M5 additions, multiplies, fused multiply-adds, selects, shifts, bitfield and bitwise operations and conversions qualify. Texture coordinate producers stay paired with their sample. Host shader-db (M5 profile), SCP:SL: spills -9.54%, fills -5.09%, instructions -0.08%; Skyrim spills -0.06%; CS2 unchanged.
A structure read member by member issues one device load per word unless NIR vectorized it, and NIR cannot: each member's address is base + u2u64(x + c) until address lowering, and if-conversion may only bring the reads into one block afterwards. Lowered, those loads share base, index and scale and differ only in the byte offset the hardware adds after scaling, so one vector load reads the same words at the same addresses. In fragment shaders, merge register-indexed loads of two or four consecutive words that sit close together, with no memory write, atomic, barrier or discard between them, into one load at the first of them. Words a phi reads stay scalar so they can land in the phi's register; three words would take a four-register slot, and vertex and compute shaders, which often sit just below an occupancy step, are left alone. Host shader-db (M5 profile), SCP:SL: instructions -0.04% (596 helped, none hurt), GPRs unchanged; Skyrim and CS2 unchanged.
The M5 acceleration-structure profile set VK_KHR_pipeline_library to
whether ray tracing pipelines are exposed. Without the ray-query assets
that cleared it while VK_EXT_graphics_pipeline_library, which requires
it, stayed advertised, so every device creating graphics pipeline
libraries failed with VK_ERROR_EXTENSION_NOT_PRESENT. Only add it there.
Fixes 80 dEQP-VK.pipeline.{pipeline_library,fast_linked_library}.blend.
dual_source.multi_attachments cases run without the ray-query assets.
A fragment sample that terminates its f156 group releases the quad's helper lanes. On M5 a lone implicit-LOD sample followed by dfdx/dfdy terminated the group, so helper lanes never produced the sample result and derivatives of it read zero from them. Leave the group open in that case on M5 as well, as already done for G17P. Fixes dEQP-VK.glsl.helper_invocations.load_from_texture. No status change over 54,535 derivative, texture, gather and quad cases.
M5 advertises residencyNonResidentStrict, but unbound pages of a sparse buffer's writable alias were backed by the shared scratch page, so reads returned what any other unbound page had received. With soft faults, an unmapped page reads as zero and drops stores, so leave the writable alias unmapped and keep only the zero-page read-only shadow. A dropped store stays visible in the cache to a later read of the same address, so storage-buffer stores and atomics still check the residency map, but only for bindings the shader also reads. Strict residency is advertised only when soft faults are enabled. Fixes 11 sparse_resources.buffer cases, including the strict null-address descriptor reads and the strict copy-destination and read-write cases. All 19,078 sparse_resources cases pass or are unsupported. On the SCP:SL pipeline cache this leaves fragment and vertex shaders unchanged and adds 5% static instructions to 48 compute shaders, with no new spills.
A compute stream that links out of its root reported a fixed 64 KiB range to the kernel. Report the size of the root that was actually allocated instead.
Use 32 KiB graphics roots, as G17P does, and 16 KiB compute roots on M5; longer streams link on as before. The first tessellation or geometry draw of a command buffer opens two compute streams, and two 64 KiB roots did not fit beside the command buffer's other uploads, so that draw allocated two new command BOs.
As on G17P, write each recycled command BO once at creation so that recording does not take first-write faults in the middle of a draw.
The G17P device already uploads these internal kernels at creation. Do the same on M5, including the immediate-write kernel that resets the geometry heap, so the first tessellation or geometry draw does not build and upload them.
The logic op only selects a different fragment epilog when it is enabled. Keying on it otherwise splits identical epilogs, so a program linked for one disabled logic op was not found for another.
G17P links a complete VS+FS pipeline's fragment shader with its epilog at pipeline creation. On M5 that link is a full compile too (inline blend), and every vertex prolog is compiled on first use, so the first draw of each program compiled on the recording thread. Do the prelink on M5 as well, also for tessellation and geometry pipelines, and with the depth and stencil attachments the pipeline fixes. Link vertex shaders that read no attributes for every vertex input state they can be drawn with, since their prolog does not depend on it. Shader objects get their fragment shader linked for the most common state: one RGBA8 target, one sample, no blending. With the preceding changes, the first tessellation and geometry draw of a shader object set on M5 records in 52 us instead of 199 us, 40 us on later sets.
A pipeline runs its vertex shader as the hardware program unless tessellation or geometry follow it, so link only that program for it. Shader objects may be drawn either way and still get both.
The kernel publishes M5 timestamps after a command completes and holds back later compute that might read them. Mark every control stream that records a query copy or reset, and send DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS on the others when the kernel supports it, so they do not wait. gpubench query timestamp overhead at depth 16 drops from 91 us to under 1 us per submit. In the unified uAPI the feature takes bit 30 (bit 28 is DRM_ASAHI_FEATURE_COMPUTE_RESOURCES there) and the flag bit 17, after the other M5-only compute flag.
M5 compression is channel-aware: an image decodes only through the class it was written with. The end-of-tile store of an R11G11B10 target wrote its packed tile word through an R32_UINT PBE, so a compressed target read back as zero and these targets were never compressed. On M5 the end-of-tile block store now reads that word in the packed-float tile format and stores it through an R11G11B10 PBE, which keeps the image's own class. The tile contents and the fragment shader's packed store are unchanged. Admit B10G11R11 to the M5 colour and storage compression shapes. G17P keeps the raw word. SCP:SL keeps its three full-resolution G-buffer targets in R11G11B10: native-resolution gameplay goes from 66-68 to 70 FPS on one view and from 75 to 87-89 FPS on another. All 11,122 b10g11r11 CTS cases pass or are unsupported.
The M5 Max (T6050, four clusters) reports G17C. Treat it as an M5 chip in agx_chip_g17_m5(), accept it in the M5 bring-up gate alongside the M5 and M5 Pro, and give it the M5 shader-binary version. It stays outside agx_params_driver_supported(), like the other M5 chips. The profile-loader immediate of M5 programs (vertex, fragment, compute and tile) takes the G17S multiplier on G17C. The value was chosen by testing: x1 and x2 render correctly and pass the compute tests, while scaling with the cluster count (x4) drops the trailing draws of multi-draw passes. x2 is kept so G17C matches G17S. G17G and G17S behaviour is unchanged. The unit tests now cover G17C in the M5 program tests and the bring-up gate, and also a four-cluster container lead. Tested on a J716c with zink on honeykrisp: an 867-frame Hyprland trace replays frame by frame identical to a fully synchronized run, repeatedly, and local Vulkan compute and coherency tests pass. Developed with Claude Code.
The M5 was admitted only with ASAHI_M5_BRINGUP=1 set. The kernel now has an M5 backend that reports the exact contract the driver implements (T8142, G17G, one die and cluster, AGX3 USC, HAL300), so admit the device by that identity alone, and drop the message every client printed on stderr. [Ported onto aurora-wip: the target's M5 bring-up predicate also admits G17S and G17C, so the exact G17G contract becomes a separate agx_params_m5_supported() and only G17G skips ASAHI_M5_BRINGUP. The target already advertises timestamp queries and has no shim raster-state test or M5 READMEs; the test change goes into test-chip-admission.c.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
memcpy_small() walks the linear box row by row and reads the tiled image one element at a time in Z-order, which is very slow on write-combined GPU memory. For 32-bit formats with tiles of at least 4x4, read each fully covered tile in order, one 64-byte 4x4 block at a time. Partially covered tiles keep memcpy_small(). Bit-identical to the original over 2400 random layouts and boxes; a 2560x1600 RGBA8 glReadPixels on the M5 goes from 109 ms to 35-40 ms. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The store direction of the fast detile: gather each 4x4 block of a fully covered tile from four linear rows and write it as one in-order 64-byte line. Bit-identical to the original over 2400 cases. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The generic path calloc'd a staging copy of the box per upload (33 MB for a 4K frame), filled it and tiled it on unmap. Tile directly from the caller for twiddled uncompressed levels; depth/stencil and MSAA keep the transfer helper. A 4K SHM frame upload on the M5 drops from 13.4 to 6.9 ms. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Chromium (Skia over ANGLE) on the M5 lost 73 of its 105 GL programs: the G17G packer refused them, and text, icons and shadows were never drawn. - Float control-flow compares: G17G only has the f32 register pair form; every immediate, half and modifier form is G17P-only. Rewrite IF/WHILE/ BREAK_IF_FCMP operands into that shape before RA (exact f32 constants, widened halves, IEEE sign-bit ABS/NEG). Only shapes that were refused change. - When the packer still refuses a G17G function, compile it once more with float constants kept in registers and a pre-RA legalization of FADD/FMUL/FFMA/FCMPSEL/FCMP: exact register constants (selected values bit-exact, not as floats), mixed half/f32 operands computed at f32, half-destination selects run as the witnessed 32-bit select (bits zero-extended, low half kept), and the unwitnessed LTN/GTN as the negated ordered GE/LE. fadd(x, -0.0) conversions are left alone. Shaders that encode on the first attempt are unchanged. Captured Chromium programs (MESA_SHADER_CAPTURE_PATH): 32/105 linked before, 105/105 now. One draw-time fragment variant still needs the G17G R8/RG8 framebuffer-fetch tile load, which has no witness yet. [Ported onto aurora-wip: only the second-attempt lowering and retry are ported; the target already legalizes AGX3C float branch compares in agx_lower_agx3_cf_constants and encodes their half, negated, absolute and zero forms. The retry runs through the target's attempt wrapper, skips the NIR output passes the first attempt already applied, and also keeps the target's M5 minifloat select fold off.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…m registers The staging COPY of a texel-fetch coordinate carried a last-use hint even when the coordinate stays live (AGX3C), so the GPU dropped the register and a second fetch with the same coordinates read garbage (WebRender tile text clipped). Hint last use only when the source is really discarded. G17G has no grounded encoding for fcmpsel with register comparands and immediate 1/0 selects, which post-RA FCMP lowering produced (WebRender box-shadow FS refused). Lower such FCMPs before RA to an fcmpsel between registers holding 1 and 0, narrowing to a 16-bit destination afterwards. [Ported onto aurora-wip: only the second-attempt FCMP select is ported; the target's AGX3C texel-fetch coordinate COPYs already carry the real last-use hint (agx3_tex_coord_discard).] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The compact G17G f32mul/f32fma baselines are Apple specimens whose f46/f29 (and f63) mark every source as last use, so any value read by a plain register multiply was dropped afterwards. In a loop the invariant factor died after the first iteration: WebRender cs_blur coefficients became zero and every blurred box shadow, filter: blur and inset shadow vanished. Encode these through the hint-aware form, which writes the lifetime fields from the real source hints. An unfused signed ICMP with a 16-bit result (a loop counter compare) has no grounded G17G select; compare into 32 bits and narrow. [Ported onto aurora-wip: only the second-attempt signed ICMP widening is ported; the target already sends plain AGX3C FADD/FMUL/FFMA through the hint-aware agx3_alu_float_reg, which writes f46/f29/f63 from the real source hints instead of the specimen's last-use bits.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
GTK 4's Vulkan vertex shaders select 16-bit values on a 32-bit signed compare (`x < n`), and G17G grounds no compare-select with a half result for the signed conditions, nor one with an immediate comparand or immediate selected values: every GTK vertex pipeline failed with "cannot encode vertex shader for G17G". On the second (register-constant) attempt, select between 32-bit registers into a 32-bit temporary and narrow it, as already done for the unfused signed ICMP: the selected values are bit patterns and are zero-extended, an immediate comparand takes the width of the register it is compared with. GTK's vertex shaders now compile; its Vulkan renderer still stops at the M5 draw profile. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Second-attempt lowerings for shapes G17G has no grounded form for: - An integer compare-select with a half result and half comparands (mediump `a < b ? 1 : 0`, registers or uniforms): widen the comparands, sign-extended for the signed conditions (SEQ too, so an immediate comparand extends like the register) and zero-extended otherwise, then select at 32 bits and narrow. Sign extension is sext(x) = (zext(x) ^ 0x8000) - 0x8000, as SIGNEXT is lowered. All operands are checked before any is rewritten. - A half fabs/fneg, fadd(h.abs/.neg, -0.0) into a half: only the sign bit changes, so AND 0x7fff, XOR 0x8000 or OR 0x8000 with the 16-bit bit operations G17G encodes. GLES3 functional.shaders: 18205 -> 18646 of 21935 pass. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
More second-attempt lowerings: - An unfused integer compare with half comparands into a half boolean becomes a half 0/1 select after RA, which G17G cannot encode under any condition: compare 32-bit extensions (signed or zero, as for the compare-select) into a 32-bit temporary and narrow it. - A compare-select whose first comparand is an immediate: swap the comparands and mirror the condition, then widen as above. - `imm - x` at 32 bits, which has no form with the immediate first: put the immediate in a register (sign-extended unless .abs marks it zero-extended); register subtraction is witnessed. GLES3 functional.shaders: 18646 -> 19838 of 21935 pass (90.4%); refused fragment shaders 1278 -> 528, vertex shaders 652 -> 187. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
dfdx/dfdy with a half source and result have no grounded G17G form; on the retry, differentiate the exact f32 extension and round the result back to half. GLES3 functional.shaders.derivate: 172 -> 314 of 612. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Two more retry lowerings that only move the sign bit: - a half multiply of two absolute sources: multiply and AND 0x7fff; - fadd(-x, -0.0) from f32 into a half: convert x, then XOR 0x8000. GLES3 functional.shaders: 19983 -> 20001 of 21935 pass. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
G17G grounds only the 32-bit integer to float conversions (to f32 and to f16); the byte and half forms are G17P's, so every vertex prolog fetching byte, short or fixed attributes was refused and its draw dropped. On the retry, extend the source to 32 bits (zero extension, masked to the byte for U8; sign extension as (x ^ m) - m, m = 0x80 or 0x8000) and convert that. GLES2 functional.vertex_arrays: 380 -> 559 of 571. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Retry lowerings for forms G17G does not encode: - a 32-bit select on half comparands (bool == in vertex shaders): compare the 32-bit extensions - 32-bit a & ~b (bitfieldInsert): XOR the cleared source with ~0, AND - |a| * |b| as HMUL, not only FMUL: multiply, then AND 0x7fff - f32 -> f16 of |x| and -|x|: convert, then AND 0x7fff / OR 0x8000 bitfieldReverse uses the G17P shift and mask sequence, with immediate shift counts on G17G. CTS on the M5: GLES2 shaders.operator 2917 -> 2949/2949, shaders.functions 264 -> 268/271; GLES31 builtin_functions.integer fragment 30 -> 51/176, vertex 30 -> 54/176 (the rest write integer or multiple render targets). [Ported onto aurora-wip: only the second-attempt lowerings are ported; the target keeps AGX3C's native BITREV, and agx_g17p_ushr_imm() serves only AGX3B paths there.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
- i2i32/i2i16 of a byte: G17G has no half-register shift pair, so widen to 32 bits and sign-extend with constant 32-bit shifts (G17P's shape). - The retry lowering of byte/half integer -> float conversions accepts any rounding mode where the result is exact (to f32, or a byte to f16), and converts with RTE: S8 attributes arrive with RTZ. - Normalized 16-bit device loads (UNORM16/SNORM16 vertex attributes): no device format or witnessed 16-bit normflt on G17G. Load raw halves and normalize with arithmetic, c / 65535 and max(c / 32767, -1). CTS on the M5: GLES2 vertex_arrays 559 -> 571/571, GLES3 vertex_arrays 959 -> 988/1005. [Ported onto aurora-wip: only the retry's rounding change is ported; the target's AGX3 normalized 16-bit loads use the native 16-bit normflt, and its byte sign extension already runs through 32-bit shifts on AGX3C.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A fragment shader sampling two textures with the same varying returned the corner texel from both: the first sample, which leaves the coordinate vector live, is packed with a different source form, and that form reads wrong coordinates on G17G. Samples that consume their coordinates are correct. Before register allocation, give each sample whose coordinate vector has another use a private copy that it consumes. CTS on the M5: GLES2 fbo.render.color.mix 0 -> 12/12, GLES3 fbo.color.tex2d 0 -> 35/36. Against t27 over GLES2 texture/shaders/fbo and GLES3 texture/shaders/fbo/blend: +12 and +41 Fail->Pass. The few Pass->Fail cases (texture.units 8_units, msaa derivatives) are order-dependent: they give the same result on both builds when run alone. [Ported onto aurora-wip: the pass is gated on the G17G chip rather than the AGX3C encoding, which the target shares with G17S and G17C, and runs after the target's (AGX3B-only) implicit coordinate staging pass.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Blending into an RGB565 target reads the tile with a three-channel ld_tile (mask 0x7), which G17G has no form for, so the fragment program was refused. Load all four channels and keep the first three. (Tried earlier, it gave wrong images while RGB565 was still stored with the wrong end-of-tile class; with 0x15 it is correct.) CTS on the M5: GLES2 fbo.render.*rgb565* 15 -> 21/43, GLES3 fbo.color.blend 12 -> 13/14, GLES3 fbo 1697 -> 1702/2079; blending and shaders unchanged. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Gallium refused linear PBEs on anything but Gen9. The macOS G17G driver's write descriptor for a buffer-backed RGBA8 texture, read from its descriptor heap (256x64 stride 1024 and 2560x1600 stride 10240), is agx_pbe_agx3_2d_pack()'s Gen10 linear layout bit for bit. Admit one-level 2D linear on Gen10: rendering straight into a LINEAR scanout dma-buf works. [Ported onto aurora-wip: the target's Gallium has no M5 render path, so this only aligns its Gen10 linear gate with hk_pack_native_pbe(), which already admits one-level Gen10 linear 2D.] Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The macOS workflow came from upstream Mesa, which has since dropped it. It asked for the retired macos-11 runner, so every run was cancelled, and it built only swrast and zink, so it never exercised this tree's drivers. Replace it with a job that builds the Asahi Gallium and Honeykrisp Vulkan drivers with their tests in a Fedora container on a 64-bit Arm runner and runs the asahi test suite. Signed-off-by: Diljit Singh <dj@aurorasilicon.org> Assisted-by: Claude Opus 5.5
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.
Summary
aurora-wip already carries the M5 tree from #47, but as one snapshot commit. This branch adds what landed on the M5 line after that snapshot, as a linear series on top of aurora-wip 05ddb00:
agx3c, d41d1a34..d3c8612fThe M5 line part covers compression (R11G11B10 targets, transfer destinations), render tiling prefixes, whole-attachment renders, uniform-colour blended fragments with their own constant program, compiler work (uniform texture handles in compute, spill reloads, fragment load merging, FCMPSEL minifloat immediates), program prelinking, and smaller fixes. Authorship of every commit is kept.
Against aurora-wip
These are the places where aurora-wip had moved since the snapshot:
g17p_layout). Both stay: M5 uniform blend links through its variant source, and every other inline-blend program keeps the G17P path. The AGX3 shader binary version goes from 36 to 37.hk_query_oq.c). A merge fixup for the packing test was also already upstream.uAPI
New flags go into the unified layout aurora-wip already uses (the aurora-silicon kernel's):
t6050-gpuFEATURE_RENDER_STAGE_PREFIXES, render flagSTAGE_PREFIXESFEATURE_WHOLE_ATTACHMENT_RENDERS, render flagWHOLE_ATTACHMENTSFEATURE_COMPUTE_NO_QUERY_ACCESS, compute flagNO_QUERY_ACCESSBit 28 is
FEATURE_COMPUTE_RESOURCESin the unified layout, and M5-only compute flags start at 16 (USES_MATRIXis 1<<16), so the no-query pair moves. The aurora-silicon kernel implements none of these three yet. Mesa checks each feature bit before setting a flag, so they stay off until the kernel defines them at these values.The
t6050-gpukernel that runs the M5 Pro and Max still uses the older layout throughout (FEATURE_COMPUTE_MATRIX12,USES_MATRIX1<<1, against 20 and 1<<16 here). That predates this PR: aurora-wip already disagreed with it.J813 work that did not come over
ASAHI_M5_BRINGUP), the fast CPU tiling andtexture_subdatawork, the second compile attempt for shaders the AGX3C packer refuses, and private texture coordinates on G17G.In six places Thomas's J813 results disagree with the evidence this tree is built on, and the tree's behaviour was kept. They need a J813 run to settle:
Testing
texture_subdatachanges are generic and change GL uploads and readbacks there, and the inline-blend merge touches the G17P program path.CI
.github/workflows/macos.ymlcame from upstream Mesa, which dropped it. It asked for the retired macos-11 runner, so every run was cancelled, and it never built these drivers. It is replaced by a job that builds the Asahi drivers with their tests in Fedora 44 on a 64-bit Arm runner and runs the asahi suite.GitHub has not started any Actions run on this repository since 2026-10-24: the push of this branch created no Actions check suite, although Actions is enabled for the repository and the organization's private repositories still run. Someone with org admin access needs to look at that before this or any other PR here gets checks.
🤖 Generated with Claude Code