{"record":{"id":"6e80490e6d9d53bf","repo":"stride3d/stride","slug":"texture-array-is-not-supported-for-3d-textures-direct3d12","errorCode":null,"errorMessage":"Texture Array is not supported for 3D Textures","messagePattern":"Texture Array is not supported for 3D Textures","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs","lineNumber":692,"sourceCode":"\n                // Initialize for Texture Arrays or Texture Cube\n                if (ArraySize > 1)\n                {\n                    if (MultisampleCount > MultisampleCount.None)\n                    {\n                        if (Dimension != TextureDimension.Texture2D)\n                        {\n                            throw new NotSupportedException(\"Multisample is only supported for 2D Textures\");\n                        }\n                        rtvDescription.ViewDimension = RtvDimension.Texture2Dmsarray;\n                        rtvDescription.Texture2DMSArray.ArraySize = (uint)arrayCount;\n                        rtvDescription.Texture2DMSArray.FirstArraySlice = (uint)arrayOrDepthSlice;\n                    }\n                    else // Non-multisampled\n                    {\n                        if (Dimension == TextureDimension.Texture3D)\n                        {\n                            throw new NotSupportedException(\"Texture Array is not supported for 3D Textures\");\n                        }\n                        rtvDescription.ViewDimension = Dimension is TextureDimension.Texture2D or TextureDimension.TextureCube\n                            ? RtvDimension.Texture2Darray\n                            : RtvDimension.Texture1Darray;\n\n                        // Use rtvDescription.Texture1DArray as it matches also Texture memory layout\n                        rtvDescription.Texture1DArray.ArraySize = (uint) arrayCount;\n                        rtvDescription.Texture1DArray.FirstArraySlice = (uint) arrayOrDepthSlice;\n                        rtvDescription.Texture1DArray.MipSlice = (uint) mipIndex;\n                    }\n                }\n                else // Regular Texture (1D, 2D, 3D)\n                {\n                    if (IsMultiSampled)\n                    {\n                        if (Dimension != TextureDimension.Texture2D)\n                        {\n                            throw new NotSupportedException(\"Multisample is only supported for 2D Render Target Textures\");","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs#L674-L710","documentation":"A non-multisampled render-target texture with ArraySize > 1 maps to a Texture2DArray/Texture1DArray RTV in D3D12. D3D12 has no arrayed RTV dimension for 3D textures, so when Dimension is Texture3D and ArraySize > 1 the backend throws during InitializeFromImpl.","triggerScenarios":"Creating a 3D texture (TextureDescription.New3D or Dimension = Texture3D) with ArraySize > 1 and IsRenderTarget true, then initializing it on the Direct3D12 device.","commonSituations":"Confusing the depth dimension of a 3D texture (DimensionCount/Z) with array slices; setting ArraySize on a volumetric render target by mistake; porting Vulkan-style 3D-array images.","solutions":["Set ArraySize = 1 for 3D render-target textures; encode layers in the texture's depth instead.","Use a 2D texture array (Dimension = Texture2D) if you need multiple renderable layers.","Render volumetric data by slicing: bind individual Z slices via a 2D view or use compute shaders with UAVs instead."],"exampleFix":"// before\nvar desc = TextureDescription.New3D(128, 128, 64, false, PixelFormat.R16G16B16A16.Float);\ndesc.ArraySize = 4;\n// after\nvar desc = TextureDescription.New3D(128, 128, 64, false, PixelFormat.R16G16B16A16.Float);\ndesc.ArraySize = 1;","handlingStrategy":"validation","validationCode":"if (desc.IsRenderTarget && desc.ArraySize > 1 && desc.Dimension == TextureDimension.Texture3D)\n    throw new InvalidOperationException(\"3D render targets cannot have ArraySize > 1.\");","typeGuard":null,"tryCatchPattern":"try { texture.InitializeFrom(device, desc); }\ncatch (NotSupportedException) { desc.ArraySize = 1; texture.InitializeFrom(device, desc); }","preventionTips":["Keep ArraySize = 1 for 3D textures; use Z for layers.","Use 2D texture arrays when you need multiple renderable layers.","Validate descriptions in one helper before calling any Texture.New* API."],"tags":["direct3d12","texture3d","render-target","array"],"backgroundTag":"unsupported-operation","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"}