{"record":{"id":"c46f1cb28d9baaac","repo":"stride3d/stride","slug":"unsupported-pixelformat-from-dds-header","errorCode":null,"errorMessage":"Unsupported PixelFormat from DDS Header","messagePattern":"Unsupported PixelFormat from DDS Header","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Foundation/Graphics/DDSHelper.cs","lineNumber":420,"sourceCode":"\n                        description.ArraySize = 6;\n                        description.Dimension = TextureDimension.TextureCube;\n                    }\n                    else\n                    {\n                        description.Dimension = TextureDimension.Texture2D;\n                    }\n\n                    description.Width = header.Width;\n                    description.Height = header.Height;\n                    description.Depth = 1;\n                    // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture\n                }\n\n                description.Format = GetDXGIFormat(ref header.PixelFormat, flags, out convFlags);\n\n                if (description.Format == PixelFormat.None)\n                    throw new InvalidOperationException(\"Unsupported PixelFormat from DDS Header\");\n            }\n\n            // Special flag for handling BGR DXGI 1.1 formats\n            if ((flags & DDSFlags.ForceRgb) != 0)\n            {\n                switch ((PixelFormat) description.Format)\n                {\n                    case PixelFormat.B8G8R8A8_UNorm:\n                        description.Format = PixelFormat.R8G8B8A8_UNorm;\n                        convFlags |= ConversionFlags.Swizzle;\n                        break;\n\n                    case PixelFormat.B8G8R8X8_UNorm:\n                        description.Format = PixelFormat.R8G8B8A8_UNorm;\n                        convFlags |= ConversionFlags.Swizzle | ConversionFlags.NoAlpha;\n                        break;\n\n                    case PixelFormat.B8G8R8A8_Typeless:","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/DDSHelper.cs#L402-L438","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-encode the texture to a supported format (BC1/BC3/BC7, R8G8B8A8, etc.) with texconv or Compressonator.","Check the DDS pixel-format FOURCC and confirm it is in the engine's supported PixelFormat list.","If the format exists but should be supported, extend GetDXGIFormat's mapping table for that FOURCC/bitmask.","Catch the InvalidOperationException per-asset and substitute a placeholder texture."],"exampleFix":"// before\nvar img = Image.Load(ddsBytes);\n\n// after\ntry { var img = Image.Load(ddsBytes); }\ncatch (InvalidOperationException e) when (e.Message == \"Unsupported PixelFormat from DDS Header\")\n{\n    img = ConvertDdsToSupportedFormat(ddsBytes); // e.g. texconv -f BC7\n}","handlingStrategy":"validation","validationCode":"// check the FOURCC (offset 4+80 in DDS header) against supported codecs\nuint fourcc = BitConverter.ToUInt32(ddsBytes, 4 + 84 - 4); // ddspf.fourcc\nvar supported = new HashSet<uint> { 0x20 /*DXT1*/, 0x21, 0x22, 0x64 /*BC7*/, 0, 28 /*uncompressed*/ };\nif (!supported.Contains(fourcc))\n    Console.WriteLine($\"DDS FOURCC 0x{fourcc:X} may be unsupported; re-encode\");","typeGuard":null,"tryCatchPattern":"try { image = Image.Load(ddsBytes); }\ncatch (InvalidOperationException e) when (e.Message == \"Unsupported PixelFormat from DDS Header\")\n{\n    image = null; // schedule external re-encode to BC7/R8G8B8A8\n}","preventionTips":["Restrict content pipeline to supported formats (BC1/BC3/BC5/BC7, R8G8B8A8)","Scan assets for exotic FOURCCs at import","Keep YUV/vendor-codec files out of the texture folder"],"tags":["dds","pixelformat","unsupported"],"backgroundTag":"unsupported-operation","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"}