stride3d/stride · error · ArgumentOutOfRangeException
Destination texture is a MSAA texture.
Error message
Destination texture is a MSAA texture.
What it means
DrawCore validates output.IsMultiSampled and throws ArgumentOutOfRangeException when the destination texture is itself multisampled. The resolver's job is to produce a single-sampled texture, so writing into another MSAA texture is unsupported; note the message incorrectly uses nameof(input) even though it validates the output.
Solutions
- Create the destination texture with MultisampleCount = 1 (non-MSAA).
- Ensure input and output are two distinct textures, not the same MSAA target.
- If you need MSAA output, don't use MSAAResolver — it resolves MSAA to non-MSAA by design.
Example fix
// before resolver.SetOutput(0, msaaTarget); // MSAA texture as destination // after var resolved = PushRenderTexture(width, height, 0, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget, 1); // single-sampled resolver.SetOutput(0, resolved);
Defensive patterns
Strategy: validation
Validate before calling
if (output.IsMultiSampled)
throw new InvalidOperationException("MSAAResolver output must NOT be an MSAA texture");
resolver.SetOutput(0, output); Type guard
bool IsResolvedTarget(Texture t) => t != null && !t.IsMultiSampled;
Try / catch
try { resolver.SetOutput(0, texture); }
catch (ArgumentOutOfRangeException ex) { Log.Error("Destination texture must be single-sampled.", ex); } Prevention
- Always create the resolved target with MultisampleCount = 1.
- Never reuse the MSAA source texture as the output.
- Keep separate factory helpers for MSAA vs resolved target creation to avoid flag mix-ups.
When it happens
Trigger: Binding an MSAA texture (IsMultiSampled == true) to MSAAResolver's output slot 0 and rendering.
Common situations: Reusing the same multisampled render target for input and output; creating the resolved target with the same MultisampleCount as the source by copying target-creation code; chaining two resolvers where the second one's output was accidentally created as MSAA.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/a79d2adec327a3b5.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Compositing/MSAAResolver.cs:155
protected override void InitializeCore()
{
base.InitializeCore();
ToLoadAndUnload(msaaResolver);
ToLoadAndUnload(msaaDepthResolver);
}
protected override void DrawCore(RenderDrawContext drawContext)
{
var input = GetInput(0);
var output = GetOutput(0);
if (input == null)
throw new ArgumentNullException(nameof(input));
if (output == null)
throw new ArgumentNullException(nameof(output));
if (!input.IsMultiSampled)
throw new ArgumentOutOfRangeException(nameof(input), "Source texture is not a MSAA texture.");
if (output.IsMultiSampled)
throw new ArgumentOutOfRangeException(nameof(input), "Destination texture is a MSAA texture.");
// Prepare
int samplesCount = (int)input.MultisampleCount;
var inputSize = input.Size;
// SvPosUnpack = float4(float2(0.5, -0.5) * TextureSize, float2(0.5, 0.5) * TextureSize))
// TextureSizeLess1 = TextureSize - 1
var svPosUnpack = new Vector4(0.5f * inputSize.Width, -0.5f * inputSize.Height, 0.5f * inputSize.Width, 0.5f * inputSize.Height);
var textureSizeLess1 = new Vector2(inputSize.Width - 1.0f, inputSize.Height - 1.0f);
if (input.IsDepthStencil)
{
System.Diagnostics.Debug.Assert(output.IsDepthStencil, "input and output IsDepthStencil don't match");
// Resolve using custom pixel shader (output depth only)
msaaDepthResolver.DepthStencilState = new DepthStencilStateDescription(true, true) { DepthBufferFunction = CompareFunction.Always };
msaaDepthResolver.Parameters.Set(MSAAResolverParams.MSAASamples, samplesCount);
msaaDepthResolver.Parameters.Set(MSAADepthResolverShaderKeys.SvPosUnpack, svPosUnpack);
msaaDepthResolver.Parameters.Set(MSAADepthResolverShaderKeys.TextureSizeLess1, textureSizeLess1);View on GitHub (pinned to 96fad776d2)