[PR #535] [MERGED] gfx10_descriptors: zero mipLodBias for unnormalized samplers (VK-SAMPLER-UNNORM-BIAS) #580

Closed
opened 2026-11-26 20:18:21 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/535
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: fix/vk-sampler-unnorm-bias


📝 Commits (1)

  • e9f521c gfx10_descriptors: zero mipLodBias for unnormalized samplers (VK-SAMPLER-UNNORM-BIAS)

📊 Changes

2 files changed (+12 additions, -7 deletions)

View changed files

📝 runtime/src/gfx10_descriptors.h (+4 -2)
📝 runtime/test/gfx10_descriptors_test.cpp (+8 -5)

📄 Description

Summary

When Sampler::unnormalized (FORCE_UNNORMALIZED) is set on an S#, gfx10::vulkan_sampler() in runtime/src/gfx10_descriptors.h previously clamped addressModeU/addressModeV (VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075), equalized minFilter = magFilter (-01072), forced mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, minLod = maxLod = 0.0f (-01073), disabled anisotropy (-01076), and disabled comparison (-01077), but left info.mipLodBias set to the decoded LOD_BIAS.

Vulkan requires mipLodBias == 0.0f whenever unnormalizedCoordinates == VK_TRUE (VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074). Any S# with FORCE_UNNORMALIZED and a non-zero LOD_BIAS passed into vkCreateSampler() (via bind_sampler(), vk_sampler_test, vk_harness, or vk_sandbox) violated this VUID.

Fix

  • Zero info.mipLodBias = 0.0f; inside the if (sampler.unnormalized) block in gfx10::vulkan_sampler() (runtime/src/gfx10_descriptors.h).
  • Add regression checks with both positive (+2.5f) and negative (-3.25f) lod_bias plus non-zero min_lod in runtime/test/gfx10_descriptors_test.cpp.

Verification

  • Built and ran 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 OK

Coordination

  • Claimed on #14 as VK-SAMPLER-UNNORM-BIAS (no overlapping open PRs or claims).
  • AI-assisted: yes.
中文翻译

摘要

当 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 单元测试):全部通过。

协同

  • 已在 #14 认领 VK-SAMPLER-UNNORM-BIAS(无重复 PR/认领)。
  • AI 辅助:是。

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/535 **Author:** [@tahffo68hk-hash](https://github.com/tahffo68hk-hash) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/vk-sampler-unnorm-bias` --- ### 📝 Commits (1) - [`e9f521c`](https://github.com/ubiquitarianism/leonida/commit/e9f521cebb840868260b0fe6208da5781355c687) gfx10_descriptors: zero mipLodBias for unnormalized samplers (VK-SAMPLER-UNNORM-BIAS) ### 📊 Changes **2 files changed** (+12 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/gfx10_descriptors.h` (+4 -2) 📝 `runtime/test/gfx10_descriptors_test.cpp` (+8 -5) </details> ### 📄 Description ## Summary When `Sampler::unnormalized` (`FORCE_UNNORMALIZED`) is set on an S#, `gfx10::vulkan_sampler()` in `runtime/src/gfx10_descriptors.h` previously clamped `addressModeU`/`addressModeV` (`VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075`), equalized `minFilter = magFilter` (`-01072`), forced `mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST`, `minLod = maxLod = 0.0f` (`-01073`), disabled anisotropy (`-01076`), and disabled comparison (`-01077`), **but left `info.mipLodBias` set to the decoded `LOD_BIAS`**. Vulkan requires `mipLodBias == 0.0f` whenever `unnormalizedCoordinates == VK_TRUE` (`VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074`). Any S# with `FORCE_UNNORMALIZED` and a non-zero `LOD_BIAS` passed into `vkCreateSampler()` (via `bind_sampler()`, `vk_sampler_test`, `vk_harness`, or `vk_sandbox`) violated this VUID. ### Fix - Zero `info.mipLodBias = 0.0f;` inside the `if (sampler.unnormalized)` block in `gfx10::vulkan_sampler()` (`runtime/src/gfx10_descriptors.h`). - Add regression checks with both positive (`+2.5f`) and negative (`-3.25f`) `lod_bias` plus non-zero `min_lod` in `runtime/test/gfx10_descriptors_test.cpp`. ### Verification - Built and ran `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 OK` ### Coordination - Claimed on #14 as `VK-SAMPLER-UNNORM-BIAS` (no overlapping open PRs or claims). - AI-assisted: yes. <details> <summary>中文翻译</summary> ## 摘要 当 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 单元测试):全部通过。 ### 协同 - 已在 #14 认领 `VK-SAMPLER-UNNORM-BIAS`(无重复 PR/认领)。 - AI 辅助:是。 </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:21 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#580
No description provided.