stride3d/stride · error · InvalidOperationException
A texture with size [ ] already exist with the same output…
Error message
A texture with size [{0}] already exist with the same output size What it means
Each output of an ImageMultiScaler must have a unique size, because the scaler keeps one output per size step. PrepareScaling throws InvalidOperationException when a newly added output texture has the same Size as one already registered in outputTextures.
Solutions
- Give every output texture a distinct Size before adding it to the scaler.
- Fix size-computation loops so consecutive outputs differ (check integer rounding: Math.Max(1, size >> level) collisions).
- Check the message's size value and find the duplicate SetOutput call producing that dimension.
Example fix
// before for (int i = 0; i < levels; i++) scaler.SetOutput(i, RenderTexture(w >> i, h >> i)); // level rounding may duplicate // after var used = new HashSet<Size3>(); foreach (var size in ComputeDistinctSizes()) if (used.Add(size)) scaler.SetOutput(...);
Defensive patterns
Strategy: validation
Validate before calling
var seen = new HashSet<Size3>();
foreach (var o in outputs)
if (!seen.Add(o.Size)) throw new InvalidOperationException($"Duplicate output size {o.Size}"); Try / catch
try { scaler.Draw(context); }
catch (InvalidOperationException) { Log.Warning("Duplicate multi-scaler output size; removing duplicate"); } Prevention
- Deduplicate generated mip-level sizes (watch integer rounding collisions like w>>i == w>>(i+1) near 1).
- Use a HashSet of sizes when programmatically adding outputs.
- Verify each SetOutput call uses a distinct texture size.
When it happens
Trigger: Adding two output textures with identical dimensions to the same ImageMultiScaler (e.g. two mip-like outputs both at half input resolution) and rendering.
Common situations: Loop-generated outputs with a rounding bug making two sizes collide (integer division); copy-pasted SetOutput calls using the same size texture; UI code that binds the same render target twice.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Unsupported texture size
- Input and output texture cannot have same size
- Custom strides is not supported with packed PixelFormats
- output
- Source texture is not a MSAA texture.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/053cd428f90c6f30.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageScaler/ImageMultiScaler.cs:154
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));
}
}
// If the textrue is valid use it
outputTextures.Add(outputTexture);
}
}
return outputTextures.Count > 0;
}
private Texture FindOutputMatchingSize(Size3 targetSize, int scalingDirection)
{
for (int i = 0; i < outputTextures.Count; i++)
{
var outputTexture = outputTextures[i];
if (outputTexture == null)
{View on GitHub (pinned to 96fad776d2)