stride3d/stride · error · InvalidOperationException

Unsupported PixelFormat from DDS Header

Error message

Unsupported PixelFormat from DDS Header

What it means

Thrown by DecodeDDSHeader when GetDXGIFormat cannot map the DDS pixel format (the ddspf block, possibly with conversion flags) to any supported PixelFormat, returning PixelFormat.None. The library throws instead of loading a texture whose pixel data it cannot interpret.

Solutions

  1. Re-encode the texture to a supported format (BC1/BC3/BC7, R8G8B8A8, etc.) with texconv or Compressonator.
  2. Check the DDS pixel-format FOURCC and confirm it is in the engine's supported PixelFormat list.
  3. If the format exists but should be supported, extend GetDXGIFormat's mapping table for that FOURCC/bitmask.
  4. Catch the InvalidOperationException per-asset and substitute a placeholder texture.

Example fix

// before
var img = Image.Load(ddsBytes);

// after
try { var img = Image.Load(ddsBytes); }
catch (InvalidOperationException e) when (e.Message == "Unsupported PixelFormat from DDS Header")
{
    img = ConvertDdsToSupportedFormat(ddsBytes); // e.g. texconv -f BC7
}
Defensive patterns

Strategy: validation

Validate before calling

// check the FOURCC (offset 4+80 in DDS header) against supported codecs
uint fourcc = BitConverter.ToUInt32(ddsBytes, 4 + 84 - 4); // ddspf.fourcc
var supported = new HashSet<uint> { 0x20 /*DXT1*/, 0x21, 0x22, 0x64 /*BC7*/, 0, 28 /*uncompressed*/ };
if (!supported.Contains(fourcc))
    Console.WriteLine($"DDS FOURCC 0x{fourcc:X} may be unsupported; re-encode");

Try / catch

try { image = Image.Load(ddsBytes); }
catch (InvalidOperationException e) when (e.Message == "Unsupported PixelFormat from DDS Header")
{
    image = null; // schedule external re-encode to BC7/R8G8B8A8
}

Prevention

When it happens

Trigger: Loading a .dds whose FOURCC/pixel-format descriptor uses an unsupported compression (e.g. exotic FOURCC codes, YUV, or a custom codec) or an unusual uncompressed RGB bit layout that the format table does not cover.

Common situations: DDS files from video tools (YUV fourcc), LUMINANCE or palette variants outside the supported set, files compressed with vendor-specific codecs, or DDS headers with bit counts the converter does not handle.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/c46f1cb28d9baaac. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Foundation/Graphics/DDSHelper.cs:420

                        description.ArraySize = 6;
                        description.Dimension = TextureDimension.TextureCube;
                    }
                    else
                    {
                        description.Dimension = TextureDimension.Texture2D;
                    }

                    description.Width = header.Width;
                    description.Height = header.Height;
                    description.Depth = 1;
                    // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture
                }

                description.Format = GetDXGIFormat(ref header.PixelFormat, flags, out convFlags);

                if (description.Format == PixelFormat.None)
                    throw new InvalidOperationException("Unsupported PixelFormat from DDS Header");
            }

            // Special flag for handling BGR DXGI 1.1 formats
            if ((flags & DDSFlags.ForceRgb) != 0)
            {
                switch ((PixelFormat) description.Format)
                {
                    case PixelFormat.B8G8R8A8_UNorm:
                        description.Format = PixelFormat.R8G8B8A8_UNorm;
                        convFlags |= ConversionFlags.Swizzle;
                        break;

                    case PixelFormat.B8G8R8X8_UNorm:
                        description.Format = PixelFormat.R8G8B8A8_UNorm;
                        convFlags |= ConversionFlags.Swizzle | ConversionFlags.NoAlpha;
                        break;

                    case PixelFormat.B8G8R8A8_Typeless:

View on GitHub (pinned to 96fad776d2)