{"record":{"id":"9223282665062981","repo":"AvaloniaUI/Avalonia","slug":"vulkan-d3ddevice-wasn-t-created","errorCode":null,"errorMessage":"Vulkan D3DDevice wasn't created","messagePattern":"Vulkan D3DDevice wasn't created","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"samples/GpuInterop/VulkanDemo/VulkanImage.cs","lineNumber":143,"sourceCode":"                    out var memoryRequirements);\n\n                var dedicatedAllocation = new MemoryDedicatedAllocateInfoKHR\n                {\n                    SType = StructureType.MemoryDedicatedAllocateInfoKhr, Image = image\n                };\n\n                var fdExport = new ExportMemoryAllocateInfo\n                {\n                    HandleTypes = handleType,\n                    SType = StructureType.ExportMemoryAllocateInfo,\n                    PNext = &dedicatedAllocation\n                };\n\n                ImportMemoryWin32HandleInfoKHR handleImport = default;\n                if (handleType == ExternalMemoryHandleTypeFlags.D3D11TextureBit && exportable)\n                {\n                    if (vk.D3DDevice.Handle == null)\n                        throw new NotSupportedException(\"Vulkan D3DDevice wasn't created\");\n                    _d3dTexture2D = D3DMemoryHelper.CreateMemoryHandle(vk.D3DDevice, size, Format);\n\n                    handleImport = new ImportMemoryWin32HandleInfoKHR\n                    {\n                        PNext = &dedicatedAllocation,\n                        SType = StructureType.ImportMemoryWin32HandleInfoKhr,\n                        HandleType = ExternalMemoryHandleTypeFlags.D3D11TextureBit,\n                        Handle = CreateDxgiSharedHandle()\n                    };\n                }\n\n                var memoryAllocateInfo = new MemoryAllocateInfo\n                {\n                    PNext =\n                        exportable ? handleImport.Handle != IntPtr.Zero ? &handleImport : &fdExport : null,\n                    SType = StructureType.MemoryAllocateInfo,\n                    AllocationSize = memoryRequirements.Size,\n                    MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex(","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/samples/GpuInterop/VulkanDemo/VulkanImage.cs#L125-L161","documentation":"On Windows the sample shares a D3D11 texture with Vulkan by importing a DXGI shared handle, which requires a Vulkan D3D device (vk.D3DDevice) created via D3D11On12 / VkD3D11ExternalMemory. The NotSupportedException fires when that interop D3D device is null while the code path needs it (handleType == D3D11TextureBit && exportable). It indicates the Windows-D3D external-memory bridge was never set up.","triggerScenarios":"Calling VulkanImage creation/export with ExternalMemoryHandleTypeFlags.D3D11TextureBit set as exportable, on Windows, before vk.D3DDevice has been initialized. Happens when the Vulkan demo's D3D interop device was skipped or failed silently.","commonSituations":"Running the demo on a system lacking VK_KHR_external_memory_win32; failing to create the D3D11On12 device; copy-paste of image-export code without setting up D3DMemoryHelper's backing device; Windows N editions missing d3d11.","solutions":["Ensure vk.D3DDevice is created before VulkanImage export on Windows — create the D3D11On12 device and assign it so Handle is non-null.","Verify the instance/device enable VK_KHR_external_memory, VK_KHR_external_memory_win32, and the dedicated-allocation extension.","If D3D sharing is not needed, do not set exportable with D3D11TextureBit (avoid this code path).","Run on Windows 10+ with a driver that exposes the external-memory-win32 extension."],"exampleFix":"// before\nif (vk.D3DDevice.Handle == null)\n    throw new NotSupportedException(\"Vulkan D3DDevice wasn't created\");\n\n// after (fail early with actionable guidance at device setup)\nif (vk.D3DDevice?.Handle is null)\n    throw new NotSupportedException(\n        \"Vulkan D3D interop device wasn't created. Enable VK_KHR_external_memory_win32 and create the D3D11On12 device before exporting a shared D3D11 texture.\");","handlingStrategy":"validation","validationCode":"// before exporting a shared D3D11 texture\nif (OperatingSystem.IsWindows() && exportable && handleType == ExternalMemoryHandleTypeFlags.D3D11TextureBit\n    && vk.D3DDevice?.Handle is null)\n{\n    // skip the D3D export path or create the device first\n}","typeGuard":"static bool CanExportD3D11(VkHandle vk) => vk.D3DDevice?.Handle is not null;","tryCatchPattern":"try { /* image creation/export that hits the D3D path */ }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"D3DDevice\"))\n{ /* fall back to a non-shared Vulkan image */ }","preventionTips":["Create the D3D11On12 device before image export on Windows.","Verify VK_KHR_external_memory_win32 is enabled on instance+device.","Do not set D3D11TextureBit+exportable unless you need D3D sharing."],"tags":["vulkan","d3d11","windows","external-memory","interop","sample"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}