Skip to content

fix(kyty): accept devices without shaderResourceMinLod - #336

Open
discordbarca wants to merge 2 commits into
simnJS:AnyKytyfrom
discordbarca:kyty-optional-shader-min-lod
Open

discordbarca wants to merge 2 commits into
simnJS:AnyKytyfrom
discordbarca:kyty-optional-shader-min-lod

Conversation

@discordbarca

@discordbarca discordbarca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

Device selection refused any GPU without shaderResourceMinLod. The Intel Windows driver (101.8974, Intel Arc iGPU in a Core Ultra 7 255H) reports it as false, so 20 of the 104 kyty_shim_ tests failed before reaching the GPU (Intel(R) Graphics: shaderResourceMinLod is not supported). This was reported in #203: #203 (comment)

This PR makes the feature optional:

  • vulkanWindow.cpp: logs the missing feature instead of rejecting the device; enables shaderResourceMinLod only when the driver reports it; adds GraphicContext::shader_resource_min_lod_enabled.
  • Spirv::Profile::shader_resource_min_lod (set in SpirvProfile, serialized in Serialize.h, so it is also part of the shader store header) carries support into the recompiler.
  • spirvEmitterImage.cpp: without the feature, an implicit-LOD sample with a clamp component queries its LOD with OpImageQueryLod (.y), adds the bias, clamps with FMax(lod, min_lod) and samples with an explicit Lod. This is the same fold the explicit-LOD path already uses, and the same query the mip-stats path uses. Only anisotropic filtering is lost on that sample. With explicit gradients the clamp is dropped.

Devices that support the feature take the old path and emit the same SPIR-V as before.

Tested

Windows 11 Pro 25H2 (26200.9974), WinLibs GCC 15.2.0 UCRT, LLVM 21.1.8, Vulkan SDK 1.4.363.0 validation layer. ctest --test-dir build -R '^kyty_shim_' -V --timeout 300 with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Tested on 688dbf145d plus this change; the rebase onto current AnyKyty was clean and touched none of these files.

before after
Intel(R) Graphics, 101.8974 (ANYPS5_GPU=Intel) 82 passed, 21 failed 101 passed, 2 failed
NVIDIA RTX 5070 Laptop, 621.14 (ANYPS5_GPU=5070) 102 passed, 1 failed 102 passed, 1 failed
  • kyty_shim_rt_corpus is skipped in every run (no manifest).
  • 0 VUID- lines in all runs.
  • All 20 tests that were rejected for shaderResourceMinLod now pass on Intel.
  • The remaining failures are not from this change:
    • kyty_shim_packed_unorm_blend checks every device regardless of ANYPS5_GPU. Its 10 off-by-one-LSB dst=5 mismatches are on NVIDIA; Intel has 0. This failure is the same before and after.
    • kyty_shim_pm4_shader_registers timed out once during the Intel run. That test always uses NVIDIA, and it passed in 0.5 s on rerun with both ANYPS5_GPU=Intel and =5070.

New test kyty_shim_recompiler_min_lod_fallback: compiles image_sample_cl, image_sample_b_cl and image_sample_d_cl pixel shaders with and without shader_resource_min_lod, and checks the SPIR-V. With the feature, the MinLod capability and operand are used. Without it there is no MinLod, implicit and biased samples use OpImageQueryLod with an explicit Lod, and the gradient sample keeps its gradients. Every variant passes spirv-val. It passes along with the other 5 kyty_shim_recompiler_* tests.

Still not covered: the rendered output of the fallback is not compared against the MinLod path on a GPU, and no game was run on the Intel GPU.

Checklist

  • Based on current AnyKyty; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and licence notices
  • Unimplemented paths throw; silent stubs are listed in their library's technical debt file (n/a: no stubs)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (n/a)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none (the Intel part of Run the Kyty GPU tests on your GPU and post the summary (AMD, Intel, Windows) #203)
  • Unblocks: none
  • GPUs tested: Intel(R) Graphics (Arc iGPU, Core Ultra 7 255H), driver 101.8974; NVIDIA GeForce RTX 5070 Laptop GPU, driver 621.14; both on Windows 11 Pro 25H2
  • AI-assisted: yes

The Intel Windows driver (101.8974, Intel Arc iGPU) reports
shaderResourceMinLod = false, so device selection refused it and 20 of
the kyty_shim tests failed before reaching the GPU (see simnJS#203).

Make the feature optional:
- device selection logs it instead of rejecting the device, and the
  feature is only enabled when the driver reports it;
- a new Spirv::Profile::shader_resource_min_lod flag carries support
  into the recompiler (and into the shader store header);
- without it, an implicit-LOD sample with a clamp queries its LOD with
  OpImageQueryLod, adds the bias, clamps with FMax and samples at that
  explicit LOD (the same fold the explicit-LOD path already uses); only
  anisotropic filtering is lost. With explicit gradients the clamp is
  dropped.

Devices that support the feature emit the same SPIR-V as before.
Compile image_sample_cl, image_sample_b_cl and image_sample_d_cl pixel
shaders with and without Spirv::Profile::shader_resource_min_lod and
check the SPIR-V: with the feature it uses the MinLod capability and
operand; without it there is no MinLod at all, implicit and biased
samples query their LOD and sample at an explicit Lod, and the gradient
sample keeps its gradients. Every variant must pass spirv-val.

Registered as kyty_shim_recompiler_min_lod_fallback.
@discordbarca
discordbarca temporarily deployed to repository-maintenance November 26, 2026 19:47 — with GitHub Actions Inactive

@simnJS simnJS left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please add a behavioral regression for a sampler with nonzero mip LOD bias. The fallback takes the second component of OpImageQueryLod, which includes the queried LOD adjustment, and sends it to an explicit-LOD sample using the same sampler. This can apply the bias twice and select a different mip. The gradient fallback also drops the minimum LOD clamp. Cover both cases with distinguishable mip values so the test verifies sampling results. Vulkan LOD operation and query

This branch was previously deployed

1 inactive deployment
repository-maintenance — bd51579b Deployed Nov 26, 2026 by discordbarca via review #4
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