Repository navigation
asahi/compiler: zero-extend 16-bit FFS sources on AGX3C instead of undef-padding - #1158
Conversation
…def-padding agx_supports_zext folds u2u32 into AGX_OPCODE_FFS, leaving a 16-bit source whose upper 16 bits are defined to be zero. In agx_lower_m5_alu_operands, widening that 16-bit source back to 32-bit for AGX3's 32-bit FFS encoding called agx_pad_to_32() (collect with undef high half), leaving uninitialized garbage in bits 16..31 and corrupting MSB / clz results. This miscompiled RemoveMSB() in libagx_tess_tri, breaking dEQP-VK.tessellation.invariance.outer_edge_index_independence.triangles_fractional_even_spacing_*. Widen 16-bit FFS sources with a zero-extending agx_mov_to (matching AGX_OPCODE_BITREV) and add NativeForms.AGX3CFfsHalfSourceZeroExtends. Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 31f4cf41f658
Blockers: none
Checked: Read the diff. agx_supports_zext() folds u2u32 into FFS, so the 16-bit source has defined-zero upper bits; widening with a zero-extending move (as BITREV already does) instead of an undef-padded collect is the right fix, and findMSB of the zero-extended value equals the original semantics. AGX3C only, selected by encoding. The new AGX3CFfsHalfSourceZeroExtends test passes in the gate; your CTS A/B shows the 4 tessellation invariance failures fixed. M5-only, so the J716c row is the hardware row.
Evidence
Local Mesa gate (stands in for CI; buildbox x86 docker aurora/hk6356-mesa-x86-tests:local, clang release with asserts, -Dbuild-tests=true -Dtools=asahi,drm-shim, meson test --suite asahi --suite poly):
- base
aurora-wip90211df6816: 335/335 OK. - batch build:
90211df6816with 22 open PR heads merged on top (#1133 #1137 #1155 #1136 #1140 #1157 #1158 #1160 #1164 #1165 #1167 #1168 #1170 #1171 #1172 #1175 #1182 #1183 #1185 #1187 #1190 #1191; each also merges cleanly alone, and into currentaurora-wipd2e883ab2e3): 335/336 OK. The one failure,agx3_cmat_mixed_mma8, reproduces with #1187 alone on the base (329/330) and is caused by that PR's new test; nothing else in the batch fails.
…bases aurora-wip gained #1158's AGX3CFfsHalfSourceZeroExtends test next to this branch's AGX3CCompilePlacesPreambleLoadBasesLow in test-native-form-regressions.cpp. Keep both tests; no code conflict. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
What: Fix a 16-bit
AGX_OPCODE_FFSmiscompilation inagx_lower_m5_alu_operands()that causes 4 Vulkan CTS tessellation invariance failures on M5 (AGX3C):src/asahi/compiler/agx_compile.c&agx_compiler.h:agx_supports_zext()foldsu2u32intoAGX_OPCODE_FFS, leaving a 16-bit source whose upper 16 bits are defined to be zero.agx_lower_m5_alu_operands()previously widened that 16-bit source back to 32-bit for AGX3's 32-bit FFS encoding viaagx_pad_to_32()(collectwithundefhigh half), leaving uninitialized garbage in bits 16..31 and corruptingMSB/clzresults (e.g.RemoveMSB()inlibagx_tess_tri).AGX_OPCODE_FFSsources with a zero-extendingagx_mov_to(matchingAGX_OPCODE_BITREV).src/asahi/compiler/test/test-native-form-regressions.cpp: AddNativeForms.AGX3CFfsHalfSourceZeroExtendsregression test.Tested: J716c Apple M5 Max (
G17C B1, 40 GPU cores), Fedora Remix 44 (7.3.0-40.j716c19.fc44.aurora.aarch64, GCC 16.2.1,--buildtype=release -Db_ndebug=true), at31f4cf41f65vs baseaurora-wip822cf58723a:meson test --suite asahi: 212/212 PASS (0 fail;NativeForms.AGX3CFfsHalfSourceZeroExtendspasses).deqp-vk,MESA_SHADER_CACHE_DISABLE=1,dEQP-VK.tessellation.invariance.{outer_edge_index_independence,inner_triangle_set}.*+dEQP-VK.glsl.builtin.function.integer.findmsb.*, 30 cases):822cf58723a): 26/30 PASS, 4/30 FAIL (outer_edge_index_independence.triangles_fractional_even_spacing_*)31f4cf41f65): 30/30 PASS, 0/30 FAIL (+4 CTS fixes, 0 regressions).SELinux=Enforcing,0failed systemd units,0kernel GPU/DRM/AVC errors.Risk: two-way door · AGX3C (M5). A plain revert restores
agx_pad_to_32(). Non-AGX3C encodings are untouched.Not yet: Full
vk-defaultmustpass sweep.Frozen binary hashes
822cf58723a04967a1b99653f9de72e3d2982487):libvulkan_asahi.soSHA-256d5b7e4582e1b034642e804f6477b070504ad077c2f0a3212989f6ad785228d6831f4cf41f658e37d7ff809815bb82d5b2d6189c6):libvulkan_asahi.soSHA-2564f3934239f6b7b547e51e2af5635ef0f6bf91f329e0587e426d3721cb9ed385f