rdna2spirv: --explicit-lod-bias applies the S# LOD bias where MoltenVK drops the sampler's; ps_ssharp passes on Macs (SHADER-EXPLICIT-LOD-BIAS-MVK) #1774
Open
github-bot
wants to merge 16 commits from
github-bot/gh-1774 into main
AGit
pull from: github-bot/gh-1774
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1774
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1774"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Tauwni on GitHub · 2026-11-25 11:50 UTC · original
Tauwni:fix/explicit-lod-bias-moltenvk→main· +1374 −60 · 26 files · 16 commits · openUpdate 4 (
5c702e2a7, docs only): the M3 on 27.0 and an Apple M5 have run this headNo code has changed since
743eda012.bcf199736and5c702e2a7only updatedocs/design.mdwith these results:--lod-bias)ps_ssharp*in auto modeSo the measured gate does what it should on real Apple hardware. Where MoltenVK drops the bias (the M3s), the shader applies it. Where MoltenVK applies it (the M5, KosmicKrisp, llvmpipe), the flag stays off, and nothing is counted twice.
Still open: the macOS CI job. Its workflows are awaiting approval, and
ps_ssharpstays inEXPECTED_FAILURESuntil the runner's probe shows which way it goes. An M5 Pro run on 26.7.3 (@GeorgiyDemo) would be one more false data point, but it is no longer needed for the gate.Update 3 (
743eda012): review fixes, andmainmerged againFrom @aslan2142's review:
tools/vk_lod_bias.pyalso reads at explicit LOD 1 with no bias, and answersnullunless that read is 1.0. Before, a level 1 that was never cleared also read 0.0, which looked like a dropped bias.image_sample_cl/image_sample_c_cladd the S# bias before the clamp,max(0 + bias, minlod), as_b_cldoes.make_game.pydropped, and thetools/vk_subgroup_info.pyconflict resolved (3fc618429,b14565930).After #2098, a tagged module reads its instruction's array only when the table entry's kind names it.
vk_sampler_test --cube/--3dnow tag the array the texture sits in. Without that,ps_ssharp_cubeandps_ssharp_3dread the fallback.Still open at the time: the M5 Pro and 27.0 M3 reruns (both answered in Update 4), and the macOS CI job.
Update 2 (
631a53832): the probe needs no test programs, every sample form is GPU-checkedThe open points of the Update below are done, with @EvgHaze's two suggestions:
tools/vk_subgroup_info.py --lod-biasmeasures it in Python (tools/vk_lod_bias.py): a two-level R32_SFLOAT image cleared to 0.0 / 1.0, sampled at explicit LOD 0 through samplers withmipLodBias0 and +1 in one compute dispatch.truewhen +1 still reads level 0,falsewhen it reads level 1,nullotherwise. It needs no built test programs, llvm-mc or SPIR-V tools.tools/lod_bias_probe.pyreturns that answer and only falls back to theps_ssharpdraw when it has none.build.pyandmake_game.pynow measure too, socheck.pyalone takes the flag andmake_game.pyno longer waits for the test programs. The option is off by default, so nothing else that runsvk_subgroup_info.pydispatches anything.llvm-mcmessage. When the draw fallback can't startllvm-mc, it givesmc_command.install_hint()(the HomebrewLLVM_MC="$(brew --prefix llvm)/bin/llvm-mc"line) instead of a bare "could not be started".SAMPLER_CASES(check.py'sSAMPLER_FIXTURES).vk_sampler_testgains--cube,--3dand--dref; its 2D default is unchanged.ps_ssharpimage_sample_lz,image_sampleps_ssharp_ld(new)image_sample_l,image_sample_d(theGradscale)ps_ssharp_b(new)image_sample_lz,image_sample_bps_ssharp_cube(new)image_sample_lz,image_sampleimages_arrps_ssharp_3d(new)image_sample_lz,image_sampleimages_3dps_ssharp_c(new)image_sample_c_lz,image_sample_cps_ssharp_o(new)image_sample_lz_o,image_sample_oLEONIDA_TEXOFF_FALLBACK=1(a SKIP without it)Tested at
631a53832on the Apple M3 (macOS 26.5.1):bias +1) on all 7true)bias +0.3(counted twice) on all 7false)bias +0.3on all 7false)generated/fix below, locally) onmaindb1a22d29, test programs rebuilt:run_gpu_tests.py(200/270 native, 233/270 emulated) orcheck.py(192/237, 45 skipped, flag measured bybuild.pyitself).cs_fma_fusedfrom #1724;ps_cndmask_sign_modsandps_valu16_mad_sel, fixed by the KosmicKrisp branch below;cs_fmt_all, see below).mainhas too:test_tool_stdout_encoding(#1837, #1673 and thestage_timelinebranch below) andtest_calibrated_texture_extra, a WindowsMoveFileExWtest that fails on macOS onmainalone.Still open after Update 2
ps_ssharpstays in itsEXPECTED_FAILURES; the job prints a notice if it passes there, and it can be dropped then.python -I tools/vk_subgroup_info.py --lod-biasshould answer"explicit_lod_bias": falsethere, and--filter ps_ssharpshould pass all 7 with the flag off.Found while testing and split off, since they're not this PR's topic:
generated/directory forvk_null_descriptor_test(the macOS/Linux build fails onmain).Tauwni:fix/stage-timeline-stdout(pull request to follow):stage_timeline.py's stdout guard.Tauwni:fix/kosmickrisp-nan-canonicalization(pull request to follow): KosmicKrisp's canonical NaN in exact-word pixel tests.cs_fmt_allon KosmicKrisp isn't one fix. Word 293 is an f16 signalling NaN stored quiet (0x7c01->0x7e00), and word 312, an 11/11/10 float, reads a different finite G and a NaN B (0xf83efde0->0xfc1efde0). That looks like a driver bug, not the canonicalization, so it stays a finding (#1608) rather than a tolerance.Update (
66b27ac6e): the flag is now measured per device, not keyed on MoltenVK's driver IDThe reviews showed the driver-ID gate was wrong: the same MoltenVK 1.4.2 applies
mipLodBiason an Apple M5 Pro, so the auto flag counted the bias twice there and turned a passingps_ssharpred. It isn't an OS-version rule either:mipLodBias?ps_ssharpfails onmainmainmainWhat changed:
tools/lod_bias_probe.py: translatesvs_idsandps_ssharpwithout the flag, draws them withvk_sampler_testat LOD_BIAS 0, +1 and -1, and answerstrueonly when +1 and -1 read the no-bias levels. It answersfalsewhen both move ascheck.pyexpects, andnullotherwise (wrong no-bias draw, mixed answer, failed draw, no test programs).nullnever turns the flag on.scripts/run_gpu_tests.pyandmake_game.pytake the probe's answer.make_game.pyruns it on the test programs inruntime/build/linuxorruntime/buildif present; otherwise it keeps a recorded flag, like the other fallbacks.runtime/test/shaders/build.pyonly followsLEONIDA_EXPLICIT_LOD_BIAS: it also runs inside the CMake build, before the test programs exist, so it must not probe.tools/vk_subgroup_info.pyand its test are back as onmain, with noexplicit_lod_biasfield.tools/lod_bias_probe.pyis inruntime.yml's path filters. Newtests/test_lod_bias_probe.py(7 tests with fake draws: applied, dropped, mixed, wrong base, failed draw, no programs, translated without the flag).Tested at
66b27ac6eon the Apple M3:true, KosmicKrispfalse, llvmpipefalse, no test programsnull.ps_ssharpin auto mode: 10/10 on all three. KosmicKrisp plays the part of a driver that applies the bias, like the M5 Pro: the probe leaves the flag off there. Forced checks unchanged: MoltenVK off failsbias +1, KosmicKrisp on failsbias +0.3.main71a769d7d, test programs rebuilt:run_gpu_tests.py(195/264 native, 228/264 emulated) or incheck.pywithLEONIDA_EXPLICIT_LOD_BIAS=1, as the probe answers (187/231, 44 skipped).Still open
(done in Update 2): aftercheck.pyalone doesn't take the flagbuild.py, a Mac that needs it has to setLEONIDA_EXPLICIT_LOD_BIAS=1, whichpython -I tools/lod_bias_probe.py --build <test programs>answers. A lead: letbuild.pyprobe when it is given the test programs' folder, but never inside the CMake build.Not GPU-checked:(done in Update 2) A lead: a_d, the_c*forms, cube and 3D samples, and the texel-offset gradients.ps_ssharp-style fixture per form.ps_ssharpstays in itsEXPECTED_FAILURES; the job prints a notice if it passes there.(done in Update 2); before that the flag stays off unless it was recorded.make_game.pycan only probe once the test programs are built--filter ps_ssharprun andpython -I tools/lod_bias_probe.py --build <your build>would confirm the probe answersfalsethere.mainsinceba626820e, the macOS/Linux build ofvk_null_descriptor_testfails: itsadd_custom_commandwritesgenerated/cs_null_descriptors.spvwithout creatinggenerated/("Failed to open file"). AddingCOMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/generatedbeforeglslangValidatorfixes it locally (ctest 95/95).tests/test_tool_stdout_encoding.pyfails onmainfor two new tools,tools/game_run_summary.pyandtools/stage_timeline.py(noerrors='replace'on stdout).ps_cndmask_sign_mods,ps_valu16_mad_selandcs_fmt_all(NaN canonicalization, finding in #1608) andcs_fma_fusedwith #1724 (comment there) still fail.I'll try to fix the open points of this PR this evening, or as soon as I have time, and post the results here.Done: see Update 2.Claimed in the coordination issue as: SHADER-EXPLICIT-LOD-BIAS-MVK (#1608)
What and why
ps_ssharpfails onevery Macsome Macs (see Update) with MoltenVK 1.4.2 (point bias +1: (0,0): (1.0, 0.0, 0.502, 0.502) != (0.502, 0.502, 0.502, 0.502)) and sits in the macOS job'sEXPECTED_FAILURES. Measured on an Apple M3: MoltenVK dropsVkSamplerCreateInfo::mipLodBiasfrom both explicit-LOD samples (image_sample_lzwith +0.6 / +1 stays on level 0) and the derivative-LODimage_sample(-0.6 / -1 stays on level 1). The test stopped at its first failing case, so only the explicit half showed. KosmicKrisp and llvmpipe (Mesa 26.3.1) on the same machine apply the bias.This adds a device fallback,
rdna2spirv.py --explicit-lod-bias, in the same shape as--f16-interp-fallback: the shader applies the S#'sLOD_BIAS(word 2 [13:0], signed 5.8, read from the S# SGPRs; a literal S# folds to a constant, a zero bias adds nothing):Lodof_lz,_l,_c_lz,_c_land of the implicit forms outside the PS;_b/_c_b;Biasoperand on implicit samples in the PS;Gradderivatives (the typed 2D implicit read,_d, and the--texel-offset-fallbackgradients).The sampler still clamps to
MIN_LOD..MAX_LOD. It is chosen per device, since on a driver that applies the bias it would count twice:(replaced, see Update) (recorded with the other fallback flags);explicit_lod_biasintools/vk_subgroup_info.py(MoltenVK's driver ID), read byscripts/run_gpu_tests.py,runtime/test/shaders/build.pyandmake_game.pyLEONIDA_EXPLICIT_LOD_BIAS=1/0forces it in the test runners.check.py'sSAMPLER_CASESgainpoint bias +0.3and-0.3: with two levels, an integer bias can't tell a bias applied once from twice, these can (they fail on KosmicKrisp and llvmpipe when the flag is forced there).Docs: a contract row in
docs/design.md(with what is and isn't GPU-checked) and a Known problems row indocs/testing.md.ps_ssharpstays in the macOS job'sEXPECTED_FAILURESfor now: that runner is a paravirtual device I can't test here; if it passes there, the job prints its "drop it from the expected failures" notice and it can go in a follow-up.Tested
Apple M3, macOS 26.5.1, test programs built from
main:ps_ssharp(10 cases)bias +1; also +-0.6, -1)bias +0.3(counted twice)bias +0.3(counted twice)tests/semantic/test_explicit_lod_bias.py(new, 7 tests: literal, negative, zero and run-time S#, Grad scaling, Bias operand,_b, compute);tests/test_vk_subgroup_info.py,tests/test_make_game_translator_flags.py(probe mocked, new case),tests/test_make_game_argparse.py(probe mocked),tests/test_shader_checks.py(the two new cases).build.py, resolution in #822's thread, none with this branch), test programs rebuilt: MoltenVK has no failure left:run_gpu_tests.py195/263, 68 skipped (228/263 withLEONIDA_W64_EMULATE=1),check.py187/231, 44 skipped. KosmicKrisp keeps exactly the failures it had without this branch (cs_fma_fusedfrom #1724,ps_cndmask_sign_mods,ps_valu16_mad_sel,cs_fmt_all; see #1608); llvmpipe none. ctest 88/88; translator suite 6299 tests, standard-library loop 499 files, pytest 1912 passed, all 0 failed._d, the_c*forms, cube and 3D samples, and the texel-offset gradients (covered by the semantic test only).GPUs tested: Apple M3 (10-core GPU), MoltenVK 1.4.2 and KosmicKrisp (Mesa 26.3.1), macOS 26.5.1 (25F80); llvmpipe (Mesa 26.3.1)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly.docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
743eda012bcf1997366@Mby159 on GitHub · 2026-11-25 12:11 UTC · original
Checked
1d19671ebon AMD: Radeon 780M Graphics (RDNA3 iGPU, gfx1103), AMD proprietary 26.10.2 (32.0.32015.12012, LLPC), Vulkan 1.4.359, Windows 11 10.0.29712, subgroup 32..64. This branch changes no C++, so we ran the branch's translator, fixtures and checker against the C++ test programs built frommainbcaa13dad(the merge-base); nothing was merged.tools/vk_subgroup_info.pyon this GPU answers"explicit_lod_bias": false(driver_id: 1), so the fallback stays off here, consistent with this driver applying the sampler's own bias.--filter ps_ssharpwith the flag unset: PASS, "10 S#/T# cases, 4096 pixels each exact" - the two newpoint bias +0.3andpoint bias -0.3cases included.LEONIDA_EXPLICIT_LOD_BIAS=1forced on, the new case fails: "point bias +0.3: (0,0): (0.502, 0.502, 0.502, 0.502) != (1.0, 0.0, 0.502, 0.502)" - the bias counted twice, matching the PR's own description (design.md / testing.md) of forcing the flag on a driver that already applies the sampler bias.LEONIDA_EXPLICIT_LOD_BIAS=0forced off: PASS, all ten cases.So on this AMD Windows device the ±0.3 cases also tell a bias counted once from twice, and the per-device selection keeps this GPU on the sampler's bias.
The whole suite with this branch and the flag unset gives the same result as
mainon this GPU: 273/273 shaders translated and spirv-val clean, 243/263 passed, 18 skipped, and the same two failures (cs_imgatomic_ext, which open PR #1518 fixes, andcs_texture_uav, which needs the D3D12 test program this machine cannot build).Still not GPU-checked here: the
_d,_c*, cube and 3D forms and the texel-offset gradients.AI-assisted (MiniMax Code). No game files.
@GeorgiyDemo on GitHub · 2026-11-25 12:13 UTC · original
Tested
1d19671ebon Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain0d80bc5df:tests/semantic/test_explicit_lod_bias.py: OK at this head; onmain7 errors. The wiring tests (test_make_game_argparse,test_make_game_translator_flags,test_shader_checks,test_vk_subgroup_info): 219 passed, 1 skipped, 485 subtests.ps_ssharp:main(no flag):ps_ssharp8 S#/T# cases PASS on MoltenVK 1.4.2 — the sampler appliesmipLodBiasto the explicit-LOD sample here.vk_subgroup_inforeportsexplicit_lod_bias: truefor driver_id 14): FAILpoint bias +0.3: (0,0): (0.502, 0.502, 0.502, 0.502) != (1.0, 0.0, 0.502, 0.502)— exactly the fixture's doubled-bias case: the translator's +0.3 on top of the sampler's +0.3 = +0.6 reads level 1. Reproduced 3/3.LEONIDA_EXPLICIT_LOD_BIAS=0at this head: PASS 10/10; KosmicKrisp (flag off by detection): PASS 10/10.mipLodBias") does not hold: a driver-id gate alone turns a passing fixture red. It needs a behavioural probe (or a narrower condition) before enabling--explicit-lod-biasautomatically.AI-assisted; synthetic fixtures only, no game data.
@EvgHaze on GitHub · 2026-11-25 12:45 UTC · original
Independent Apple check, including the per-device choice this PR introduces.
The auto-selection reports what it should:
ps_ssharp, with the choice made per device:--explicit-lod-biasOn main, MoltenVK fails this fixture on this machine (
point bias +1: (0,0): (1.0, 0.0, 0.502, 0.502)), so the flag is what fixes it.Negative control, the risk your design row names: forcing
LEONIDA_EXPLICIT_LOD_BIAS=1on KosmicKrisp fails exactly as documented —so the per-device probe is load-bearing, not cosmetic: without it KosmicKrisp would count the bias twice and lose the ±0.3 cases.
Both drivers translate the two modules with
spirv-valclean.AI-assisted. No game data: the fixture is hand-written and every number above is test output.
@GeorgiyDemo on GitHub · 2026-11-25 14:14 UTC · original
Adding a datapoint that makes the driver-id gate look OS-version-dependent: an Apple M5 Pro on macOS 26.7.3 (25G342) with the same MoltenVK 1.4.2 (driver id 14), base
main0d80bc5df, binaries from the build at66d4f5aa3, Homebrew llvm-mc 23.1.4 / SPIRV-Tools 1.4.363:vk_subgroup_inforeportsdriver_id: 14,explicit_lod_bias: true— i.e. the auto path enables the flag.mainwithout the flag:ps_ssharp8/8 PASS — on this macOS the sampler appliesmipLodBiasto the explicit-LOD sample, so the M3/macOS 27 premise does not hold here.point bias +0.3: (0,0): (0.502, 0.502, 0.502, 0.502) != (1.0, 0.0, 0.502, 0.502)— the same doubled-bias failure as the forced-on negative controls (KosmicKrisp here, and Mby159's forced-on AMD run). Reproduced 3/3.LEONIDA_EXPLICIT_LOD_BIAS=0at this head: PASS 10/10; KosmicKrisp, flag off by detection: PASS 10/10.So "MoltenVK drops
mipLodBias" is true on the macOS 27.0/M3 run above but false on macOS 26.7.3 with the identical MoltenVK version;driver_id == MOLTENVKalone turns a passing fixture red on 26.7.3. The auto choice needs a behavioural probe (or an OS/Metal-version condition) rather than the driver id.AI-assisted; synthetic fixtures only, no game data.
@EvgHaze on GitHub · 2026-11-25 14:35 UTC · original
Confirming the other half of what @GeorgiyDemo describes, from the macOS 27.0 side, and agreeing the gate has to be behavioural.
My run, which the comment above quotes as "the macOS 27.0/M3 run": Apple M3, macOS 27.0 (26A5406e), MoltenVK 1.4.2 (Homebrew),
driver_id: 14, base0d80bc5df:mainwithout the flagps_ssharp—point bias +1: (0,0): (1.0, 0.0, 0.502, 0.502)LEONIDA_EXPLICIT_LOD_BIAS=1forcedpoint bias +0.3, the doubled biasSo the same
driver_id 14gives opposite answers on 26.7.3 and 27.0, and both directions are reproducible.driver_id == MOLTENVKis necessary but not sufficient.For the probe, the cheapest shape that cannot lie is to sample with a known bias and read the returned LOD, the way
ps_ssharpdoes, with a 1×1 chain: build a 2-mip texture, sample withimage_sample_lzatLod = 0andmipLodBias = +1, and compare the returned texel against level 1. That is onevk_compute_test-sized program, no game data, and it answers the question on whichever macOS/Metal combination the user actually has, instead of encoding a version table.If you want, I can write that probe into
tools/vk_subgroup_info.pyand test it on both sides — 27.0 here, and I can ask for a 26.7.3 run from the comment above.AI-assisted.
@Tauwni on GitHub · 2026-11-25 14:38 UTC · original
Thanks, this is the key datapoint, and you're right that the driver-ID gate is wrong.
It doesn't look like an OS-version condition either, though. My M3 is on an older macOS than your M5 Pro and still drops the bias:
mipLodBias?ps_ssharpfails onmainmainmainSo it follows the GPU (or its Metal family) more than the OS, and any static rule (driver ID, OS version, chip list) will be wrong somewhere. I'm working on replacing the gate with the behavioural probe you suggested: a small tool that translates
vs_idsandps_ssharpwithout the flag, draws them withvk_sampler_testat LOD_BIAS 0, +1 and -1, and turns the flag on only when +1 and -1 read the no-bias levels. An inconclusive probe leaves it off.It's still being tested here. I'll push it and post the results in this thread when it's done, and it would help if you could rerun
--filter ps_ssharpon your M5 Pro then. Until then, please don't merge this PR as it is: the current head turnsps_ssharpred on your machine.AI-assisted (Claude Code).
@Tauwni on GitHub · 2026-11-25 15:03 UTC · original
Thanks! The probe you describe is in the update I just pushed (
66b27ac6e, see the Update section above):tools/lod_bias_probe.pydrawsps_ssharpwithout the flag at LOD_BIAS 0, +1 and -1 on the two-level texture and turns the flag on only when +1 and -1 read the no-bias levels. On my M3 (26.5.1) it answerstrueon MoltenVK andfalseon KosmicKrisp and llvmpipe. A rerun on your 27.0 M3 would be very welcome.Your idea of putting it in
tools/vk_subgroup_info.pyhas a real advantage over mine: it wouldn't need the built test programs, somake_game.pyandbuild.pycould probe too (two of the "Still open" points). If you'd like to write that version, go ahead and I'll test it here; otherwise I'll look at it this evening. Either way, let's say who does it here so we don't both write it.AI-assisted (Claude Code).
@EvgHaze on GitHub · 2026-11-25 15:46 UTC · original
Rerun on the 27.0 M3, as asked.
So the probe answers
trueon this 27.0 M3 too, which is whatps_ssharpneeds here (main fails without the flag, 10/10 with it). Together with @GeorgiyDemo's 26.7.3 run, that is the two sides the driver-id gate got wrong, and the behavioural probe now gets both right.One thing to keep in mind if the probe ships:
lod_bias_probe.pyneedsllvm-mconPATH, and Homebrew'sllvmis keg-only, so a Mac user hitting it first sees the raw'llvm-mc' could not be startedmessage. Cheap fix in the tool's error text (point atllvm/tools/mc_command.py's message, which already saysLLVM_MC="$(brew --prefix llvm)/bin/llvm-mc"), and worth doing so the probe is not blamed for being broken.On ownership: you take the
vk_subgroup_info.pyversion this evening — I would rather not start it and have us both write it. I will test whatever you push on this 27.0 M3 and on KosmicKrisp, and I can ask the 26.7.3 machine in the comment above to run it too. If you would rather I write it, say so and I will start, but the split above is the safer one.AI-assisted.
@Tauwni on GitHub · 2026-11-25 18:31 UTC · original
Thanks for the 27.0 rerun, and agreed on the split: I'll write the
vk_subgroup_info.pyversion, so the probe no longer needs the built test programs, plus the clearllvm-mcmessage you suggest. I'll post here when it's pushed, with the M3 results, so you can run it on your 27.0 M3 and on KosmicKrisp.AI-assisted (Claude Code).
@Tauwni on GitHub · 2026-11-25 20:18 UTC · original
Update 2 is pushed (
631a53832), see the top of the description. As discussed:tools/vk_subgroup_info.py --lod-biasmeasures it in Python with one compute dispatch (tools/vk_lod_bias.py), with no built test programs, llvm-mc or SPIR-V tools.build.pyandmake_game.pyuse it too.LLVM_MChint whenllvm-mcis missing.ps_ssharp_ld,_b,_cube,_3d,_c,_o), through newvk_sampler_test --cube/--3d/--drefmodes.On the M3 (26.5.1), all 7
ps_ssharp*pass on MoltenVK (probetrue), KosmicKrisp and llvmpipe (probefalse), and forcing the flag on the last two failsbias +0.3as it should. With the open fixes merged, MoltenVK has no failure left.@EvgHaze: a run on your 27.0 M3 (MoltenVK and KosmicKrisp) would be great. @GeorgiyDemo: on the M5 Pro,
python -I tools/vk_subgroup_info.py --lod-biasshould answer"explicit_lod_bias": false, and--filter ps_ssharpshould pass all 7 with the flag off. Thanks both.AI-assisted (Claude Code).
@aslan2142 on GitHub · 2026-11-25 21:47 UTC · original
Thanks for Update 2! Three things before this can merge:
mainintools/vk_subgroup_info.py, after #624 landed. Please mergemainin.make_game.py,runtime_gpu_explicit_lod_bias()has a secondtryblock after the first, which always returns. It's unreachable and uses an undefinedbuild; please drop it.AI-assisted (Claude Code, Claude Opus 5.5).
@Tauwni on GitHub · 2026-11-25 23:22 UTC · original
@aslan2142 thanks, both done, in your order:
mainis merged in (b14565930, up to21d3662ad). #624 had addedchosen_d/chosen_extensionsfor what mychosen_devdid, so I keptmain's and the--lod-biasmeasurement now uses them. It looks the extensions up itself rather than throughexts, which is only set whenper_vertexis true.tryinruntime_gpu_explicit_lod_bias()is removed (3fc618429), and nothing else inmake_game.pychanges.Rerun at
3fc618429on the Apple M3 (macOS 26.5.1):trueon MoltenVK andfalseon KosmicKrisp and llvmpipe.ps_ssharp*fixtures pass in auto mode on all three, and forcing the flag off or on fails as documented.maindoesn't also have. ctest needs #2096 today: without it, the build stops atvk_null_descriptor_test's missinggenerated/.The 27.0 M3 and M5 Pro reruns are still pending.
AI-assisted (Claude Code).
@aslan2142 on GitHub · 2026-11-26 00:57 UTC · original
Thanks, the merge and the dead-code fix both look good: it merges cleanly and the translator suite passes.
Before merging:
vk_subgroup_info.py --lod-biasshould answerfalse) and the 27.0 M3 with the compute probe. The 27.0 result in the thread is from the draw probe.EXPECTED_FAILURESinruntime.ymlstill listsps_ssharp. Once the job runs, drop it if the runner's probe answerstrue, or add the newps_ssharp_*fixtures if they fail there.vk_lod_bias.pyanswerstruewhenever the biased read is 0.0, which a level 1 that was never cleared also gives. Could you add a plain read at explicit LOD 1 that must return 1.0, and answernullotherwise?image_sample_cl/image_sample_c_clgetmax(0, minlod) + bias. Vulkan clamps after the bias,max(bias, minlod), as_b_clalready does.AI-assisted (Claude Code, Claude Opus 5.5).
@Tauwni on GitHub · 2026-11-26 01:45 UTC · original
@aslan2142 thanks, done in your order:
vk_subgroup_info.py --lod-biasshould answerfalse) and the 27.0 M3 with the compute probe. @GeorgiyDemo @EvgHaze, when you have a moment, please rerun at the new head.ps_ssharpfromEXPECTED_FAILURESif the runner's probe answerstrue, or add theps_ssharp_*fixtures that fail there.1787a81c7): the shader also reads at explicit LOD 1 with no bias, andverdict()answersnullunless that read is 1.0. On this M3, skipping the level 1 clear now givesnullon all three drivers ("control read at LOD 1 gave 0.0"), where it used to givetrueon MoltenVK. New test:test_the_lod1_control_must_read_one.85eac6b54): outside the PS,image_sample_cl/image_sample_c_clnow add the S# bias before the clamp,max(0 + bias, minlod), as_b_cldoes. New semantic test:test_compute_cl_clamps_after_the_bias. It fails on the previous head.eb464f2fc): it now says the 27.0 M3 checked the draw probe until it's rerun, and it describes the LOD 1 control and the clamp order.I also merged
mainagain (a88bb83e0, up toad41fd517), because #2098 changed something this PR depends on: a tagged module now reads its instruction's array only when the table entry's kind names it.vk_sampler_testtagged the T# 2D only, so after the mergeps_ssharp_cubeandps_ssharp_3dread the magenta fallback.743eda012tags the array the texture sits in for--cube/--3d.Rerun at
743eda012on the Apple M3 (macOS 26.5.1):trueon MoltenVK andfalseon KosmicKrisp and llvmpipe.ps_ssharp*fixtures pass in auto mode on all three, and forcing the flag off or on fails as documented.run_gpu_tests.py: no failure thatmaindoesn't also have.ps_array_resinfoandps_get_lod_arrayfail onmaintoo since #2098, on every driver; #2169 fixes them.AI-assisted (Claude Code).
@EvgHaze on GitHub · 2026-11-26 04:28 UTC · original
Rerun at
743eda012, the head that mergedmainagain, on the 27.0 M3 — so the "checked until it is rerun" note indesign.mdcan go.vk_subgroup_info.py --lod-bias, MoltenVK 1.4.2 — the new flag answers and explains:tools/lod_bias_probe.py, three drivers on the same machine:mipLodBias(+1 still reads level 0)mipLodBias(+1 reads level 1)mipLodBias(+1 reads level 1)run_gpu_tests.py --filter ps_ssharp, auto mode, all three drivers: 6/6 PASS on each —ps_ssharp,_3d,_b,_c,_cube,_ld, 10 S#/T# cases each, 4096 pixels each exact.So this head reproduces your 26.5.1 M3 result on 27.0, and the cube/3d tagging fix (
743eda012) holds here —ps_ssharp_cubeandps_ssharp_3dread the real arrays rather than the magenta fallback.That is the full set you asked for from this machine; I did not rerun the whole GPU suite or ctest, since your run already covers those and this head changes no C++ that the probe and the fixtures do not exercise.
@GeorgiyDemo the 26.7.3 side is still the one missing — that is the pair that decides the gate, since 26.7.3 is where
mainpasses without the flag.AI-assisted. No game data.
@Tauwni on GitHub · 2026-11-26 05:47 UTC · original
@EvgHaze thanks for the rerun.
bcf199736drops the "until it is rerun" note:design.mdnow says the compute probe answers true on both M3s (26.5.1 and 27.0, MoltenVK 1.4.2) and false on KosmicKrisp and llvmpipe, and thatps_ssharpand its five variants pass in auto mode on all three drivers on the 27.0 machine. Docs only, no code change.What is still open is the M5 Pro on 26.7.3, as you said.
@Tauwni on GitHub · 2026-11-26 10:56 UTC · original
@GeorgiyDemo When you have a moment on the M5 Pro (macOS 26.7.3), could you run this head (
bcf199736)? It is the last result this PR is waiting for. Both M3s, on macOS 26.5.1 and 27.0, are done.On your machine the probe should answer
"explicit_lod_bias": false, since MoltenVK appliesmipLodBiasthere. The sixps_ssharp*fixtures should pass in auto mode. If the probe answers true instead, itsexplicit_lod_bias_reasonline is the useful part. Thanks!AI-assisted (Claude Code).
@Tauwni on GitHub · 2026-11-26 14:02 UTC · original · edited 2026-11-26 14:04 UTC
Apple M5 result for this head, run by cizerter (on Discord) on their machine. I'm relaying it, and thanks to cizerter for the run.
tools/vk_subgroup_info.py --lod-biasscripts/run_gpu_tests.py --filter ps_ssharp, auto modeSo the measured answer is false on the M5, as on the M5 Pro without the flag: MoltenVK applies
mipLodBiasthere. The fixtures pass without--explicit-lod-bias, and only the M3s, where the probe answers true, get the in-shader bias. That is the false half of the gate on real Apple hardware.The M5 Pro on 26.7.3 (@GeorgiyDemo) would still be a second false data point, but this one already covers the case that decides the gate.
AI-assisted (Claude Code). No game data.
@Tauwni on GitHub · 2026-11-26 23:51 UTC · original
Merged
main(d1dff7949) for the needs rebase label:0dcf650d1. The only conflict was thegloballine inrdna2spirv.py'smain(), wheremainaddedADDRESS_GUARDnext to this PR'sEXPLICIT_LOD_BIAS. Both are kept.Retested at
0dcf650d1on an Apple M3 (macOS 26.5.1), test programs rebuilt from this tree:--lod-biasprobe: true on MoltenVK 1.4.2, false on KosmicKrisp and llvmpipe (Mesa 26.3.1), as before.run_gpu_tests.py --filter ps_ssharp: 6/6 pass on all three (ps_ssharp_oskips withoutLEONIDA_TEXOFF_FALLBACK=1).cs_fma_fused(#1724) andcs_imgatomic_ext(#1518).test_vk_lod_bias.py,test_vk_subgroup_info.pyandtest_make_game_translator_flags.pypass.No change to the PR's own code.
AI-assisted (Claude Code). No game data.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.