{"record":{"id":"01487b795645dca3","repo":"stride3d/stride","slug":"unexpected-arraysize-0-from-dds-headerdx10","errorCode":null,"errorMessage":"Unexpected ArraySize == 0 from DDS HeaderDX10 ","messagePattern":"Unexpected ArraySize == 0 from DDS HeaderDX10 ","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Foundation/Graphics/DDSHelper.cs","lineNumber":331,"sourceCode":"\n            // Setup MipLevels\n            description.MipLevels = header.MipMapCount;\n            if (description.MipLevels == 0)\n                description.MipLevels = 1;\n\n            // Check for DX10 extension\n            if ((header.PixelFormat.Flags & DDS.PixelFormatFlags.FourCC) != 0 && (new FourCC('D', 'X', '1', '0') == header.PixelFormat.FourCC))\n            {\n                // Buffer must be big enough for both headers and magic value\n                if (size < (Unsafe.SizeOf<DDS.Header>() + sizeof (uint) + Unsafe.SizeOf<DDS.HeaderDXT10>()))\n                    return false;\n\n                var headerDX10 = *(DDS.HeaderDXT10*) ((byte*) headerPtr + sizeof (int) + Unsafe.SizeOf<DDS.Header>());\n                convFlags |= ConversionFlags.DX10;\n\n                description.ArraySize = headerDX10.ArraySize;\n                if (description.ArraySize == 0)\n                    throw new InvalidOperationException(\"Unexpected ArraySize == 0 from DDS HeaderDX10 \");\n\n                description.Format = headerDX10.DXGIFormat;\n                if (!description.Format.IsValid)\n                    throw new InvalidOperationException(\"Invalid Format from DDS HeaderDX10 \");\n\n                switch (headerDX10.ResourceDimension)\n                {\n                    case DDS.ResourceDimension.Texture1D:\n\n                        // D3DX writes 1D textures with a fixed Height of 1\n                        if ((header.Flags & DDS.HeaderFlags.Height) != 0 && header.Height != 1)\n                            throw new InvalidOperationException(\"Unexpected Height != 1 from DDS HeaderDX10 \");\n\n                        description.Width = header.Width;\n                        description.Height = 1;\n                        description.Depth = 1;\n                        description.Dimension = TextureDimension.Texture1D;\n                        break;","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/DDSHelper.cs#L313-L349","documentation":"A DDS file with an extended DX10 header declares texture arrays via ArraySize. Stride (following DirectXTex) treats ArraySize == 0 as invalid — a resource must have at least one array element — so DecodeDDSHeader throws InvalidOperationException.","triggerScenarios":"Loading a DDS file whose HeaderDXT10.ArraySize field is 0, produced by a tool/bad writer or corrupted file.","commonSituations":"DDS files written by buggy custom exporters, files corrupted in transit, older/incorrect tools writing DX10 headers incorrectly.","solutions":["Fix or regenerate the DDS file with ArraySize >= 1 using a reliable tool (texconv, image studio)","Inspect the file's DX10 header bytes (offset 128+20) to confirm the bad ArraySize","Convert the texture to a format without a DX10 header (plain DX9-style DDS) as a workaround","Patch ArraySize to 1 in the file if you know the texture is a single image"],"exampleFix":"// before (DDS DX10 header, 4-byte DWORD at offset 128+20)\nArraySize = 0\n// after\nArraySize = 1","handlingStrategy":"validation","validationCode":"// Check DX10 header ArraySize before decoding (after magic+DX9 header at offset 128)\nint dx10Offset = 128 + 20;\nif (hasDx10Header && BitConverter.ToUInt32(ddsBytes, dx10Offset) == 0)\n    throw new InvalidOperationException(\"DDS DX10 header has ArraySize == 0; file is malformed\");","typeGuard":null,"tryCatchPattern":"try { image = Image.Load(ddsBytes); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"ArraySize == 0\")) { // treat as corrupt asset\n    log.Error(\"Corrupt DDS (ArraySize=0); regenerate with texconv\"); throw; }","preventionTips":["Validate DDS assets at import time in the content pipeline","Standardize on mainstream tools (texconv) for DDS generation","Add a pre-commit asset lint that checks DX10 header fields","Hash-and-version control source textures to detect corruption"],"tags":["dds","textures","header-validation","file-format"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}