{"record":{"id":"8a30e7ecae4e9da6","repo":"stride3d/stride","slug":"source-texture-is-not-a-msaa-texture-commandlist-direct3d12","errorCode":null,"errorMessage":"Source Texture is not a MSAA Texture","messagePattern":"Source Texture is not a MSAA Texture","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs","lineNumber":1656,"sourceCode":"        ///            <item>The source (or destination) format could be <see cref=\"PixelFormat.R16G16B16A16_UNorm\"/>.</item>\n        ///            <item>The destination (or source) format could be <see cref=\"PixelFormat.R16G16B16A16_Float\"/>.</item>\n        ///          </list>\n        ///        </para>\n        ///      </description>\n        ///    </item>\n        ///   </list>\n        /// </remarks>\n        public void CopyMultisample(Texture sourceMultiSampledTexture, int sourceSubResourceIndex,\n                                    Texture destinationTexture, int destinationSubResourceIndex,\n                                    PixelFormat format = PixelFormat.None)\n        {\n            ArgumentNullException.ThrowIfNull(sourceMultiSampledTexture);\n            ArgumentNullException.ThrowIfNull(destinationTexture);\n\n            RecordDebugCounter(DebugCounterKind.Copy);\n\n            if (!sourceMultiSampledTexture.IsMultiSampled)\n                throw new ArgumentException(\"Source Texture is not a MSAA Texture\", nameof(sourceMultiSampledTexture));\n\n            ResourceBarrierTransition(sourceMultiSampledTexture, BarrierLayout.ResolveSource);\n            ResourceBarrierTransition(destinationTexture, BarrierLayout.ResolveDest);\n            FlushResourceBarriers();\n\n            currentCommandList.NativeCommandList.ResolveSubresource(sourceMultiSampledTexture.NativeResource, (uint) sourceSubResourceIndex,\n                                                                    destinationTexture.NativeResource, (uint) destinationSubResourceIndex,\n                                                                    (Format)(format == PixelFormat.None ? destinationTexture.Format : format));\n        }\n\n        /// <summary>\n        ///   Copies a region from a source Graphics Resource to a destination Graphics Resource.\n        /// </summary>\n        /// <param name=\"source\">The source Graphics Resource to copy from.</param>\n        /// <param name=\"sourceSubResourceIndex\">The index of the sub-resource of <paramref name=\"source\"/> to copy from.</param>\n        /// <param name=\"sourceRegion\">\n        ///   <para>\n        ///     An optional <see cref=\"ResourceRegion\"/> that defines the source sub-resource to copy from.","sourceCodeStart":1638,"sourceCodeEnd":1674,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/CommandList.Direct3D12.cs#L1638-L1674","documentation":"CommandList.Resolve(sourceMultiSampledTexture, ...) performs an MSAA resolve on D3D12 via ResolveSubresource. It throws ArgumentException when the source texture's IsMultiSampled is false, because resolving a non-multisampled resource is meaningless on D3D12 and would fail at the native level.","triggerScenarios":"Calling CommandList.Resolve(source, destination, ...) where source.MultiSampleCount is 1 / TextureFlags not created with multisampling — i.e. a plain single-sample texture passed as the MSAA source.","commonSituations":"Passing the wrong texture (the resolved target instead of the MSAA source) after swapping arguments; MSAA disabled in device settings but resolve path still executed; textures created without TextureFlags or multisample count > 1.","solutions":["Pass a texture created with MultiSampleCount > 1 as the source.","Check source.IsMultiSampled before calling Resolve and branch to a plain Copy for non-MSAA sources.","Verify source/destination arguments were not swapped."],"exampleFix":"// before\nvar src = Texture.New2D(device, w, h, fmt, TextureFlags.RenderTarget); // not MSAA\ncommandList.Resolve(src, dst, 0); // throws\n\n// after\nvar src = Texture.New2D(device, w, h, fmt, TextureFlags.RenderTarget, 4); // 4x MSAA\ncommandList.Resolve(src, dst, 0);","handlingStrategy":"validation","validationCode":"if (sourceMultiSampledTexture == null || destinationTexture == null)\n    throw new ArgumentNullException(nameof(sourceMultiSampledTexture));\nif (!sourceMultiSampledTexture.IsMultiSampled)\n    throw new InvalidOperationException(\"Resolve requires a multisampled source texture\");","typeGuard":"bool IsMsaaSource(Texture t) => t != null && t.IsMultiSampled;","tryCatchPattern":"try\n{\n    commandList.Resolve(source, destination, subResourceIndex);\n}\ncatch (ArgumentException ex) when (ex.ParamName == nameof(sourceMultiSampledTexture))\n{\n    commandList.Copy(source, destination, subResourceIndex); // non-MSAA fallback path\n}","preventionTips":["Create MSAA render targets with MultiSampleCount > 1 when a resolve will follow.","Branch between Resolve and Copy based on IsMultiSampled at a single helper method.","Check that source/destination arguments were not swapped at call sites."],"tags":["direct3d12","graphics","msaa","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"}