stride3d/stride · error · NotSupportedException

Texture Array is not supported for Texture3D

Error message

Texture Array is not supported for Texture3D

What it means

When building an image view, Stride computes layerCount and enters the layered-view branch if it is greater than 1. A Texture3D image cannot be viewed as an array with multiple layers in Vulkan, so the code throws NotSupportedException when Dimension == Texture3D and layerCount > 1. 3D textures must be viewed with a 3D view type covering all slices instead of per-layer array views.

Solutions

  1. Request a full 3D view (all slices) and select slices inside the shader via normalized w coordinates instead of array layers.
  2. Create a separate 2D texture per needed slice and copy slice data into it, then view the 2D textures.
  3. Pass an arrayOrDepthSlice that results in a single layer (layerCount == 1) if per-slice handling is required via other means.
  4. Restructure volume data as a Texture2D array if per-layer views are a hard requirement.

Example fix

// before
var view = texture3D.GetView(ViewType.Full, arrayOrDepthSlice: 0, mipIndex: 0); // spans all depth slices -> layerCount > 1
// after
copy slice 0 into a Texture2D, then:
var view = sliceTexture.GetView(ViewType.Full, 0, 0);
Defensive patterns

Strategy: validation

Validate before calling

if (texture.Dimension == TextureDimension.Texture3D && arrayOrDepthCount > 1)
    throw new ArgumentException("Do not request multi-layer views on Texture3D; use a full 3D view");

Type guard

bool SupportsLayeredView(Texture t) => t.Dimension != TextureDimension.Texture3D;

Try / catch

try
{
    var view = texture.GetView(ViewType.Full, 0, mipIndex);
}
catch (NotSupportedException)
{
    // copy slice(s) into a Texture2D and view that instead
}

Prevention

When it happens

Trigger: Calling GetImageView (via InitializeFromImpl) on a Texture3D where GetViewSliceBounds yields arrayOrDepthCount > 1 — e.g. requesting a view over multiple depth slices of a 3D texture.

Common situations: Attempting per-slice sampling or per-slice UAV access of a volume texture; porting D3D11 code that sliced 3D textures; misusing arrayOrDepthSlice parameters when a single-slice or full view was intended.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs:545

                sType = VkStructureType.ImageViewCreateInfo,
                pNext = &viewUsageInfo,
                format = NativeFormat, //VulkanConvertExtensions.ConvertPixelFormat(ViewFormat),
                image = NativeImage,
                components = VkComponentMapping.Identity,
                // For shader resource views, use only the depth aspect (not stencil) when sampling depth-stencil textures
                subresourceRange = new VkImageSubresourceRange(HasStencil ? VkImageAspectFlags.Depth : NativeImageAspect, (uint) mipIndex, (uint) mipCount, (uint) arrayOrDepthSlice, (uint) layerCount)
            };

            if (IsMultiSampled)
                throw new NotImplementedException();

            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
            {

View on GitHub (pinned to 96fad776d2)