{"record":{"id":"0acb5a378e4f8a9a","repo":"stride3d/stride","slug":"unexpected-dimension-0-from-dds-headerdx10","errorCode":null,"errorMessage":"Unexpected dimension [{0}] from DDS HeaderDX10","messagePattern":"Unexpected dimension \\[(.+?)\\] from DDS HeaderDX10","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Foundation/Graphics/DDSHelper.cs","lineNumber":381,"sourceCode":"                        description.Height = header.Height;\n                        description.Depth = 1;\n                        break;\n\n                    case DDS.ResourceDimension.Texture3D:\n                        if ((header.Flags & DDS.HeaderFlags.Volume) == 0)\n                            throw new InvalidOperationException(\"Texture3D missing HeaderFlags.Volume from DDS HeaderDX10\");\n\n                        if (description.ArraySize > 1)\n                            throw new InvalidOperationException(\"Unexpected ArraySize > 1 for Texture3D from DDS HeaderDX10\");\n\n                        description.Width = header.Width;\n                        description.Height = header.Height;\n                        description.Depth = header.Depth;\n                        description.Dimension = TextureDimension.Texture3D;\n                        break;\n\n                    default:\n                        throw new InvalidOperationException(string.Format(\"Unexpected dimension [{0}] from DDS HeaderDX10\", headerDX10.ResourceDimension));\n                }\n            }\n            else\n            {\n                description.ArraySize = 1;\n\n                if ((header.Flags & DDS.HeaderFlags.Volume) != 0)\n                {\n                    description.Width = header.Width;\n                    description.Height = header.Height;\n                    description.Depth = header.Depth;\n                    description.Dimension = TextureDimension.Texture3D;\n                }\n                else\n                {\n                    if ((header.CubemapFlags & DDS.CubemapFlags.CubeMap) != 0)\n                    {\n                        // We require all six faces to be defined","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/DDSHelper.cs#L363-L399","documentation":"Thrown by DecodeDDSHeader when a DDS file uses the DX10 extension header (HeaderDXT10) whose ResourceDimension field contains a value the parser does not recognize as Texture2D, Texture3D, or an accepted dimension. The library validates the enum strictly rather than guessing, because a wrong dimension would misinterpret the whole texture layout.","triggerScenarios":"Calling DirectXTex/Stride DDS loading APIs (e.g. DDSHelper.LoadDDSFromStream / Image.Load on a .dds) on a file whose DDSD_HEADER10 resourceDimension field is corrupted, zero, or written by a non-conformant tool with an out-of-range value (not 2/3/4 for 2D/3D/Cube-compatible dimensions).","commonSituations":"Hand-edited or truncated DDS files; DDS files exported by third-party tools that misfill the DX10 extension header; files renamed to .dds that are actually other formats; older texture pipeline tools producing nonstandard DX10 headers.","solutions":["Re-export the DDS with a conformant tool (texconv, Compressonator, or the engine's exporter) so resourceDimension is a valid D3D10_RESOURCE_DIMENSION value.","Inspect bytes 32-35 of the DX10 extension header (offset 128+20 in the file) and confirm resourceDimension is 2 (TEXTURE2D) or 3 (TEXTURE3D).","If the texture is a plain 2D texture, re-save it without the DX10 extension header (legacy DDS header) so this code path is skipped.","Catch InvalidOperationException around the decode call and reject/fall back for the offending asset."],"exampleFix":"// before\nclassifyDds(file);\n\n// after\ntry { classifyDds(file); }\ncatch (InvalidOperationException e) when (e.Message.Contains(\"DDS HeaderDX10\"))\n{\n    log.Error($\"{file}: invalid DX10 resourceDimension, re-export the texture\");\n}","handlingStrategy":"try-catch","validationCode":"// resourceDimension is the first uint of the DX10 header (offset 128+20)\nuint dim = BitConverter.ToUInt32(ddsBytes, 128 + 20);\nbool hasDx10 = BitConverter.ToUInt32(ddsBytes, 128 - 4 + 16 * 7) != 0 || ddsBytes.Length > 128 + 20;\nif (hasDx10 && dim != 2 && dim != 3)\n    throw new InvalidDataException($\"DDS DX10 resourceDimension {dim} is invalid\");","typeGuard":"bool IsValidDx10Dimension(uint dim) => dim is 2 or 3; // TEXTURE2D or TEXTURE3D","tryCatchPattern":"try { texture = DdsLoader.Load(stream); }\ncatch (InvalidOperationException e) when (e.Message.Contains(\"from DDS HeaderDX10\"))\n{\n    ReportInvalidAsset(assetPath, e.Message);\n}","preventionTips":["Export DDS only with conformant tools (texconv, Compressonator)","Validate asset headers at import time in the content pipeline","Never hand-edit DDS binary headers"],"tags":["dds","texture-loading","invalid-data"],"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"}