{"record":{"id":"a1b8e9e32d256fab","repo":"stride3d/stride","slug":"source-texture-is-not-a-msaa-texture-msaaresolver","errorCode":null,"errorMessage":"Source texture is not a MSAA texture.","messagePattern":"Source texture is not a MSAA texture\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Compositing/MSAAResolver.cs","lineNumber":153,"sourceCode":"        }\n\n        protected override void InitializeCore()\n        {\n            base.InitializeCore();\n            ToLoadAndUnload(msaaResolver);\n            ToLoadAndUnload(msaaDepthResolver);\n        }\n\n        protected override void DrawCore(RenderDrawContext drawContext)\n        {\n            var input = GetInput(0);\n            var output = GetOutput(0);\n            if (input == null)\n                throw new ArgumentNullException(nameof(input));\n            if (output == null)\n                throw new ArgumentNullException(nameof(output));\n            if (!input.IsMultiSampled)\n                throw new ArgumentOutOfRangeException(nameof(input), \"Source texture is not a MSAA texture.\");\n            if (output.IsMultiSampled)\n                throw new ArgumentOutOfRangeException(nameof(input), \"Destination texture is a MSAA texture.\");\n\n            // Prepare\n            int samplesCount = (int)input.MultisampleCount;\n            var inputSize = input.Size;\n            // SvPosUnpack = float4(float2(0.5, -0.5) * TextureSize, float2(0.5, 0.5) * TextureSize))\n            // TextureSizeLess1 = TextureSize - 1\n            var svPosUnpack = new Vector4(0.5f * inputSize.Width, -0.5f * inputSize.Height, 0.5f * inputSize.Width, 0.5f * inputSize.Height);\n            var textureSizeLess1 = new Vector2(inputSize.Width - 1.0f, inputSize.Height - 1.0f);\n\n            if (input.IsDepthStencil)\n            {\n                System.Diagnostics.Debug.Assert(output.IsDepthStencil, \"input and output IsDepthStencil don't match\");\n\n                // Resolve using custom pixel shader (output depth only)\n                msaaDepthResolver.DepthStencilState = new DepthStencilStateDescription(true, true) { DepthBufferFunction = CompareFunction.Always };\n                msaaDepthResolver.Parameters.Set(MSAAResolverParams.MSAASamples, samplesCount);","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Compositing/MSAAResolver.cs#L135-L171","documentation":"MSAAResolver exists to convert a multisampled (MSAA) texture into a regular resolved texture. DrawCore validates input.IsMultiSampled and throws ArgumentOutOfRangeException when the source texture is NOT multisampled, because the MSAA-resolve shader is meaningless (and would sample garbage) on a plain texture.","triggerScenarios":"Assigning a non-MSAA texture (MultisampleCount == 1 / IsMultiSampled == false) to MSAAResolver's input slot 0 and rendering.","commonSituations":"MSAA disabled in the graphics profile/device settings so the color target is created single-sampled; binding the already-resolved output of a previous resolve pass back into the resolver; switching anti-aliasing mode from MSAA to FXAA/none without removing the resolver from the compositing graph.","solutions":["Create the source render target with MultisampleCount > 1 so it is genuinely an MSAA texture.","Enable MSAA in the game settings / GraphicsDevice profile so upstream targets are multisampled.","Remove or bypass MSAAResolver when the pipeline is not using MSAA."],"exampleFix":"// before\nvar target = PushRenderTexture(width, height); // non-MSAA\nresolver.SetInput(0, target, null);\n// after\nvar msaaTarget = PushRenderTexture(width, height, 0, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget, 4); // 4x MSAA\nresolver.SetInput(0, msaaTarget, null);","handlingStrategy":"validation","validationCode":"if (!input.IsMultiSampled)\n    throw new InvalidOperationException(\"MSAAResolver input must be an MSAA texture\");\nresolver.SetInput(0, input, null);","typeGuard":"bool IsMsaaSource(Texture t) => t != null && t.IsMultiSampled;","tryCatchPattern":"try { resolver.SetInput(0, texture, null); }\ncatch (ArgumentOutOfRangeException ex) { Log.Error(\"Input texture must be MSAA; enable MSAA or remove resolver.\", ex); }","preventionTips":["Create source targets with MultisampleCount > 1 whenever MSAA is enabled.","Check GraphicsProfile / anti-aliasing settings match pipeline expectations.","Bypass MSAAResolver entirely when MSAA is disabled."],"tags":["rendering","msaa","texture","argument-out-of-range","stride"],"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"}