stride3d/stride · error · InvalidOperationException
Input and output texture cannot have same size
Error message
Input and output texture cannot have same size [{0}] What it means
ImageMultiScaler is a scaling pass; it requires input and output textures to have different sizes. PrepareScaling throws InvalidOperationException when an output texture's size equals the input size, since upscaling/downscaling a texture onto one of identical dimensions is unsupported by this effect.
Solutions
- Ensure the output is strictly smaller or larger than the input; use a copy/blit (e.g. ImageScaler in copy mode or a SpriteBatch copy) if you need same-size transfer.
- Skip adding the texture as a multi-scaler output when its size equals the input size.
- Log/compare inputSize vs requested output size during setup to catch the equality early.
Example fix
// before scaler.SetOutput(0, RenderTexture(inputWidth, inputHeight)); // same size // after scaler.SetOutput(0, RenderTexture(inputWidth / 2, inputHeight / 2));
Defensive patterns
Strategy: validation
Validate before calling
if (outputSize == inputSize)
throw new InvalidOperationException("Use a copy/blit pass, not ImageMultiScaler, for same-size transfer"); Try / catch
try { scaler.Draw(context); }
catch (InvalidOperationException) { FallbackCopyPass(input, output); } Prevention
- Compute output size as a strict fraction/multiple (e.g. half) of input, never 1:1.
- Use a dedicated copy pass for same-size transfers.
- Assert outputSize != inputSize in texture setup helpers.
When it happens
Trigger: Connecting an output texture with exactly the same dimensions as the input texture (inputSize == outputSize) and rendering, so DrawCore calls PrepareScaling.
Common situations: Auto-sizing an output to match the input 'to keep it simple'; a resize handler that makes the backbuffer equal the source resolution; copy intent where the developer should have used a blit/copy pass instead of a scaler.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Only array of 2D textures are currently supported as output
- Only render targets are supported as output
- Only cubemaps are currently supported as input
- Unsupported texture size
- Support only output scaling to the same direction
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/6a33fe4a5d921d97.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageScaler/ImageMultiScaler.cs:139
{
// Verify pixel format
if (outputPixelFormat != PixelFormat.None && outputPixelFormat != outputTexture.ViewFormat)
{
throw new InvalidOperationException("Output texture format [{0}] is not matching other output texture format [{1}]".ToFormat(outputTexture.ViewFormat, outputPixelFormat));
}
outputPixelFormat = outputTexture.ViewFormat;
var outputSize = outputTexture.Size;
// Verify pixel format
if (outputSize < minSize || outputSize > maxSize)
{
throw new InvalidOperationException("Unsupported texture size [{0}] out of limit [{1} - {2}]".ToFormat(outputTexture.Size, minSize, maxSize));
}
if (inputSize == outputSize)
{
throw new InvalidOperationException("Input and output texture cannot have same size [{0}]".ToFormat(inputSize));
}
int newScalingDirection = outputSize.CompareTo(inputSize);
if (scalingDirection != 0 && Math.Sign(scalingDirection) != Math.Sign(newScalingDirection))
{
throw new InvalidOperationException("Support only output scaling to the same direction");
}
scalingDirection = newScalingDirection;
// Check that we are scaling to different texture sizes
foreach (var existingOutput in outputTextures)
{
if (existingOutput.Size == outputTexture.Size)
{
throw new InvalidOperationException("A texture with size [{0}] already exist with the same output size".ToFormat(existingOutput.Size));
}
}
View on GitHub (pinned to 96fad776d2)