{"record":{"id":"8b68e9464fc13c7e","repo":"stride3d/stride","slug":"texture-array-is-not-supported-for-texture3d","errorCode":null,"errorMessage":"Texture Array is not supported for Texture3D","messagePattern":"Texture Array is not supported for Texture3D","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs","lineNumber":545,"sourceCode":"                sType = VkStructureType.ImageViewCreateInfo,\n                pNext = &viewUsageInfo,\n                format = NativeFormat, //VulkanConvertExtensions.ConvertPixelFormat(ViewFormat),\n                image = NativeImage,\n                components = VkComponentMapping.Identity,\n                // For shader resource views, use only the depth aspect (not stencil) when sampling depth-stencil textures\n                subresourceRange = new VkImageSubresourceRange(HasStencil ? VkImageAspectFlags.Depth : NativeImageAspect, (uint) mipIndex, (uint) mipCount, (uint) arrayOrDepthSlice, (uint) layerCount)\n            };\n\n            if (IsMultiSampled)\n                throw new NotImplementedException();\n\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            {","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs#L527-L563","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Request a full 3D view (all slices) and select slices inside the shader via normalized w coordinates instead of array layers.","Create a separate 2D texture per needed slice and copy slice data into it, then view the 2D textures.","Pass an arrayOrDepthSlice that results in a single layer (layerCount == 1) if per-slice handling is required via other means.","Restructure volume data as a Texture2D array if per-layer views are a hard requirement."],"exampleFix":"// before\nvar view = texture3D.GetView(ViewType.Full, arrayOrDepthSlice: 0, mipIndex: 0); // spans all depth slices -> layerCount > 1\n// after\ncopy slice 0 into a Texture2D, then:\nvar view = sliceTexture.GetView(ViewType.Full, 0, 0);","handlingStrategy":"validation","validationCode":"if (texture.Dimension == TextureDimension.Texture3D && arrayOrDepthCount > 1)\n    throw new ArgumentException(\"Do not request multi-layer views on Texture3D; use a full 3D view\");","typeGuard":"bool SupportsLayeredView(Texture t) => t.Dimension != TextureDimension.Texture3D;","tryCatchPattern":"try\n{\n    var view = texture.GetView(ViewType.Full, 0, mipIndex);\n}\ncatch (NotSupportedException)\n{\n    // copy slice(s) into a Texture2D and view that instead\n}","preventionTips":["Use full 3D views and select slices in-shader via w coordinates","Copy needed slices to 2D textures for per-slice access","Use Texture2D arrays when per-layer views are required","Avoid porting D3D11 3D-slice view patterns directly to Vulkan"],"tags":["vulkan","graphics","texture3d","texture-array","volume-texture"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}