stride3d/stride · error · NotSupportedException
Texture cube views require a layerCount which is a multiple…
Error message
Texture cube views require a layerCount which is a multiple of 6
What it means
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.
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.
Example fix
// before var view = cubeTexture.GetView(ViewType.Full, arrayOrDepthSlice: 0, mipIndex: 0); // layerCount resolved to 4 -> % 6 != 0 // after var view = cubeTexture.GetView(ViewType.Full, arrayOrDepthSlice: 0, mipIndex: 0); // full cube: layerCount == 6
Defensive patterns
Strategy: validation
Validate before calling
if (texture.Dimension == TextureDimension.TextureCube && layerCount > 1 && layerCount % 6 != 0)
throw new ArgumentException("Cube views need a layerCount that is a multiple of 6"); Type guard
bool IsValidCubeLayerCount(int layerCount) => layerCount <= 1 || layerCount % 6 == 0;
Try / catch
try
{
var view = cubeTexture.GetView(ViewType.Full, arrayOrDepthSlice, mipIndex);
}
catch (NotSupportedException)
{
// widen slice range to full cube(s) or copy faces to another texture
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- ViewSlice.MipBand is not supported for render targets
- TextureCube must have an arraysize = 6
- Invalid texture datas. First dimension must be equal to 6
- Cannot create a Texture View with flags
- Cannot swap texture views; only root textures can be…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/4156b1fd6d975b5f.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs:556
if (IsMultiSampled && Dimension != TextureDimension.Texture2D)
throw new NotSupportedException("Multisample is only supported for 2D Textures");
if (layerCount > 1)
{
if (Dimension == TextureDimension.Texture3D)
throw new NotSupportedException("Texture Array is not supported for Texture3D");
switch (Dimension)
{
case TextureDimension.Texture1D:
createInfo.viewType = VkImageViewType.Image1DArray;
break;
case TextureDimension.Texture2D:
createInfo.viewType = VkImageViewType.Image2DArray;
break;
case TextureDimension.TextureCube:
if (layerCount % 6 != 0) throw new NotSupportedException("Texture cube views require a layerCount which is a multiple of 6");
createInfo.viewType = layerCount > 6 ? VkImageViewType.ImageCubeArray : VkImageViewType.ImageCube;
break;
}
}
else
{
switch (Dimension)
{
case TextureDimension.Texture1D:
createInfo.viewType = VkImageViewType.Image1D;
break;
case TextureDimension.Texture2D:
case TextureDimension.TextureCube:
createInfo.viewType = VkImageViewType.Image2D;
break;
case TextureDimension.Texture3D:
createInfo.viewType = VkImageViewType.Image3D;View on GitHub (pinned to 96fad776d2)