Repository navigation
Conversation
|
Request changes: the documented shader-side LOD-bias fallback does not exist, so this cannot fix Verified: But there is no Also, The conflict in AI-assisted review, no game files, no GPU. |
|
Tested head
AI-assisted (Devin). |
Kam471
left a comment
There was a problem hiding this comment.
Ran this at d90394e03 on Windows 11: pytest tests/test_vk_subgroup_info.py -q -> 50 passed, 75 subtests passed; git diff --check clean.
vk_subgroup_info now recognises KosmicKrisp and reports its sampler-LOD-bias fallback, and the runtime enables the matching path for that driver; the added cases pin the detection and the non-KosmicKrisp path. I cannot run the KosmicKrisp driver here. No blocking issue.
d90394e to
8e55d5d
Compare
|
@tupacfan04 You are right on every point, and the PR is rebuilt around it. The fallback the old version documented does exist — it is #1845 (SHADER-268), still open, which is why So this PR is now stacked on #1845 (Depends on #1845) and keeps only what #1845 leaves open:
Verified on this machine (M3 Pro, Homebrew Mesa), no game files: Review only |
8e55d5d to
dc68669
Compare
|
PARTIAL: the fallback is real now, but the runtime never selects it. At the head I checked ( The blocking gap is the wiring: The merge conflicts with current AI-assisted review, no game files, no game GPU. |
|
Tested dc68669 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
|
Verified at the PR head: tests/test_vk_subgroup_info.py passes 46 under python -I, the new test_lod_bias_fallback passes under pytest (14 + 26 subtests; like its siblings it needs the pytest venv), and main's translator-use guard passes when the test is copied onto a current-main tree. However the branch no longer merges with current main — docs/d3d12_vulkan.md conflicts; a rebase is needed and will interact with #4642's same-tuple change. The vulkan_portability.h part and the KosmicKrisp Mesa measurement are unverified here (no cmake build, no Apple hardware). No CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
An Apple M5 (MacBook Air, macOS 26.6) with Homebrew Mesa KosmicKrisp ( I'm holding off at Once the fix and the rebase onto main are pushed, I'll run these on the M5:
AI-assisted (Claude Code). |
|
Independent check on Apple M4 Pro, macOS 27.2.1, comparing #1845 a71346f with #4641 dc68669. With LEONIDA_LOD_BIAS_FALLBACK unset, KosmicKrisp 26.2.99 passed 2/3 sampler tests on #1845 (ps_ssharp_lod failed at point bias +1) and 3/3 on #4641. The generated metadata confirmed automatic fallback selection on #4641. Forcing the fallback on in #1845 made ps_ssharp_lod pass. Forcing it off in #4641 reproduced the same failure. MoltenVK 1.4.2 passed all three tests on both revisions. All generated shaders passed spirv-val, and all 46 device-probe unit tests passed. Native macOS tests only. Synthetic fixtures, no game files. AI-assisted. |
dc68669 to
2732fbb
Compare
|
Rebased onto The gap. Rebase. One translator fix the merge brought out. Tested on macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2, MoltenVK 1.4.2 (a device whose samplers take no LOD bias), synthetic fixtures and texture only, no game files:
AI-assisted. |
…R-268) MoltenVK reports VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias false (Metal samplers have no LOD bias) and ignores mipLodBias, which with the portability subset is also invalid usage (VUID-...-samplerMipLodBias-04467), so ps_ssharp failed at "point bias +1" and every biased sampler read the wrong mip. - rdna2spirv.py --lod-bias-fallback: samples apply S# word 2 [13:0] where Vulkan adds the sampler's bias, before the clamp: gradients x 2^bias for a 2D implicit PS sample (sampled with Grad from the quad derivatives), the Bias operand for other implicit PS samples (added to _b's), added to _l's LOD, LOD = bias for _lz, _c_lz and implicit samples outside the PS, gradients x 2^bias for _d/_d_cl. image_get_lod queries at the coordinate x 2^bias, since OpImageQueryLod's lambda' includes the sampler's bias. With --texel-offset-fallback, an implicit image_sample_o/_b_o finds the level its offset is scaled by the same way, so the device clamps after the bias as the sample does. A scalar-list S# (VCCTuple) reads word 2 from its third entry. Gathers are unchanged. The index marks such shaders lod_bias_fallback. Without the flag all 214 GPU-test modules and index.json are byte-identical to ec8ec4c's. - vulkan_sampler(..., 0) gives mipLodBias 0; the D3D12 device and vk_sampler_test read the portability subset (runtime/src/vulkan_portability.h), enable it where offered, and zero the bias where the feature is missing; vk_sampler_test also takes --shader-lod-bias and enumerates portability drivers behind the loader. - vk_subgroup_info.py reports sampler_lod_bias; make_game.py and run_gpu_tests.py turn the flag on where it is false (LEONIDA_LOD_BIAS_FALLBACK=1/0 overrides). - ps_ssharp_ops (image_sample_l, _b, _d, _d_cl), ps_ssharp_lod (image_get_lod at LOD 1 and 2, over the cases without MIN_LOD = MAX_LOD, which llvmpipe leaves out of the query, plus MAX_LOD 0.25) and three more SAMPLER_CASES (+0.375, bias -1 with MIN_LOD 1, +1 with MAX_LOD 0); test_lod_bias_fallback.py. Apple M3 Max: ps_ssharp, ps_ssharp_ops and ps_ssharp_lod pass on MoltenVK 1.4.2 with the flag (chosen by itself), and on KosmicKrisp and llvmpipe (Mesa 26.3.1) with it forced on, plain and with LEONIDA_W64_EMULATE=1 LEONIDA_MESH_COMPUTE=1. Natively llvmpipe passes all three and KosmicKrisp ps_ssharp and ps_ssharp_ops; its OpImageQueryLod leaves the sampler's bias out of lambda', so ps_ssharp_lod fails there (docs/testing.md). The D3D12 part compiles and links with clang-cl 23.1.6 and the xwin 10.0.26100 SDK; not run on Windows. AI-assisted.
…-918) KosmicKrisp (Mesa's Metal driver, driver ID 28) reports VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias as true, yet its OpImageQueryLod leaves the sampler's mipLodBias out of the calculated LOD and adds it, unrounded and past the last level, to the clamped one (ItsNotRexed#3124, Mesa 26.3.1 on an M3 Max). ps_ssharp_lod therefore fails there while the probe says the samplers take a bias, and make_game.py translates without --lod-bias-fallback: the driver drops the S#'s bias from the LOD query and nothing applies it. This is the one piece ItsNotRexed#1845 (SHADER-268) leaves open: it selects the fallback from the portability subset's samplerMipLodBias feature, which KosmicKrisp reports as present, and documented the KosmicKrisp failure as needing LEONIDA_LOD_BIAS_FALLBACK=1 by hand. - tools/vk_subgroup_info.py: sampler_lod_bias is false for driver ID 28, whatever the feature says, and the answer carries kosmickrisp. - runtime/src/vulkan_portability.h: sampler_mip_lod_bias() is false for driver ID 28 (is_kosmickrisp, by the driver ID as is_moltenvk is, since the extension may not be in sight), so vulkan_sampler() creates samplers with mipLodBias 0 and the shaders translated with --lod-bias-fallback apply the S#'s bias there, as on MoltenVK. Older Vulkan headers get the driver ID constant. - docs/design.md: how sampler_lod_bias is chosen now; docs/testing.md: the ps_ssharp_lod row says the tooling selects the fallback for KosmicKrisp. - tests/test_vk_subgroup_info.py: a KosmicKrisp device that reports the feature (with and without VK_KHR_portability_subset), MoltenVK, and an AMD device that keeps the bias. Depends on ItsNotRexed#1845. The PR diff shows ItsNotRexed#1845's commit as well: this one is the last commit, 205810f3. Tested on macOS 27.2.1 (Apple M3 Pro, CPython 3.15.2), no game files: - python -I tests/test_vk_subgroup_info.py -> 46 tests OK. - tools/vk_subgroup_info.py against the real drivers on this machine: KosmicKrisp (Homebrew Mesa, driver 28) -> "kosmickrisp": true, "sampler_lod_bias": false; MoltenVK (driver 14) -> "sampler_lod_bias": false. Before this change the same KosmicKrisp device answered true, which is the bug. - tests/test_docs_design_rows.py, test_docs_links.py, test_docs_repo_paths.py, test_make_game_translator_flags.py, test_shader_checks.py -> OK; python -m compileall -q tools tests -> OK. - cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo and cmake --build runtime/build -> 96/96 targets, clean. The GPU result ps_ssharp_lod passes with the fallback on KosmicKrisp is ItsNotRexed#3124's and automatic, and was not re-run on a GPU here. AI-assisted.
2732fbb to
86e11f3
Compare
|
Rebased again onto Re-tested at the new head: |
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
|
Tested Windows 11, MSVC 14.44.35207 (VS Build Tools 2022, CPU, translator (the main change,
GPU, runtime wiring (
Not covered by this run: Negative control (runtime level). Reverting Commands: the semantic suite, pytest and |
|
Tested
No game files. AI-assisted (Claude Code). |
Claimed in the coordination issue as: TEST-918.
Depends on #1845 (SHADER-268, the shader-side LOD bias fallback itself). The PR diff therefore shows #1845's commit too: the change to review here is the last commit,
8e55d5d3(git show 8e55d5d3).What and why
KosmicKrisp, Mesa's Metal driver (driver ID 28), reports
VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBiasas true, but itsOpImageQueryLodleaves the sampler'smipLodBiasout of the calculated LOD and adds it, unrounded and past the last level, to the clamped one (#3124, Mesa 26.3.1, M3 Max). Sops_ssharp_lodfails natively there while the probe says the samplers take a bias.#1845 selects
--lod-bias-fallbackfrom that portability-subset feature, so on KosmicKrisp it selects nothing, and its own known-problems row says to forceLEONIDA_LOD_BIAS_FALLBACK=1by hand. This PR closes that: the fallback is selected for KosmicKrisp by driver ID.Changes (commit
8e55d5d3)tools/vk_subgroup_info.py:sampler_lod_biasis false for driver ID 28 whatever the feature says, and the answer carrieskosmickrisp.runtime/src/vulkan_portability.h:sampler_mip_lod_bias()is false for driver ID 28 (is_kosmickrisp, by the driver ID likeis_moltenvk, since the extension may not be in sight), sovulkan_sampler()creates samplers withmipLodBias0 and the shaders translated with--lod-bias-fallbackapply the S#'s bias there, as on MoltenVK. Older Vulkan headers get the driver ID constant.docs/design.md: howsampler_lod_biasis chosen.docs/testing.md: theps_ssharp_lodrow says the tooling selects the fallback for KosmicKrisp.tests/test_vk_subgroup_info.py: a KosmicKrisp device that reports the feature (with and withoutVK_KHR_portability_subset), MoltenVK, and an AMD device that keeps the bias.Gone from the earlier version of this PR, on review: the runtime branch that claimed shaders handle the bias while nothing did, and the
sampler_lod_biasflag inferred from a driver blacklist — the field and its MoltenVK meaning are #1845's, and it is only overridden for the one driver that measurably drops the bias.Testing
macOS 27.2.1, Apple M3 Pro, CPython 3.15.2. No game files.
python -I tests/test_vk_subgroup_info.py-> 46 tests OK.tools/vk_subgroup_info.pyagainst the real drivers on this machine: KosmicKrisp (Homebrew Mesa, driver 28) ->"kosmickrisp": true, "sampler_lod_bias": false; MoltenVK (driver 14) ->"sampler_lod_bias": false. Before this change the same KosmicKrisp device answeredtrue, which is the bug.tests/test_docs_design_rows.py,test_docs_links.py,test_docs_repo_paths.py,test_make_game_translator_flags.py,test_shader_checks.py-> OK;python -m compileall -q tools tests-> OK.cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo; cmake --build runtime/build-> 96/96 targets, clean.ps_ssharp_lodpassing with the fallback on KosmicKrisp is #3124's and #1845's measurement (M3 Max, Mesa 26.3.1); this change makes that selection automatic and was not re-run on a GPU here.AI-assisted.
Checklist
docs/design.md, with how it was confirmed.