{"record":{"id":"b89c9fe1b2be3da8","repo":"stride3d/stride","slug":"multisample-is-only-supported-for-2d-render-target-textures","errorCode":null,"errorMessage":"Multisample is only supported for 2D Render Target Textures","messagePattern":"Multisample is only supported for 2D Render Target Textures","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs","lineNumber":710,"sourceCode":"                            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\");\n                        }\n                        rtvDescription.ViewDimension = RtvDimension.Texture2Dms;\n                    }\n                    else // Non-multisampled Texture\n                    {\n                        switch (Dimension)\n                        {\n                            case TextureDimension.Texture1D:\n                                rtvDescription.ViewDimension = RtvDimension.Texture1D;\n                                rtvDescription.Texture1D.MipSlice = (uint) mipIndex;\n                                break;\n\n                            case TextureDimension.Texture2D:\n                                rtvDescription.ViewDimension = RtvDimension.Texture2D;\n                                rtvDescription.Texture2D.MipSlice = (uint) mipIndex;\n                                break;\n\n                            case TextureDimension.Texture3D:","sourceCodeStart":692,"sourceCodeEnd":728,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/Texture.Direct3D12.cs#L692-L728","documentation":"For a single (ArraySize == 1) render-target texture that is multisampled, the D3D12 backend uses a Texture2DMS RTV, which only exists for 2D textures. A multisampled 1D or 3D render target has no matching D3D12 view dimension, so InitializeFromImpl throws.","triggerScenarios":"Creating a Texture with ArraySize == 1, MultisampleCount > MultisampleCount.None, IsRenderTarget true, and Dimension equal to Texture1D or Texture3D.","commonSituations":"Enabling MSAA on a 1D gradient/lookup render target; leaving a global MultisampleCount setting enabled while switching a render target to 3D; template-based texture creation that copies MSAA flags.","solutions":["Use Dimension = TextureDimension.Texture2D for any multisampled render target.","Set MultisampleCount = MultisampleCount.None on non-2D render targets.","Render into a plain 1D/3D target without MSAA, or resolve from a 2D MSAA source."],"exampleFix":"// before\nvar desc = TextureDescription.New1D(1024, PixelFormat.R8G8B8A8.UNorm, usage: GraphicsResourceUsage.RenderTarget);\ndesc.MultisampleCount = MultisampleCount.X8;\n// after\nvar desc = TextureDescription.New1D(1024, PixelFormat.R8G8B8A8.UNorm, usage: GraphicsResourceUsage.RenderTarget);\ndesc.MultisampleCount = MultisampleCount.None;","handlingStrategy":"validation","validationCode":"if (desc.IsRenderTarget && desc.MultisampleCount > MultisampleCount.None && desc.Dimension != TextureDimension.Texture2D)\n    throw new InvalidOperationException(\"MSAA render targets must be 2D textures.\");","typeGuard":null,"tryCatchPattern":"try { texture.InitializeFrom(device, desc); }\ncatch (NotSupportedException ex) { logger.Warn(ex); desc.MultisampleCount = MultisampleCount.None; texture.InitializeFrom(device, desc); }","preventionTips":["Only enable MultisampleCount on Texture2D render targets.","Add a debug-time assertion in texture factory helpers.","Keep MSAA configuration in a single settings object that enforces the 2D-only rule."],"tags":["direct3d12","multisampling","render-target","texture"],"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"}