stride3d/stride · error · InvalidOperationException

Unexpected Height != 1 from DDS HeaderDX10

Error message

Unexpected Height != 1 from DDS HeaderDX10 

What it means

Per the DDS/DirectXTex convention, 1D textures always have height 1. When the DX10 header declares ResourceDimension == Texture1D but the legacy DDS header carries a Height flag with a value other than 1, the file is internally inconsistent, so DecodeDDSHeader throws.

Solutions

  1. Re-export the texture as a proper 1D or 2D texture with a standard tool
  2. If it is actually a 2D texture, fix ResourceDimension in the DX10 header to Texture2D
  3. If truly 1D, set the header height to 1 and clear the Height flag if your writer allows

Example fix

// before (DDS header)
ResourceDimension = Texture1D; Height = 64
// after
ResourceDimension = Texture1D; Height = 1
Defensive patterns

Strategy: validation

Validate before calling

// If DX10 ResourceDimension == Texture1D, verify legacy header height == 1
if (resourceDimension == 1 /*Texture1D*/) {
    uint height = BitConverter.ToUInt32(ddsBytes, 12);
    bool hasHeightFlag = (BitConverter.ToUInt32(ddsBytes, 8) & 0x2 /*HEIGHT*/) != 0;
    if (hasHeightFlag && height != 1) throw new InvalidOperationException("DDS declares Texture1D but height != 1");
}

Try / catch

try { image = Image.Load(ddsBytes); } catch (InvalidOperationException ex) when (ex.Message.Contains("Unexpected Height != 1")) { // regenerate asset as proper 1D/2D texture
    throw new AssetLoadException("Malformed 1D texture DDS; re-export", ex); }

Prevention

When it happens

Trigger: Loading a DDS with DX10 extension where ResourceDimension is Texture1D but the DX9 header has DDS_HEADER_FLAGS_HEIGHT set and height != 1 — usually from a malformed writer or manual edit.

Common situations: Custom exporters that write 1D texture dimensions incorrectly, files converted between dimensions by hand-edited headers, corrupted files.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

                var headerDX10 = *(DDS.HeaderDXT10*) ((byte*) headerPtr + sizeof (int) + Unsafe.SizeOf<DDS.Header>());
                convFlags |= ConversionFlags.DX10;

                description.ArraySize = headerDX10.ArraySize;
                if (description.ArraySize == 0)
                    throw new InvalidOperationException("Unexpected ArraySize == 0 from DDS HeaderDX10 ");

                description.Format = headerDX10.DXGIFormat;
                if (!description.Format.IsValid)
                    throw new InvalidOperationException("Invalid Format from DDS HeaderDX10 ");

                switch (headerDX10.ResourceDimension)
                {
                    case DDS.ResourceDimension.Texture1D:

                        // D3DX writes 1D textures with a fixed Height of 1
                        if ((header.Flags & DDS.HeaderFlags.Height) != 0 && header.Height != 1)
                            throw new InvalidOperationException("Unexpected Height != 1 from DDS HeaderDX10 ");

                        description.Width = header.Width;
                        description.Height = 1;
                        description.Depth = 1;
                        description.Dimension = TextureDimension.Texture1D;
                        break;

                    case DDS.ResourceDimension.Texture2D:
                        if ((headerDX10.MiscFlags & DDS.ResourceOptionFlags.TextureCube) != 0)
                        {
                            description.ArraySize *= 6;
                            description.Dimension = TextureDimension.TextureCube;
                        }
                        else
                        {
                            description.Dimension = TextureDimension.Texture2D;
                        }

View on GitHub (pinned to 96fad776d2)