stride3d/stride · error · InvalidOperationException
Unsupported texture format:
Error message
Unsupported texture format:
What it means
This ConvertPixelFormat overload converts a Stride PixelFormat to a VkFormat, pixel size, and compression flag. It delegates to TryConvertPixelFormat and throws InvalidOperationException with 'Unsupported texture format: <format>' when the PixelFormat has no Vulkan equivalent (e.g. certain compressed or legacy formats).
Solutions
- Use a widely supported PixelFormat (e.g. R8G8B8A8_UNorm, BC1/BC3 where supported)
- Pre-convert asset textures to a supported format at import time
- Call TryConvertPixelFormat first to check support and fall back gracefully
- Upgrade Stride for a broader format table
Example fix
// before
var vkFormat = VulkanConvertExtensions.ConvertPixelFormat(PixelFormat.BC2_UNorm);
// after
if (VulkanConvertExtensions.TryConvertPixelFormat(PixelFormat.BC3_UNorm, out _, out _, out _))
var vkFormat = VulkanConvertExtensions.ConvertPixelFormat(PixelFormat.BC3_UNorm);
else
/* transcode or choose another format */; Defensive patterns
Strategy: try-catch
Validate before calling
if (!VulkanConvertExtensions.TryConvertPixelFormat(inputFormat, out _, out var pixelSize, out var compressed))
{
// choose alternate format or transcode asset
} Try / catch
try { vkFormat = VulkanConvertExtensions.ConvertPixelFormat(inputFormat); }
catch (InvalidOperationException) { vkFormat = VulkanConvertExtensions.ConvertPixelFormat(PixelFormat.R8G8B8A8_UNorm); } Prevention
- Call TryConvertPixelFormat first to probe support
- Normalize imported assets to commonly supported formats at build time
- Keep a fallback PixelFormat table for the Vulkan backend
When it happens
Trigger: Creating a texture or uploading data with a PixelFormat that TryConvertPixelFormat does not recognize — the throw happens during ConvertPixelFormat called from texture initialization.
Common situations: Requesting an unusual or legacy pixel format (e.g. some block-compressed or extended formats) on the Vulkan backend; loading assets authored for DirectX with formats Vulkan cannot express in this Stride version.
Related errors
- VkFormat ' ' has no equivalent PixelFormat
- argumentsBuffer
- Custom strides is not supported with packed PixelFormats
- ' ' is already an sRGB pixel format
- ' ' is not a sRGB format
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/2d307df7f0a1c4d1.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs:287
VkFormat.R32G32B32A32Sint => PixelFormat.R32G32B32A32_SInt,
VkFormat.R32G32B32A32Uint => PixelFormat.R32G32B32A32_UInt,
VkFormat.D16Unorm => PixelFormat.D16_UNorm,
VkFormat.D24UnormS8Uint => PixelFormat.D24_UNorm_S8_UInt,
VkFormat.D32Sfloat => PixelFormat.D32_Float,
VkFormat.D32SfloatS8Uint => PixelFormat.D32_Float_S8X24_UInt,
_ => throw new NotSupportedException($"VkFormat '{inputFormat}' has no equivalent PixelFormat"),
};
public static VkFormat ConvertPixelFormat(PixelFormat inputFormat)
{
ConvertPixelFormat(inputFormat, out var format, out _, out _);
return format;
}
public static void ConvertPixelFormat(PixelFormat inputFormat, out VkFormat format, out int pixelSize, out bool compressed)
{
if (!TryConvertPixelFormat(inputFormat, out format, out pixelSize, out compressed))
throw new InvalidOperationException("Unsupported texture format: " + inputFormat);
}
/// <summary>
/// Converts a <see cref="PixelFormat"/> to its Vulkan equivalent.
/// </summary>
/// <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>
public static bool TryConvertPixelFormat(PixelFormat inputFormat, out VkFormat format, out int pixelSize, out bool compressed)
{
compressed = false;
// TODO VULKAN: Complete supported formats
switch (inputFormat)
{
//case PixelFormat.A8_UNorm:
// format = VkFormat.;
// pixelSize = 1;
// break;
case PixelFormat.R8_UNorm:View on GitHub (pinned to 96fad776d2)