AvaloniaUI/Avalonia · error · NotSupportedException
Vulkan D3DDevice wasn't created
Error message
Vulkan D3DDevice wasn't created
What it means
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.
Source
Thrown at samples/GpuInterop/VulkanDemo/VulkanImage.cs:143
out var memoryRequirements);
var dedicatedAllocation = new MemoryDedicatedAllocateInfoKHR
{
SType = StructureType.MemoryDedicatedAllocateInfoKhr, Image = image
};
var fdExport = new ExportMemoryAllocateInfo
{
HandleTypes = handleType,
SType = StructureType.ExportMemoryAllocateInfo,
PNext = &dedicatedAllocation
};
ImportMemoryWin32HandleInfoKHR handleImport = default;
if (handleType == ExternalMemoryHandleTypeFlags.D3D11TextureBit && exportable)
{
if (vk.D3DDevice.Handle == null)
throw new NotSupportedException("Vulkan D3DDevice wasn't created");
_d3dTexture2D = D3DMemoryHelper.CreateMemoryHandle(vk.D3DDevice, size, Format);
handleImport = new ImportMemoryWin32HandleInfoKHR
{
PNext = &dedicatedAllocation,
SType = StructureType.ImportMemoryWin32HandleInfoKhr,
HandleType = ExternalMemoryHandleTypeFlags.D3D11TextureBit,
Handle = CreateDxgiSharedHandle()
};
}
var memoryAllocateInfo = new MemoryAllocateInfo
{
PNext =
exportable ? handleImport.Handle != IntPtr.Zero ? &handleImport : &fdExport : null,
SType = StructureType.MemoryAllocateInfo,
AllocationSize = memoryRequirements.Size,
MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex(View on GitHub (pinned to 11c5427268)
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.
Example fix
// before
if (vk.D3DDevice.Handle == null)
throw new NotSupportedException("Vulkan D3DDevice wasn't created");
// after (fail early with actionable guidance at device setup)
if (vk.D3DDevice?.Handle is null)
throw new NotSupportedException(
"Vulkan D3D interop device wasn't created. Enable VK_KHR_external_memory_win32 and create the D3D11On12 device before exporting a shared D3D11 texture."); Defensive patterns
Strategy: validation
Validate before calling
// before exporting a shared D3D11 texture
if (OperatingSystem.IsWindows() && exportable && handleType == ExternalMemoryHandleTypeFlags.D3D11TextureBit
&& vk.D3DDevice?.Handle is null)
{
// skip the D3D export path or create the device first
} Type guard
static bool CanExportD3D11(VkHandle vk) => vk.D3DDevice?.Handle is not null;
Try / catch
try { /* image creation/export that hits the D3D path */ }
catch (NotSupportedException ex) when (ex.Message.Contains("D3DDevice"))
{ /* fall back to a non-shared Vulkan image */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Device with the corresponding LUID not found
- Not supported format
- Unable to export IOSurfaceRef
- Need skia to dump textures, sorry
- Unable to export IOSurfaceRef
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/9223282665062981.
Report an issue: GitHub.