From 84b9d9cc1a11383795a7c385cb4b87e1062df160 Mon Sep 17 00:00:00 2001 From: Jeffrey C <990135+JeffreyBytes@users.noreply.github.com> Date: Thu, 26 Nov 2026 05:02:59 -0600 Subject: [PATCH 1/2] tools: filter the translator checks' adapter by its name without the driver tag select_adapter() filtered by the name vulkaninfo prints on the host. RADV appends a tag there, as in "AMD Radeon RX 6700 XT (RADV NAVI22)", and a Proton guest can see the same device as "AMD Radeon RX 6700 XT". The filter then matched nothing, DXVK found no adapter, and every translator GPU check failed with "device failed: 0x80004005". Both filters match substrings, so filter by the name without a trailing "(...)". The full name is still what the run prints. --- tests/test_translator_checks.py | 10 +++++++++- tools/check_translator_gpu.py | 13 ++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/test_translator_checks.py b/tests/test_translator_checks.py index 2736e24b..61145af4 100644 --- a/tests/test_translator_checks.py +++ b/tests/test_translator_checks.py @@ -1,7 +1,7 @@ from pathlib import Path import unittest -from tools.check_translator_gpu import CHECKS, ROOT, command_for, printed_block, vulkan_device_name +from tools.check_translator_gpu import CHECKS, ROOT, command_for, filter_name, printed_block, vulkan_device_name class TranslatorCheckListTests(unittest.TestCase): @@ -32,6 +32,14 @@ def test_names_the_vulkan_device_for_an_adapter(self): self.assertEqual(vulkan_device_name("1002:13C0", summary), "AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO)") self.assertIsNone(vulkan_device_name("10de:2705", summary)) + def test_filters_by_the_name_without_the_driver_tag(self): + # A Proton guest can see the RADV device without the tag the host prints. + self.assertEqual(filter_name("AMD Radeon RX 6700 XT (RADV NAVI22)"), "AMD Radeon RX 6700 XT") + self.assertEqual(filter_name("AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO)"), "AMD Radeon Graphics") + self.assertEqual(filter_name("NVIDIA GeForce RTX 5090"), "NVIDIA GeForce RTX 5090") + self.assertEqual(filter_name("Intel(R) Arc(tm) A770 Graphics (DG2)"), "Intel(R) Arc(tm) A770 Graphics") + self.assertEqual(filter_name("(unnamed)"), "(unnamed)") + def test_reads_the_program_a_unit_test_prints(self): output = "running 1 test\nBEGIN_HLSL\nvoid main() {}\n\nEND_HLSL\ntest ok\nBEGIN_HLSL\nsecond\nEND_HLSL\n" self.assertEqual(printed_block(output), "void main() {}\n\n") diff --git a/tools/check_translator_gpu.py b/tools/check_translator_gpu.py index fdde9526..45359efa 100644 --- a/tools/check_translator_gpu.py +++ b/tools/check_translator_gpu.py @@ -128,6 +128,16 @@ def vulkan_device_name(adapter, summary): return None +def filter_name(name): + """The part of a device name to filter by. + + RADV appends its own tag, as in "AMD Radeon RX 6700 XT (RADV NAVI22)", and + the name a Proton guest sees can lack it. Both filters match substrings, so + the name without the tag selects the device either way. + """ + return re.sub(r"\s*\([^()]*\)\s*$", "", name) or name + + def select_adapter(adapter): """Have vkd3d-proton and DXVK expose only the requested adapter. @@ -141,7 +151,8 @@ def select_adapter(adapter): return None name = vulkan_device_name(adapter, summary) if name: - os.environ.update(VKD3D_FILTER_DEVICE_NAME=name, DXVK_FILTER_DEVICE_NAME=name) + pattern = filter_name(name) + os.environ.update(VKD3D_FILTER_DEVICE_NAME=pattern, DXVK_FILTER_DEVICE_NAME=pattern) return name From ca399e424eb369fae291f8f968ddd04651f09299 Mon Sep 17 00:00:00 2001 From: Jeffrey C <990135+JeffreyBytes@users.noreply.github.com> Date: Thu, 26 Nov 2026 06:32:34 -0600 Subject: [PATCH 2/2] tools: select the translator checks' adapter by device UUID Filtering by name cannot work in general. A Proton guest can see a device under a name that has nothing in common with what vulkaninfo prints on the host: "AMD Radeon RX 6900 XT (RADV NAVI21)" was "Radeon RX 6800/6800 XT / 6900 XT" in the guest, so the name without the driver tag still matched nothing there. A substring of the name can also match two cards, such as a 7900 XT and a 7900 XTX. vulkaninfo --summary prints each device's UUID and DXVK accepts DXVK_FILTER_DEVICE_UUID, so filter by that and set no name filter. The guests create their device on DXVK's default adapter, which is then the only one DXVK exposes. Without a UUID in the summary, fall back to the name as before. --- tests/test_translator_checks.py | 27 +++++++++++++++------ tools/check_translator_gpu.py | 43 +++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/tests/test_translator_checks.py b/tests/test_translator_checks.py index 61145af4..aa0076f2 100644 --- a/tests/test_translator_checks.py +++ b/tests/test_translator_checks.py @@ -1,7 +1,7 @@ from pathlib import Path import unittest -from tools.check_translator_gpu import CHECKS, ROOT, command_for, filter_name, printed_block, vulkan_device_name +from tools.check_translator_gpu import CHECKS, ROOT, command_for, device_filter, printed_block, vulkan_device, vulkan_device_name class TranslatorCheckListTests(unittest.TestCase): @@ -32,13 +32,24 @@ def test_names_the_vulkan_device_for_an_adapter(self): self.assertEqual(vulkan_device_name("1002:13C0", summary), "AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO)") self.assertIsNone(vulkan_device_name("10de:2705", summary)) - def test_filters_by_the_name_without_the_driver_tag(self): - # A Proton guest can see the RADV device without the tag the host prints. - self.assertEqual(filter_name("AMD Radeon RX 6700 XT (RADV NAVI22)"), "AMD Radeon RX 6700 XT") - self.assertEqual(filter_name("AMD Radeon Graphics (RADV RAPHAEL_MENDOCINO)"), "AMD Radeon Graphics") - self.assertEqual(filter_name("NVIDIA GeForce RTX 5090"), "NVIDIA GeForce RTX 5090") - self.assertEqual(filter_name("Intel(R) Arc(tm) A770 Graphics (DG2)"), "Intel(R) Arc(tm) A770 Graphics") - self.assertEqual(filter_name("(unnamed)"), "(unnamed)") + def test_filters_by_the_device_uuid(self): + # A Proton guest can see the device under another name, so the name cannot select it. + summary = ("Devices:\n========\nGPU0:\n\tvendorID = 0x1002\n\tdeviceID = 0x73bf\n" + "\tdeviceName = AMD Radeon RX 6900 XT (RADV NAVI21)\n" + "\tdeviceUUID = 00000000-0300-0000-0000-000000000000\n" + "GPU1:\n\tvendorID = 0x1002\n\tdeviceID = 0x164e\n" + "\tdeviceName = AMD Ryzen 9 7900X 12-Core Processor (RADV RAPHAEL_MENDOCINO)\n" + "\tdeviceUUID = 00000000-1300-0000-0000-000000000000\n") + self.assertEqual(device_filter(vulkan_device("1002:73bf", summary)), + {"DXVK_FILTER_DEVICE_UUID": "00000000030000000000000000000000"}) + self.assertEqual(device_filter(vulkan_device("1002:164e", summary)), + {"DXVK_FILTER_DEVICE_UUID": "00000000130000000000000000000000"}) + self.assertIsNone(vulkan_device("10de:2705", summary)) + # Without a UUID in the summary, the name is all there is. + self.assertEqual(device_filter({"deviceName": "NVIDIA GeForce RTX 5090"}), + {"VKD3D_FILTER_DEVICE_NAME": "NVIDIA GeForce RTX 5090", + "DXVK_FILTER_DEVICE_NAME": "NVIDIA GeForce RTX 5090"}) + self.assertEqual(device_filter({}), {}) def test_reads_the_program_a_unit_test_prints(self): output = "running 1 test\nBEGIN_HLSL\nvoid main() {}\n\nEND_HLSL\ntest ok\nBEGIN_HLSL\nsecond\nEND_HLSL\n" diff --git a/tools/check_translator_gpu.py b/tools/check_translator_gpu.py index 45359efa..27671006 100644 --- a/tools/check_translator_gpu.py +++ b/tools/check_translator_gpu.py @@ -118,28 +118,39 @@ def command_for(name, emitters, tools, host, work): return command + ["--work", str(work / name), "--output", str(work / f"{name}.json")] -def vulkan_device_name(adapter, summary): - """The device name `vulkaninfo --summary` lists for a PCI vendor:device ID, or None.""" +def vulkan_device(adapter, summary): + """The fields `vulkaninfo --summary` lists for a PCI vendor:device ID, or None.""" wanted = tuple(int(part, 16) for part in adapter.split(":")) for block in re.split(r"^GPU\d+:\s*$", summary, flags=re.MULTILINE)[1:]: - fields = dict(re.findall(r"^\s*(vendorID|deviceID|deviceName)\s*=\s*(.+?)\s*$", block, re.MULTILINE)) + fields = dict(re.findall(r"^\s*(vendorID|deviceID|deviceName|deviceUUID)\s*=\s*(.+?)\s*$", block, re.MULTILINE)) if (int(fields.get("vendorID", "-1"), 16), int(fields.get("deviceID", "-1"), 16)) == wanted: - return fields.get("deviceName") + return fields return None -def filter_name(name): - """The part of a device name to filter by. +def vulkan_device_name(adapter, summary): + """The device name `vulkaninfo --summary` lists for a PCI vendor:device ID, or None.""" + return (vulkan_device(adapter, summary) or {}).get("deviceName") - RADV appends its own tag, as in "AMD Radeon RX 6700 XT (RADV NAVI22)", and - the name a Proton guest sees can lack it. Both filters match substrings, so - the name without the tag selects the device either way. + +def device_filter(fields): + """The environment that makes DXVK expose only this device. + + A Proton guest can see a device under another name than the host prints: + "AMD Radeon RX 6900 XT (RADV NAVI21)" on the host was + "Radeon RX 6800/6800 XT / 6900 XT" in the guest. The device UUID is the + same on both sides, so filter by it. DXVK compares the UUID as 32 hex + digits. Without a UUID, fall back to the name. """ - return re.sub(r"\s*\([^()]*\)\s*$", "", name) or name + uuid = re.sub(r"[^0-9a-f]", "", fields.get("deviceUUID", "").lower()) + if len(uuid) == 32: + return {"DXVK_FILTER_DEVICE_UUID": uuid} + name = fields.get("deviceName") + return {"VKD3D_FILTER_DEVICE_NAME": name, "DXVK_FILTER_DEVICE_NAME": name} if name else {} def select_adapter(adapter): - """Have vkd3d-proton and DXVK expose only the requested adapter. + """Have DXVK expose only the requested adapter. The guests create their device on the default adapter, so on a machine with several GPUs they would otherwise run on whichever one comes first. @@ -149,11 +160,11 @@ def select_adapter(adapter): timeout=60).stdout except (OSError, subprocess.SubprocessError): return None - name = vulkan_device_name(adapter, summary) - if name: - pattern = filter_name(name) - os.environ.update(VKD3D_FILTER_DEVICE_NAME=pattern, DXVK_FILTER_DEVICE_NAME=pattern) - return name + fields = vulkan_device(adapter, summary) + if not fields: + return None + os.environ.update(device_filter(fields)) + return fields.get("deviceName") def main(argv=None):