{"record":{"id":"4156b1fd6d975b5f","repo":"stride3d/stride","slug":"texture-cube-views-require-a-layercount-which-is-a-multiple","errorCode":null,"errorMessage":"Texture cube views require a layerCount which is a multiple of 6","messagePattern":"Texture cube views require a layerCount which is a multiple of 6","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs","lineNumber":556,"sourceCode":"\n            if (IsMultiSampled && Dimension != TextureDimension.Texture2D)\n                throw new NotSupportedException(\"Multisample is only supported for 2D Textures\");\n\n            if (layerCount > 1)\n            {\n                if (Dimension == TextureDimension.Texture3D)\n                    throw new NotSupportedException(\"Texture Array is not supported for Texture3D\");\n\n                switch (Dimension)\n                {\n                    case TextureDimension.Texture1D:\n                        createInfo.viewType = VkImageViewType.Image1DArray;\n                        break;\n                    case TextureDimension.Texture2D:\n                        createInfo.viewType = VkImageViewType.Image2DArray;\n                        break;\n                    case TextureDimension.TextureCube:\n                        if (layerCount % 6 != 0) throw new NotSupportedException(\"Texture cube views require a layerCount which is a multiple of 6\");\n\n                        createInfo.viewType = layerCount > 6 ? VkImageViewType.ImageCubeArray : VkImageViewType.ImageCube;\n                        break;\n                }\n            }\n            else\n            {\n                switch (Dimension)\n                {\n                    case TextureDimension.Texture1D:\n                        createInfo.viewType = VkImageViewType.Image1D;\n                        break;\n                    case TextureDimension.Texture2D:\n                    case TextureDimension.TextureCube:\n                        createInfo.viewType = VkImageViewType.Image2D;\n                        break;\n                    case TextureDimension.Texture3D:\n                        createInfo.viewType = VkImageViewType.Image3D;","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs#L538-L574","documentation":"For TextureCube dimensions with a layered view (layerCount > 1), Vulkan requires the layer count to be a multiple of 6, since each cube face is one layer (a cube array is 6k layers). Stride validates this in GetImageView and throws NotSupportedException when layerCount % 6 != 0.","triggerScenarios":"Requesting a view of a TextureCube where the computed arrayOrDepthCount exceeds 1 but is not a multiple of 6 — e.g. viewing only some faces of a cube map, or a slice range cutting across cube faces.","commonSituations":"Attempting to view a subset of cube faces (e.g. 2 faces of a skybox); slicing a cube array with face-granularity offsets that don't align to 6; passing wrong arrayOrDepthSlice bounds for cube textures.","solutions":["View either a single face (layerCount == 1, not this branch) or the whole cube (layerCount == 6) / whole cube arrays (multiple of 6).","Adjust arrayOrDepthSlice bounds so the covered layer range aligns to full cubes.","Copy the needed faces into a separate cube texture or 2D texture and view that instead.","If partial-face rendering is required, render to individual face textures rather than a sliced cube view."],"exampleFix":"// before\nvar view = cubeTexture.GetView(ViewType.Full, arrayOrDepthSlice: 0, mipIndex: 0); // layerCount resolved to 4 -> % 6 != 0\n// after\nvar view = cubeTexture.GetView(ViewType.Full, arrayOrDepthSlice: 0, mipIndex: 0); // full cube: layerCount == 6","handlingStrategy":"validation","validationCode":"if (texture.Dimension == TextureDimension.TextureCube && layerCount > 1 && layerCount % 6 != 0)\n    throw new ArgumentException(\"Cube views need a layerCount that is a multiple of 6\");","typeGuard":"bool IsValidCubeLayerCount(int layerCount) => layerCount <= 1 || layerCount % 6 == 0;","tryCatchPattern":"try\n{\n    var view = cubeTexture.GetView(ViewType.Full, arrayOrDepthSlice, mipIndex);\n}\ncatch (NotSupportedException)\n{\n    // widen slice range to full cube(s) or copy faces to another texture\n}","preventionTips":["View whole cubes (6 layers) or single faces, never partial face sets","Keep cube-array slicing aligned to 6-layer boundaries","Compute layer ranges from cube counts, not raw slice numbers","Prefer dedicated face textures for partial-face rendering"],"tags":["vulkan","graphics","cubemap","texture-view","layer-count"],"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"}