Repository navigation
borealis: use AGX_MIP_FILTER_NONE for fixed LOD-0 nearest-mip samplers - #956
Conversation
When mipmapMode is NEAREST with minLod == 0, maxLod == 0, and mipLodBias == 0, the sampled level is identically 0; packing AGX_MIP_FILTER_NONE avoids unnecessary mip selection overhead. Signed-off-by: Diljit Singh <hey@djdev.me>
satchlj
left a comment
There was a problem hiding this comment.
Verdict at dd2989710329
APPROVE — Clean, surgical +6/-1 change in pack_sampler() (src/asahi/vulkan/hk_sampler.c) that packs fixed LOD-0 nearest-mip samplers (mipmapMode == VK_SAMPLER_MIPMAP_MODE_NEAREST && minLod == 0.0f && maxLod == 0.0f && mipLodBias == 0.0f) with AGX_MIP_FILTER_NONE. Live Apple M5 Max (G17C B1) hardware verification confirms AGX_MIP_FILTER_NONE is bit-for-bit identical to AGX_MIP_FILTER_NEAREST for fragment textureQueryLod (both clamped level 0.0 and unclamped lambda), magFilter != minFilter minification/magnification selection, explicit shader bias/textureLod, and anisotropy.
Blockers
None.
Checked
- Full
+6/-1diff insrc/asahi/vulkan/hk_sampler.cand allAGX_MIP_FILTER_NONE/mip_filterconsumers:hk_pack_native_sampler()(src/asahi/vulkan/hk_native_sampler.c) acceptsAGX_MIP_FILTER_NONEacross Gen4, Gen4 HAL200, and Gen5 descriptors.hk_d3d_nearest_mip(hk_sampler.c:265-268) addsHK_D3D_NEAREST_MIP_BIAS(1/64) tod3d_info.mipLodBiasbefore callingpack_sampler(), so D3D nearest-mip samplers havemipLodBias != 0.0f, remainAGX_MIP_FILTER_NEAREST, and stay consistent withhk_nir_lower_descriptors.c:1348.- Compute-stage
lower_compute_lod_query()and Gen4lower_gen4_biased_lod_query()(hk_nir_lower_descriptors.c:1339,1419) select level0.0forAGX_MIP_FILTER_NONEwhile preserving unclamped lambda, matchingnearest(clamp(lambda, 0.0, 0.0)) == 0.0.
- Isolated release build (
-Dtools=drm-shim -Dbuild-tests=true), full non-layoutasahiunit suite (262/263PASS after buildinglibgallium/libEGL_mesaforasahi-egl-priority-{allow,deny,once}; sole failure is pre-existingaurora-wipasahi-agx-chip-capsG16G/G17P, fixed in #955). - Live Apple M5 Max (
G17C B1), Linux 7.3 Borealis Vulkan CTS (MESA_SHADER_CACHE_DISABLE=1,0kernel GPU faults) plus targeted live Vulkan A/B hardware probe comparingAGX_MIP_FILTER_NONE(minLod == maxLod == mipLodBias == 0.0f) vsAGX_MIP_FILTER_NEAREST(minLod == maxLod == 0.0f, sub-ULPmipLodBias = 1e-6fquantizing to0). - Untested scope: Live AGX2 (
G13/G14) and AGX3B (G15/G16/G17P) hardware execution of fragmenttextureQueryLodunderAGX_MIP_FILTER_NONE(live hardware verification here covers Apple M5 MaxG17C B1/ Gen5 sampler);asahi_layout_testsexcluded due to pre-existing GCC 16 C++20 designated-initializer build issue.
Evidence
- Exact head tested:
dd2989710329 - Unit suite (non-layout
asahi):262/263PASS (1pre-existingaurora-wipasahi-agx-chip-capsG16G/G17Pmismatch, fixed in #955;asahi-egl-priority-{allow,deny,once}3/3PASS) - Live Vulkan CTS (Apple M5 Max
G17C B1, Linux 7.3,MESA_SHADER_CACHE_DISABLE=1):dEQP-VK.glsl.texture_functions.query.texturequerylod.*:190/190PASSdEQP-VK.texture.filtering.2d.combinations.nearest_mipmap_nearest.*:100/150PASS (50Not supported,0failed)dEQP-VK.texture.filtering.2d.combinations.linear_mipmap_nearest.*:100/150PASS (50Not supported,0failed)dEQP-VK.texture.explicit_lod.2d.derivatives.*:16/16PASSdEQP-VK.compute.pipeline.basic.*:80/81PASS (1Not supported,0failed)
- Live M5 Max (
G17C B1) A/B hardware probe (AGX_MIP_FILTER_NONEvsAGX_MIP_FILTER_NEAREST, 64x64 7-mip 2D texture):- Minification (
4x4,mag=LIN min=NEARandmag=NEAR min=LIN): identical filtered sample (magFilterselected in both) and identicaltextureQueryLod = (0.0, 4.0). - Magnification (
128x128,mag=LIN min=NEAR): identical filtered sample and identicaltextureQueryLod = (0.0, -1.0). - Anisotropy (
16x,4x4and4x64), explicit shader bias (texture(..., 3.0)), and explicittextureLod(..., 3.0): identical level-0 samples andtextureQueryLodresults;maxLod=4.0control verified mip 4 / mip 3 /queryLod=(4.0, 4.0).
- Minification (
- Kernel
dmesg:0new GPU faults/errors.
|
Merged into |
What: Borealis samplers whose
mipmapModeisNEARESTwithminLod == maxLod == 0andmipLodBias == 0always sample level 0. Pack them withAGX_MIP_FILTER_NONEinstead ofAGX_MIP_FILTER_NEAREST, so the sampler skips mip selection. Every other sampler packs as before. This is the LOD-0 half of therender.shadowPCF work; the 40-half 2D-array shadow hoisting cap needs the fragment sample hoisting in #711 and its follow-ups first, so it is not in this PR.Tested: fork CI only, no Mac run at this head yet. The
asahijob builds and runsmeson test --suite asahi: 277 of 278 pass. The one failure,asahi-agx-chip-caps(G16GNATIVE_PREAMBLE, G17PVDM_INDIRECT_INDEX_BOUNDS), fails the same way onaurora-wipitself; this PR does not touch the chip capability tables.aurora-agent-policypasses.Risk: two-way · all Macs running Borealis. Fragment-shader
textureQueryLodreads this same packed sampler (Borealis only computes the LOD itself for compute-style shaders), so if the hardware's LOD query does not clamp to[minLod, maxLod]underAGX_MIP_FILTER_NONE, queries on these samplers could stop returning 0. Sampling itself reads level 0 either way.Not yet:
dEQP-VK.glsl.texture_functions.query.texturequerylod.*, including a fixed-LOD-0 nearest-mip sampler, on G16G and G17P.render.shadowA/B againstaurora-wipon G16G and G17P.Details
src/asahi/vulkan/hk_sampler.c, inpack_sampler().textureQueryLodpath only restored the mip filter on HAL200. That is why the query-LOD runs above gate this PR.asahi45422915176,aurora-agent-policy45422915161.