From de286bf79167ebc15a60199ba22aeef1dcedf0db Mon Sep 17 00:00:00 2001 From: Matheus Fermiano <235702001+matheusfermiano-source@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:05:12 -0300 Subject: [PATCH] vk_subgroup_info: per_vertex_inputs needs VK_KHR_fragment_shader_barycentric listed RADV (Mesa 26.2.6) sets fragmentShaderBarycentric on a gfx90c iGPU (Vega 8, PCI 1002:15E7) that doesn't list VK_KHR_fragment_shader_barycentric, so per_vertex_inputs read true there. run_gpu_tests.py then didn't turn on --f16-interp-fallback and ps_interp_f16_high skipped; make_game.py reads the same field and would keep PerVertexKHR inputs the device can't run. The feature now counts only with its extension in the device's list. The gfx90c/RADV measurement goes into docs/testing.md. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 --- docs/testing.md | 8 ++++++-- tests/test_vk_subgroup_info.py | 19 ++++++++++++++----- tools/vk_subgroup_info.py | 11 ++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index 743d7b640..0021f6756 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -508,8 +508,12 @@ also advertises the feature but returns a wrong third `BaryCoordKHR` component, expected (#5933: Vega 8, PCI 1002:15E7, driver 31.0.21921.13001). `ps_bary`, `ps_persp_bary` and `ps_ij_computed` fail natively; through the fallback `ps_bary` and `ps_persp_bary` pass. `tools/vk_subgroup_info.py` reports `barycentric_fallback` for these PCI IDs under `VK_DRIVER_ID_AMD_PROPRIETARY`, so `make_game.py` and -`run_gpu_tests.py` turn the fallback on by themselves there, with the same `LEONIDA_BARY_FALLBACK` override. RADV and -other GCN 5 GPUs are not covered: none has been measured. +`run_gpu_tests.py` turn the fallback on by themselves there, with the same `LEONIDA_BARY_FALLBACK` override. RADV +(Mesa 26.2.6) on the same Vega 8 doesn't list `VK_KHR_fragment_shader_barycentric` at all, though it sets the +`fragmentShaderBarycentric` feature, so the four raw-barycentric tests skip there and pass with +`LEONIDA_BARY_FALLBACK=1`, and `ps_interp_f16_high` passes through the f16 fallback that `run_gpu_tests.py` turns on +by itself ([#166 entry](https://github.com/ItsNotRexed/Leonida/issues/166#issuecomment-7109387712)). Other GCN 5 GPUs +are not covered: none has been measured. ## Macs: 16-bit interpolation without PerVertexKHR diff --git a/tests/test_vk_subgroup_info.py b/tests/test_vk_subgroup_info.py index 9f8ff15b6..971e4a079 100644 --- a/tests/test_vk_subgroup_info.py +++ b/tests/test_vk_subgroup_info.py @@ -49,7 +49,8 @@ class FakeDevice: name: str | bytes = "Synthetic GPU" api_version: int = vk_info.VK_API_VERSION_1_3 - extension_names: tuple[bytes, ...] = () + # Listed with the fragmentShaderBarycentric feature below, as a driver that exposes barycentrics lists both. + extension_names: tuple[bytes, ...] = (vk_info.FRAGMENT_SHADER_BARYCENTRIC_EXTENSION,) device_type: int = vk_info.VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU dynamic_rendering: bool = True synchronization2: bool = True @@ -831,11 +832,19 @@ class QueryTest(unittest.TestCase): self.assertEqual(res["max_push_constants_size"], limit) def test_per_vertex_inputs(self): - """PerVertexKHR needs fragmentShaderBarycentric, and MoltenVK can't compile it to MSL either way.""" - for label, bary, driver, want in (("amd", True, 1, True), ("no_barycentrics", False, 1, False), - ("moltenvk", True, vk_info.VK_DRIVER_ID_MOLTENVK, False)): + """PerVertexKHR needs fragmentShaderBarycentric with its extension listed, and MoltenVK can't compile it to MSL + either way. RADV (Mesa 26.2.6) sets the feature on a gfx90c iGPU that doesn't list the extension.""" + ext = (vk_info.FRAGMENT_SHADER_BARYCENTRIC_EXTENSION,) + for label, bary, names, driver, want in ( + ("amd", True, ext, 1, True), + ("no_barycentrics", False, ext, 1, False), + ("moltenvk", True, ext, vk_info.VK_DRIVER_ID_MOLTENVK, False), + ("radv_gfx90c_feature_without_extension", True, (), 3, False), + ("other_extensions_only", True, (b"VK_KHR_dynamic_rendering",), 3, False), + ): with self.subTest(case=label): - res, _vk = self._run_query(FakeDevice(fragment_shader_barycentric=bary, driver_id=driver)) + res, _vk = self._run_query(FakeDevice(fragment_shader_barycentric=bary, extension_names=names, + driver_id=driver)) self.assertIs(res["per_vertex_inputs"], want) def test_barycentric_fallback(self): diff --git a/tools/vk_subgroup_info.py b/tools/vk_subgroup_info.py index d380fd279..6e79e3de9 100644 --- a/tools/vk_subgroup_info.py +++ b/tools/vk_subgroup_info.py @@ -28,8 +28,10 @@ driver. Its shader compiler can crash in vkCreateComputePipelines on emulated wa (#857, reported on RX 5000, RX 6000 and RDNA2 iGPUs). make_game.py prefers native wave64 when the GPU can run it. per_vertex_inputs says whether the device can run a pixel shader with PerVertexKHR inputs (16-bit interpolation, -docs/design.md): the fragmentShaderBarycentric feature, and a driver other than MoltenVK, whose SPIR-V to MSL -conversion rejects the decoration ("PerVertexKHR decoration is not supported in MSL", MoltenVK 1.4.2). Where it is +docs/design.md): the fragmentShaderBarycentric feature with VK_KHR_fragment_shader_barycentric in the device's +extension list, and a driver other than MoltenVK, whose SPIR-V to MSL conversion rejects the decoration +("PerVertexKHR decoration is not supported in MSL", MoltenVK 1.4.2). The feature alone is not enough: RADV (Mesa +26.2.6) fills it with a one on a gfx90c iGPU (Vega 8, PCI 1002:15E7) that doesn't list the extension. Where it is false, the shaders are translated with --f16-interp-fallback. barycentric_fallback is true for Intel's open-source Mesa driver (ANV). SHADER-925 found that Mesa ANV 26.2.5 @@ -92,6 +94,7 @@ VK_API_VERSION_1_2 = (1 << 22) | (2 << 12) VK_API_VERSION_1_3 = (1 << 22) | (3 << 12) VK_INCOMPLETE = 5 VULKAN_12_REQUIRED_EXTENSIONS = frozenset((b"VK_KHR_dynamic_rendering", b"VK_KHR_synchronization2")) +FRAGMENT_SHADER_BARYCENTRIC_EXTENSION = b"VK_KHR_fragment_shader_barycentric" PROPS_SIZE = 824 # sizeof(VkPhysicalDeviceProperties) on 64-bit FEATURES2_SIZE = 240 # sizeof(VkPhysicalDeviceFeatures2): 16 + 55 VkBool32, padded to 8 @@ -331,7 +334,9 @@ def query(*, stage_caps=False) -> dict: subgroup.subgroupSize, subgroup.supportedStages, sg.minSubgroupSize, sg.maxSubgroupSize, sg.requiredSubgroupSizeStages, sg.maxComputeWorkgroupSubgroups, sgc, - bool(u32(bary, 16)) and u32(drv, 16) != VK_DRIVER_ID_MOLTENVK, + # The feature counts only with its extension listed (RADV sets it on gfx90c without one). + bool(u32(bary, 16)) and u32(drv, 16) != VK_DRIVER_ID_MOLTENVK + and FRAGMENT_SHADER_BARYCENTRIC_EXTENSION in device_extensions(vk, d), int.from_bytes(raw[PROPS_MAX_PUSH_CONSTANTS_SIZE:PROPS_MAX_PUSH_CONSTANTS_SIZE + 4], "little"), int.from_bytes(raw[PROPS_VENDOR_ID:PROPS_VENDOR_ID + 4], "little"), int.from_bytes(raw[PROPS_DEVICE_ID:PROPS_DEVICE_ID + 4], "little"), u32(drv, 16))