stride3d/stride · error · InvalidOperationException
TextureCube must have an arraysize = 6
Error message
TextureCube must have an arraysize = 6
What it means
A TextureCube image must have an ArraySize that is a multiple of 6, because a cube map is exactly six 2D faces (+X, -X, +Y, -Y, +Z, -Z) per cube in the array. Initialize enforces this so downstream mip/face indexing stays valid.
Solutions
- Set ArraySize to exactly 6 for a single cube map (6 * N for a cube array).
- If you only need one face, use TextureDimension.Texture2D with ArraySize = 1 instead.
- Fix the DDS/source header so its array size matches the cube-map flag.
Example fix
// before
var desc = new ImageDescription { Dimension = TextureDimension.TextureCube, Width = 256, Height = 256, Depth = 1, ArraySize = 1 };
// after
var desc = new ImageDescription { Dimension = TextureDimension.TextureCube, Width = 256, Height = 256, Depth = 1, ArraySize = 6 }; Defensive patterns
Strategy: validation
Validate before calling
if (desc.Dimension == TextureDimension.TextureCube && desc.ArraySize % 6 != 0)
throw new ArgumentException($"TextureCube ArraySize must be a multiple of 6, got {desc.ArraySize}."); Type guard
null
Try / catch
try { img = Image.NewCube(width, height, mipCount, format); }
catch (InvalidOperationException ex) when (ex.Message.Contains("arraysize = 6"))
{
desc.ArraySize = 6;
img = Image.New(desc, ptr);
} Prevention
- Use Image.NewCube so ArraySize is set correctly for you.
- Remember cube arrays need ArraySize = 6 * cubeCount.
- Validate DDS headers: cubemap flag implies arraySize 6.
- If you need a single face, use Texture2D, not TextureCube.
When it happens
Trigger: Creating an Image with Dimension = TextureDimension.TextureCube and ArraySize not divisible by 6 (e.g. 1, 2, 4, 7).
Common situations: Setting ArraySize = 1 from a 2D-style description and only switching Dimension to TextureCube; loading a DDS file whose header array count is inconsistent with the cube flag; allocating a single-face cube map by mistake.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Unsupported DXGI Format
- Cannot specify custom stride with mipmaps
- Invalid Width/Height/Depth/ArraySize for Image 1D
- Invalid Width/Height/Depth/ArraySize for Image 2D
- Invalid Width/Height/Depth/ArraySize for Image 3D
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f507399b588c3f02.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Foundation/Graphics/Image.cs:791
switch (description.Dimension)
{
case TextureDimension.Texture1D:
if (description.Width <= 0 || description.Height != 1 || description.Depth != 1 || description.ArraySize == 0)
throw new InvalidOperationException("Invalid Width/Height/Depth/ArraySize for Image 1D");
// Check that miplevels are fine
description.MipLevels = CalculateMipLevels(description.Width, 1, description.MipLevels);
break;
case TextureDimension.Texture2D:
case TextureDimension.TextureCube:
if (description.Width <= 0 || description.Height <= 0 || description.Depth != 1 || description.ArraySize == 0)
throw new InvalidOperationException("Invalid Width/Height/Depth/ArraySize for Image 2D");
if (description.Dimension == TextureDimension.TextureCube)
{
if ((description.ArraySize % 6) != 0)
throw new InvalidOperationException("TextureCube must have an arraysize = 6");
}
// Check that miplevels are fine
description.MipLevels = CalculateMipLevels(description.Width, description.Height, description.MipLevels);
break;
case TextureDimension.Texture3D:
if (description.Width <= 0 || description.Height <= 0 || description.Depth <= 0 || description.ArraySize != 1)
throw new InvalidOperationException("Invalid Width/Height/Depth/ArraySize for Image 3D");
// Check that miplevels are fine
description.MipLevels = CalculateMipLevels(description.Width, description.Height, description.Depth, description.MipLevels);
break;
}
// Calculate mipmaps
mipMapToZIndex = CalculateImageArray(description, pitchFlags, rowStride, out var pixelBufferCount, out totalSizeInBytes);
mipmapDescriptions = CalculateMipMapDescription(description);View on GitHub (pinned to 96fad776d2)