{"record":{"id":"bbf95aa4652331f1","repo":"stride3d/stride","slug":"vkformat-inputformat-has-no-equivalent-pixelformat","errorCode":null,"errorMessage":"VkFormat '{inputFormat}' has no equivalent PixelFormat","messagePattern":"VkFormat '(.+?)' has no equivalent PixelFormat","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs","lineNumber":275,"sourceCode":"            VkFormat.R16G16B16A16Sint => PixelFormat.R16G16B16A16_SInt,\n            VkFormat.R32Uint => PixelFormat.R32_UInt,\n            VkFormat.R32Sint => PixelFormat.R32_SInt,\n            VkFormat.R32Sfloat => PixelFormat.R32_Float,\n            VkFormat.E5B9G9R9UfloatPack32 => PixelFormat.R9G9B9E5_Sharedexp,\n            VkFormat.R32G32Sfloat => PixelFormat.R32G32_Float,\n            VkFormat.R32G32Uint => PixelFormat.R32G32_UInt,\n            VkFormat.R32G32Sint => PixelFormat.R32G32_SInt,\n            VkFormat.R32G32B32Sfloat => PixelFormat.R32G32B32_Float,\n            VkFormat.R32G32B32Sint => PixelFormat.R32G32B32_SInt,\n            VkFormat.R32G32B32Uint => PixelFormat.R32G32B32_UInt,\n            VkFormat.R32G32B32A32Sfloat => PixelFormat.R32G32B32A32_Float,\n            VkFormat.R32G32B32A32Sint => PixelFormat.R32G32B32A32_SInt,\n            VkFormat.R32G32B32A32Uint => PixelFormat.R32G32B32A32_UInt,\n            VkFormat.D16Unorm => PixelFormat.D16_UNorm,\n            VkFormat.D24UnormS8Uint => PixelFormat.D24_UNorm_S8_UInt,\n            VkFormat.D32Sfloat => PixelFormat.D32_Float,\n            VkFormat.D32SfloatS8Uint => PixelFormat.D32_Float_S8X24_UInt,\n            _ => throw new NotSupportedException($\"VkFormat '{inputFormat}' has no equivalent PixelFormat\"),\n        };\n\n        public static VkFormat ConvertPixelFormat(PixelFormat inputFormat)\n        {\n            ConvertPixelFormat(inputFormat, out var format, out _, out _);\n            return format;\n        }\n\n        public static void ConvertPixelFormat(PixelFormat inputFormat, out VkFormat format, out int pixelSize, out bool compressed)\n        {\n            if (!TryConvertPixelFormat(inputFormat, out format, out pixelSize, out compressed))\n                throw new InvalidOperationException(\"Unsupported texture format: \" + inputFormat);\n        }\n\n        /// <summary>\n        /// Converts a <see cref=\"PixelFormat\"/> to its Vulkan equivalent.\n        /// </summary>\n        /// <returns><c>true</c> if the format has a Vulkan equivalent; otherwise <c>false</c> and <paramref name=\"format\"/> is <see cref=\"VkFormat.Undefined\"/>.</returns>","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs#L257-L293","documentation":"ConvertPixelFormat maps a Vulkan VkFormat back to Stride's PixelFormat enum. When a VkFormat has no entry in the mapping switch, it throws NotSupportedException naming the format. This happens for Vulkan formats Stride does not model (e.g. vendor-specific or packed formats returned by swapchain/surface queries).","triggerScenarios":"Calling VulkanConvertExtensions.ConvertPixelFormat(VkFormat) with a format not covered by the mapping table — commonly formats obtained from device/swapchain enumeration rather than ones Stride created.","commonSituations":"Querying Vulkan surface formats and feeding the result into Stride APIs; using a device whose preferred swapchain format has no PixelFormat equivalent; a newer Vulkan SDK adding formats unknown to the Stride version in use.","solutions":["Map the unknown VkFormat manually to the closest supported PixelFormat before calling Stride APIs","Restrict surface/device format selection to formats Stride supports (extend the switch if you own the fork)","Upgrade Stride — newer versions add more format mappings"],"exampleFix":"// before\nvar pixelFormat = VulkanConvertExtensions.ConvertPixelFormat(nativeFormat);\n// after\nif (nativeFormat != VkFormat.B8G8R8A8Unorm && nativeFormat != VkFormat.R8G8B8A8Unorm)\n    nativeFormat = VkFormat.B8G8R8A8Unorm; // fall back to a supported format\nvar pixelFormat = VulkanConvertExtensions.ConvertPixelFormat(nativeFormat);","handlingStrategy":"try-catch","validationCode":"// pre-check: only convert known-supported swapchain formats\nVkFormat[] supported = { VkFormat.B8G8R8A8Unorm, VkFormat.R8G8B8A8Unorm };\nif (!supported.Contains(nativeFormat)) nativeFormat = VkFormat.B8G8R8A8Unorm;","typeGuard":null,"tryCatchPattern":"try { pixelFormat = VulkanConvertExtensions.ConvertPixelFormat(nativeFormat); }\ncatch (NotSupportedException) { pixelFormat = PixelFormat.B8G8R8A8_UNorm; /* fallback */ }","preventionTips":["Pick surface formats from the intersection of Vulkan-supported and Stride-supported formats","Pin your Vulkan SDK/runtime to what your Stride version understands","Wrap format conversion at a single boundary so fallbacks are centralized"],"tags":["graphics","vulkan","pixel-format","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}