Skip to content

borealis: use AGX_MIP_FILTER_NONE for fixed LOD-0 nearest-mip samplers - #956

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/borealis-sampler-lod0-mip-none
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
djdev/borealis-sampler-lod0-mip-none

Conversation

@DjDeveloperr

Copy link
Copy Markdown

What: Borealis samplers whose mipmapMode is NEAREST with minLod == maxLod == 0 and mipLodBias == 0 always sample level 0. Pack them with AGX_MIP_FILTER_NONE instead of AGX_MIP_FILTER_NEAREST, so the sampler skips mip selection. Every other sampler packs as before. This is the LOD-0 half of the render.shadow PCF 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 asahi job builds and runs meson test --suite asahi: 277 of 278 pass. The one failure, asahi-agx-chip-caps (G16G NATIVE_PREAMBLE, G17P VDM_INDIRECT_INDEX_BOUNDS), fails the same way on aurora-wip itself; this PR does not touch the chip capability tables. aurora-agent-policy passes.

Risk: two-way · all Macs running Borealis. Fragment-shader textureQueryLod reads 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] under AGX_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.shadow A/B against aurora-wip on G16G and G17P.
Details

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>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 15:25

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/-1 diff in src/asahi/vulkan/hk_sampler.c and all AGX_MIP_FILTER_NONE / mip_filter consumers:
    • hk_pack_native_sampler() (src/asahi/vulkan/hk_native_sampler.c) accepts AGX_MIP_FILTER_NONE across Gen4, Gen4 HAL200, and Gen5 descriptors.
    • hk_d3d_nearest_mip (hk_sampler.c:265-268) adds HK_D3D_NEAREST_MIP_BIAS (1/64) to d3d_info.mipLodBias before calling pack_sampler(), so D3D nearest-mip samplers have mipLodBias != 0.0f, remain AGX_MIP_FILTER_NEAREST, and stay consistent with hk_nir_lower_descriptors.c:1348.
    • Compute-stage lower_compute_lod_query() and Gen4 lower_gen4_biased_lod_query() (hk_nir_lower_descriptors.c:1339,1419) select level 0.0 for AGX_MIP_FILTER_NONE while preserving unclamped lambda, matching nearest(clamp(lambda, 0.0, 0.0)) == 0.0.
  • Isolated release build (-Dtools=drm-shim -Dbuild-tests=true), full non-layout asahi unit suite (262/263 PASS after building libgallium/libEGL_mesa for asahi-egl-priority-{allow,deny,once}; sole failure is pre-existing aurora-wip asahi-agx-chip-caps G16G/G17P, fixed in #955).
  • Live Apple M5 Max (G17C B1), Linux 7.3 Borealis Vulkan CTS (MESA_SHADER_CACHE_DISABLE=1, 0 kernel GPU faults) plus targeted live Vulkan A/B hardware probe comparing AGX_MIP_FILTER_NONE (minLod == maxLod == mipLodBias == 0.0f) vs AGX_MIP_FILTER_NEAREST (minLod == maxLod == 0.0f, sub-ULP mipLodBias = 1e-6f quantizing to 0).
  • Untested scope: Live AGX2 (G13/G14) and AGX3B (G15/G16/G17P) hardware execution of fragment textureQueryLod under AGX_MIP_FILTER_NONE (live hardware verification here covers Apple M5 Max G17C B1 / Gen5 sampler); asahi_layout_tests excluded due to pre-existing GCC 16 C++20 designated-initializer build issue.
Evidence
  • Exact head tested: dd2989710329
  • Unit suite (non-layout asahi): 262/263 PASS (1 pre-existing aurora-wip asahi-agx-chip-caps G16G/G17P mismatch, fixed in #955; asahi-egl-priority-{allow,deny,once} 3/3 PASS)
  • Live Vulkan CTS (Apple M5 Max G17C B1, Linux 7.3, MESA_SHADER_CACHE_DISABLE=1):
    • dEQP-VK.glsl.texture_functions.query.texturequerylod.*: 190/190 PASS
    • dEQP-VK.texture.filtering.2d.combinations.nearest_mipmap_nearest.*: 100/150 PASS (50 Not supported, 0 failed)
    • dEQP-VK.texture.filtering.2d.combinations.linear_mipmap_nearest.*: 100/150 PASS (50 Not supported, 0 failed)
    • dEQP-VK.texture.explicit_lod.2d.derivatives.*: 16/16 PASS
    • dEQP-VK.compute.pipeline.basic.*: 80/81 PASS (1 Not supported, 0 failed)
  • Live M5 Max (G17C B1) A/B hardware probe (AGX_MIP_FILTER_NONE vs AGX_MIP_FILTER_NEAREST, 64x64 7-mip 2D texture):
    • Minification (4x4, mag=LIN min=NEAR and mag=NEAR min=LIN): identical filtered sample (magFilter selected in both) and identical textureQueryLod = (0.0, 4.0).
    • Magnification (128x128, mag=LIN min=NEAR): identical filtered sample and identical textureQueryLod = (0.0, -1.0).
    • Anisotropy (16x, 4x4 and 4x64), explicit shader bias (texture(..., 3.0)), and explicit textureLod(..., 3.0): identical level-0 samples and textureQueryLod results; maxLod=4.0 control verified mip 4 / mip 3 / queryLod=(4.0, 4.0).
  • Kernel dmesg: 0 new GPU faults/errors.

@DjDeveloperr
DjDeveloperr merged commit 01871ed into aurora-wip Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged into aurora-wip as 01871ed12707 (head dd2989710329, verified tree 70876346760b). Verified: exact-head peer approval (262/262 non-chip-caps asahi tests, live M5 Max Borealis Vulkan textureQueryLod/nearest_mipmap_nearest/linear_mipmap_nearest/explicit_lod CTS + A/B hardware probe confirming bit-for-bit parity, 0 GPU faults), aurora-agent-policy (45422915161), and asahi (45422915176, 277/277 non-chip-caps passing; asahi-agx-chip-caps restored in #955).

@RyanTheTide
RyanTheTide deleted the djdev/borealis-sampler-lod0-mip-none branch November 27, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants