{"record":{"id":"83497e7c8a338aa8","repo":"AvaloniaUI/Avalonia","slug":"not-supported-format","errorCode":null,"errorMessage":"Not supported format","messagePattern":"Not supported format","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"samples/GpuInterop/VulkanDemo/D3DMemoryHelper.cs","lineNumber":74,"sourceCode":"        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),\n            CPUAccessFlags = 0,\n            MiscFlags = (uint)(ResourceMiscFlag.SharedKeyedmutex | ResourceMiscFlag.SharedNthandle)\n        };\n        ThrowHResult(device.CreateTexture2D(&textureDesc, (SubresourceData*)null, texture.GetAddressOf()));\n\n        return texture;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/samples/GpuInterop/VulkanDemo/D3DMemoryHelper.cs#L56-L92","documentation":"Thrown by D3DMemoryHelper.CreateMemoryHandle (ArgumentException) when the requested VulkanFormat is anything other than R8G8B8A8Unorm. The D3D11 shared texture is hardcoded to Format.FormatR8G8B8A8Unorm for the Vulkan/D3D memory-handle interop, so only that format is accepted.","triggerScenarios":"Calling CreateMemoryHandle(device, size, format) with format != VulkanFormat.R8G8B8A8Unorm (e.g. BGRA, RGB, compressed, or HDR formats). Any other format is rejected before the texture is created.","commonSituations":"Rendering pipeline configured for BGRA8 (common on Windows) but the interop expects RGBA8; passing a swapchain/surface format directly; HDR or 10-bit format requested for the shared handle.","solutions":["Convert/rendezvous the source data to VulkanFormat.R8G8B8A8Unorm before calling CreateMemoryHandle.","If BGRA is required, swizzle the pixels to RGBA8 or extend the helper to support FormatR8G8B8A8->BGRA mapping.","Validate the format at the call site and surface a clear message instead of letting the interop throw."],"exampleFix":"// before\nvar handle = D3DMemoryHelper.CreateMemoryHandle(device, size, VulkanFormat.B8G8R8A8Unorm); // throws\n\n// after\nvar handle = D3DMemoryHelper.CreateMemoryHandle(device, size, VulkanFormat.R8G8B8A8Unorm);","handlingStrategy":"validation","validationCode":"if (format != VulkanFormat.R8G8B8A8Unorm) { /* convert source to RGBA8 before calling */ }","typeGuard":"static bool IsSupportedInteropFormat(VulkanFormat f) => f == VulkanFormat.R8G8B8A8Unorm;","tryCatchPattern":"try { return D3DMemoryHelper.CreateMemoryHandle(device, size, format); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Not supported format\")) { /* swizzle to RGBA8 and retry */ throw; }","preventionTips":["Standardize interop textures on R8G8B8A8Unorm.","Swizzle BGRA8 sources to RGBA8 before creating the shared handle.","Validate the format at the call site with a clear message."],"tags":["sample","gpu","vulkan","direct3d","interop","format","csharp","argument"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}