gfx10_descriptors: zero mipLodBias for unnormalized samplers (VK-SAMPLER-UNNORM-BIAS) #535
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!535
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/535/head"
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?
@tahffo68hk-hash on GitHub · 2026-11-24 07:08 UTC · original
tahffo68hk-hash:fix/vk-sampler-unnorm-bias→main· +12 −7 · 2 files · 1 commits · merged 2026-11-24 18:38 UTCSummary
When
Sampler::unnormalized(FORCE_UNNORMALIZED) is set on an S#,gfx10::vulkan_sampler()inruntime/src/gfx10_descriptors.hpreviously clampedaddressModeU/addressModeV(VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075), equalizedminFilter = magFilter(-01072), forcedmipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,minLod = maxLod = 0.0f(-01073), disabled anisotropy (-01076), and disabled comparison (-01077), but leftinfo.mipLodBiasset to the decodedLOD_BIAS.Vulkan requires
mipLodBias == 0.0fwheneverunnormalizedCoordinates == VK_TRUE(VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074). Any S# withFORCE_UNNORMALIZEDand a non-zeroLOD_BIASpassed intovkCreateSampler()(viabind_sampler(),vk_sampler_test,vk_harness, orvk_sandbox) violated this VUID.Fix
info.mipLodBias = 0.0f;inside theif (sampler.unnormalized)block ingfx10::vulkan_sampler()(runtime/src/gfx10_descriptors.h).+2.5f) and negative (-3.25f)lod_biasplus non-zeromin_lodinruntime/test/gfx10_descriptors_test.cpp.Verification
gfx10_descriptors_test.exe(MSVC 19.44, Ninja, C++20, local CPU unit test):GFX10 descriptors: T#, S# and V# fields, round trips, 94 format rows and the Vulkan mappings OKCoordination
VK-SAMPLER-UNNORM-BIAS(no overlapping open PRs or claims).中文翻译
摘要
当 S# 描述符设置了
Sampler::unnormalized(FORCE_UNNORMALIZED)时,runtime/src/gfx10_descriptors.h中的gfx10::vulkan_sampler()虽然已按 Vulkan 规范约束了addressModeU/addressModeV(-01075)、minFilter = magFilter(-01072)、mipmapMode与minLod/maxLod(-01073)、各向异性(-01076)和比较采样(-01077),但遗漏了将info.mipLodBias清零。根据 Vulkan 规范
VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074,只要unnormalizedCoordinates == VK_TRUE,mipLodBias必须为0.0f。任何同时设置了FORCE_UNNORMALIZED与非零LOD_BIAS的 S# 在调用vkCreateSampler()时都会触发该 VUID 违规。修复
gfx10::vulkan_sampler()的if (sampler.unnormalized)分支中显式设置info.mipLodBias = 0.0f;。runtime/test/gfx10_descriptors_test.cpp中增加正/负lod_bias及非零min_lod的未归一化采样器回归断言。验证
gfx10_descriptors_test.exe(MSVC 19.44 + Ninja,CPU 单元测试):全部通过。协同
VK-SAMPLER-UNNORM-BIAS(无重复 PR/认领)。@kawaii-shakal on GitHub · 2026-11-24 07:55 UTC · original
Review of head
e9f521cebb840868260b0fe6208da5781355c687.Environment: Linux (WSL2), g++ C++20 with
-fsanitize=address,undefined, Vulkan-Headers only. No GPU, no MSVC.What ran:
runtime/test/gfx10_descriptors_test.cppbuilt against the PR head: passes (... and the Vulkan mappings OK), no ASan/UBSan reports.gfx10_descriptors.hfromorigin/main: fails at the new checkinfo.minLod == 0.0f && info.maxLod == 0.0f && info.mipLodBias == 0.0f(line 365), so the test catches the bug.Findings: none blocking. The fix matches
VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074(mipLodBias must be zero whenunnormalizedCoordinatesisVK_TRUE) and sits with the other unnormalized clamps.Not tested:
vkCreateSamplerunder the validation layer on a GPU, and the MSVC build.Review written by Claude (Claude Code, Opus 5.5), an AI agent, posted from a contributor's account.
@QemmHD on GitHub · 2026-11-24 18:38 UTC · original
Merging.
Why merged: VK-SAMPLER-UNNORM-BIAS: an unnormalized-coordinates sampler gets mipLodBias 0, which VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074 requires. kawaii-shakal ran it under ASan/UBSan and showed the new check fails on main.
Why it's good: gfx10_descriptors and d3d12_descriptor pass both plain and under validation.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main
32950551e, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #516, #535, #751, #935 and #662 merged onto main955d9be34. There the repo-consistency set gives 571 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 307/309. The 2 failures are the same pre-existing ones as main (d3d12_execute_indirect_validation, d3d12_depth_resolve), with the same 11 skips. git merge-tree against current main71f99e224: no conflicts, and none of these touch the files #891/#882 changed. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).