{"record":{"id":"8533098f8a98baf1","repo":"AvaloniaUI/Avalonia","slug":"device-with-the-corresponding-luid-not-found","errorCode":null,"errorMessage":"Device with the corresponding LUID not found","messagePattern":"Device with the corresponding LUID not found","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"samples/GpuInterop/VulkanDemo/D3DMemoryHelper.cs","lineNumber":68,"sourceCode":"        return device;\n    }\n\n    private static unsafe ComPtr<IDXGIAdapter> GetAdapterByLuid(ComPtr<IDXGIFactory1> factory, Luid luid)\n    {\n        var index = 0u;\n        ComPtr<IDXGIAdapter> adapter = default;\n\n        while (factory.EnumAdapters(index, adapter.GetAddressOf()) != DxgiErrorNotFound)\n        {\n            AdapterDesc adapterDesc;\n            if (adapter.GetDesc(&adapterDesc) == 0 & AreLuidsEqual(adapterDesc.AdapterLuid, luid))\n                return adapter;\n\n            adapter.Dispose();\n            ++index;\n        }\n\n        throw new ArgumentException(\"Device with the corresponding LUID not found\");\n    }\n\n    public static unsafe ComPtr<ID3D11Texture2D> CreateMemoryHandle(ComPtr<ID3D11Device> device, PixelSize size, VulkanFormat format)\n    {\n        if (format != VulkanFormat.R8G8B8A8Unorm)\n            throw new ArgumentException(\"Not supported format\");\n\n        ComPtr<ID3D11Texture2D> texture = default;\n        var textureDesc = new Texture2DDesc\n        {\n            Format = Format.FormatR8G8B8A8Unorm,\n            Width = (uint)size.Width,\n            Height = (uint)size.Height,\n            ArraySize = 1,\n            MipLevels = 1,\n            SampleDesc = new SampleDesc(1, 0),\n            Usage = Usage.Default,\n            BindFlags = (uint)(BindFlag.RenderTarget | BindFlag.ShaderResource),","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/samples/GpuInterop/VulkanDemo/D3DMemoryHelper.cs#L50-L86","documentation":"Thrown by D3DMemoryHelper.GetAdapterByLuid (ArgumentException) when no DXGI adapter enumerated via IDXGIFactory1.EnumAdapters has an AdapterLuid matching the supplied Vulkan device LUID. The Vulkan/D3D11 interop requires both APIs to reference the same physical GPU, identified by LUID.","triggerScenarios":"Enumerating DXGI adapters after acquiring a VkPhysicalDevice, where the Vulkan device's LUID does not match any D3D11 adapter. Common on multi-GPU systems where Vulkan picked one GPU (e.g. discrete) but DXGI enumeration/selection finds only another, or the LUID comparison is mismatched.","commonSituations":"Multi-GPU laptops (integrated + discrete) where Vulkan and D3D land on different GPUs; driver LUID reporting discrepancies; Vulkan device with no valid deviceLUID extension; the wrong factory/adapter enumeration path.","solutions":["Force Vulkan and D3D11 onto the same physical GPU (e.g. select the Vulkan device whose LUID matches a known D3D adapter).","Use VkPhysicalDeviceIDProperties (deviceLUID) to obtain the exact LUID to compare against DXGI AdapterDesc.AdapterLuid.","On multi-GPU systems, prefer the discrete adapter in both APIs or disable one GPU for testing.","Update GPU drivers so LUIDs are reported consistently across APIs."],"exampleFix":"// before\nvar adapter = GetAdapterByLuid(factory, vulkanLuid); // no match -> throws\n\n// after\n// pick the Vulkan physical device whose deviceLUID matches a DXGI adapter first\nvar dxgiLuid = PickMatchingDxgiLuid(factory, vkDeviceLuid);\nvar adapter = GetAdapterByLuid(factory, dxgiLuid);","handlingStrategy":"validation","validationCode":"Luid? findMatchingLuid(ComPtr<IDXGIFactory1> factory, Luid vkLuid) {\n  uint i = 0; ComPtr<IDXGIAdapter> a = default;\n  while (factory.EnumAdapters(i, a.GetAddressOf()) != DxgiErrorNotFound) {\n    AdapterDesc d; if (a.GetDesc(&d) == 0 && AreLuidsEqual(d.AdapterLuid, vkLuid)) return d.AdapterLuid;\n    a.Dispose(); ++i;\n  }\n  return null;\n}\nif (findMatchingLuid(factory, vkLuid) is null) { /* select a different Vulkan device */ }","typeGuard":"static bool LuidMatchesAnyAdapter(ComPtr<IDXGIFactory1> factory, Luid luid) {\n  uint i = 0; ComPtr<IDXGIAdapter> a = default;\n  while (factory.EnumAdapters(i, a.GetAddressOf()) != DxgiErrorNotFound) {\n    AdapterDesc d; if (a.GetDesc(&d) == 0 && AreLuidsEqual(d.AdapterLuid, luid)) return true;\n    a.Dispose(); ++i;\n  }\n  return false;\n}","tryCatchPattern":"try { return GetAdapterByLuid(factory, luid); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"LUID\")) { /* pick the Vulkan device whose LUID matches a DXGI adapter, then retry */ throw; }","preventionTips":["Use VkPhysicalDeviceIDProperties.deviceLUID to match the Vulkan device to a DXGI adapter.","On multi-GPU systems, force both APIs to the same physical GPU.","Keep GPU drivers current so LUIDs agree across APIs."],"tags":["sample","gpu","vulkan","direct3d","interop","multi-gpu","csharp","argument"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}