{"record":{"id":"f507399b588c3f02","repo":"stride3d/stride","slug":"texturecube-must-have-an-arraysize-6","errorCode":null,"errorMessage":"TextureCube must have an arraysize = 6","messagePattern":"TextureCube must have an arraysize = 6","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Foundation/Graphics/Image.cs","lineNumber":791,"sourceCode":"            switch (description.Dimension)\n            {\n                case TextureDimension.Texture1D:\n                    if (description.Width <= 0 || description.Height != 1 || description.Depth != 1 || description.ArraySize == 0)\n                        throw new InvalidOperationException(\"Invalid Width/Height/Depth/ArraySize for Image 1D\");\n\n                    // Check that miplevels are fine\n                    description.MipLevels = CalculateMipLevels(description.Width, 1, description.MipLevels);\n                    break;\n\n                case TextureDimension.Texture2D:\n                case TextureDimension.TextureCube:\n                    if (description.Width <= 0 || description.Height <= 0 || description.Depth != 1 || description.ArraySize == 0)\n                        throw new InvalidOperationException(\"Invalid Width/Height/Depth/ArraySize for Image 2D\");\n\n                    if (description.Dimension == TextureDimension.TextureCube)\n                    {\n                        if ((description.ArraySize % 6) != 0)\n                            throw new InvalidOperationException(\"TextureCube must have an arraysize = 6\");\n                    }\n\n                    // Check that miplevels are fine\n                    description.MipLevels = CalculateMipLevels(description.Width, description.Height, description.MipLevels);\n                    break;\n\n                case TextureDimension.Texture3D:\n                    if (description.Width <= 0 || description.Height <= 0 || description.Depth <= 0 || description.ArraySize != 1)\n                        throw new InvalidOperationException(\"Invalid Width/Height/Depth/ArraySize for Image 3D\");\n\n                    // Check that miplevels are fine\n                    description.MipLevels = CalculateMipLevels(description.Width, description.Height, description.Depth, description.MipLevels);\n                    break;\n            }\n\n            // Calculate mipmaps\n            mipMapToZIndex = CalculateImageArray(description, pitchFlags, rowStride, out var pixelBufferCount, out totalSizeInBytes);\n            mipmapDescriptions = CalculateMipMapDescription(description);","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Foundation/Graphics/Image.cs#L773-L809","documentation":"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.","triggerScenarios":"Creating an Image with Dimension = TextureDimension.TextureCube and ArraySize not divisible by 6 (e.g. 1, 2, 4, 7).","commonSituations":"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.","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."],"exampleFix":"// before\nvar desc = new ImageDescription { Dimension = TextureDimension.TextureCube, Width = 256, Height = 256, Depth = 1, ArraySize = 1 };\n// after\nvar desc = new ImageDescription { Dimension = TextureDimension.TextureCube, Width = 256, Height = 256, Depth = 1, ArraySize = 6 };","handlingStrategy":"validation","validationCode":"if (desc.Dimension == TextureDimension.TextureCube && desc.ArraySize % 6 != 0)\n    throw new ArgumentException($\"TextureCube ArraySize must be a multiple of 6, got {desc.ArraySize}.\");","typeGuard":"null","tryCatchPattern":"try { img = Image.NewCube(width, height, mipCount, format); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"arraysize = 6\"))\n{\n    desc.ArraySize = 6;\n    img = Image.New(desc, ptr);\n}","preventionTips":["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."],"tags":["graphics","cubemap","textures","stride"],"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"}