mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #2089] gfx10_descriptors: clamp sampler maxLod >= minLod and guard DERIV_ADJUST_EN integer border (VK-SAMPLER-LOD-ORDER-AND-DERIV-ADJUST) #2095
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2095
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2089
Author: @KushGene
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/vk-sampler-lod-order-and-deriv-adjust📝 Commits (1)
c182b7agfx10_descriptors: clamp sampler maxLod >= minLod and guard DERIV_ADJUST_EN integer border (VK-SAMPLER-LOD-ORDER-AND-DERIV-ADJUST)📊 Changes
2 files changed (+45 additions, -4 deletions)
View changed files
📝
runtime/src/gfx10_descriptors.h(+13 -4)📝
runtime/test/gfx10_descriptors_test.cpp(+32 -0)📄 Description
Claimed in the coordination issue as: VK-SAMPLER-LOD-ORDER-AND-DERIV-ADJUST (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172871387)
What and why
runtime/src/gfx10_descriptors.hdecodes console GFX10 S# descriptors (decode(SamplerWords)) and translates them toVkSamplerCreateInfo(vulkan_sampler()) forDeviceState::bind_sampler()and synthetic GPU tests:maxLod >= minLodand finite LOD values (VUID-VkSamplerCreateInfo-maxLod-01973):vulkan_sampler()previously copiedsampler.min_lodandsampler.max_lodverbatim whenmip_filter != MipFilter::none && !sampler.unnormalized. Any title S# carryingMIN_LOD > MAX_LODor aD3D12_SAMPLER_DESC/ caller input withmin_lod > max_lod(or NaN) produced an invalidVkSamplerCreateInfo. Raiseinfo.maxLodtoinfo.minLodwheninfo.maxLod < info.minLodand normalize NaN LOD inputs (minLod->0.0f,maxLod->info.minLod).mipLodBiasagainst NaN and negative/NaNmax_lod_bias(VUID-VkSamplerCreateInfo-mipLodBias-01069):std::clamp(sampler.lod_bias, -max_lod_bias, max_lod_bias)triggers undefined behavior whenmax_lod_bias < 0or NaN, and propagates NaNlod_bias. Normalize negative/NaN limits to0.0fand NaNlod_biasto0.0fusingdetail::clamped().DERIV_ADJUST_ENwhen checkingkIntegerBorderPtrindecode(SamplerWords): Line 582 already checks!deriv_adjustbefore interpretingWORD3bits askCompareNever, becauseDERIV_ADJUST_EN(WORD2 bit 31) repurposesWORD3. Apply the same!deriv_adjustguard tokIntegerBorderPtr(0x800) so descriptors withDERIV_ADJUST_EN = 1are not misdecoded asinteger_border = true(VK_BORDER_COLOR_INT_*).Follows the pattern of
e9f521ceb(VK-SAMPLER-UNNORM-BIAS).Tested
main/ pass with fix (runtime/test/gfx10_descriptors_test.cpp): Builtgfx10_descriptors_testagainst the pre-fix header with the new tests: failed onmainatline 386: info.minLod == 3.5f && info.maxLod == 3.5f(exit 1); passes with the fix (GFX10 descriptors: T#, S# and V# fields, round trips, 95 format rows and the Vulkan mappings OK).runtime/test/gfx10_descriptors_test.cppwith/usr/bin/g++ -std=c++20 -O2 -Wall -Wextra -Werror -Wno-missing-field-initializers(0 warnings, exit 0).ctest: Rebuiltgfx10_descriptors_test,vk_sampler_test,vk_harness,vk_sandbox,vk_store_test,vk_texture_test,indirect_clamp_safety_test,indirect_topology_and_stats_test, and ranctest --test-dir runtime/build/linux-ctest -E "^(shader_library_corpus|vk_sync_validation)$" --output-on-failure -j8-> 97/97 passed (2 skipped in full suite).ps_ssharp+ inverted-LODvk_sampler_test):LEONIDA_VK_DEVICE=6700 python3 -I scripts/run_gpu_tests.py --build runtime/build/linux-ctest --filter ps_ssharp --require-pass-> 2 shaders translated and valid (spirv-val),PASS ps_ssharp 8 S#/T# cases, 4096 pixels each exact(1/1 passed).LEONIDA_VK_DEVICE=6700 ./runtime/build/linux-ctest/vk_sampler_test .../vs_ids.spv .../ps_ssharp.spv .../inv.raw 0 00000100 04000000 0 0 1(MIN_LOD = 1.0,MAX_LOD = 0.0, point mip filter) ->mipmapMode 0, minLod 1, maxLod 1, mipLodBias 0; view levels 0..1andok -> .../inv.raw(65536bytes,vkCreateSamplerand render succeeded on RADV).python3 -I scripts/check_no_game_data.py runtime/src/gfx10_descriptors.h runtime/test/gfx10_descriptors_test.cppandgit diff --checkpassed.GPUs tested: AMD Radeon RX 6700 XT (RADV NAVI22, Mesa 26.2.7, Vulkan 1.4.354, Fedora Linux 45).
AI-assisted: yes (Antigravity)
Checklist
main(db1a22d29) and merges cleanly.CONTRIBUTING.md), including in logs or reports quoted here.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.