stride3d/stride · error · InvalidOperationException

Unsupported texture size

Error message

Unsupported texture size [{0}] out of limit [{1} - {2}]

What it means

ImageMultiScaler.PrepareScaling validates each output texture's Size against configured min/max limits and throws InvalidOperationException when the output size falls outside that range. The scaler's internal passes only work correctly within these dimensions.

Solutions

  1. Clamp output texture dimensions to within MinSize/MaxSize before assigning them as scaler outputs.
  2. Guard window-resize code so render targets are never created with degenerate sizes (e.g. minimum 1x1 or a configured floor).
  3. Inspect the message values: [0] is the offending size, [1]-[2] the allowed range, and adjust the render target allocation accordingly.

Example fix

// before
var output = RenderTexture(size.Width, size.Height); // size may be 0
// after
var w = Math.Max(minSize, Math.Min(maxSize, size.Width));
var h = Math.Max(minSize, Math.Min(maxSize, size.Height));
var output = RenderTexture(w, h);
Defensive patterns

Strategy: validation

Validate before calling

if (outSize < scaler.MinSize || outSize > scaler.MaxSize)
    outSize = Math.Clamp(outSize, scaler.MinSize, scaler.MaxSize);

Try / catch

try { scaler.Draw(context); }
catch (InvalidOperationException e) { Log.Error($"Scaler output size unsupported: {e.Message}"); }

Prevention

When it happens

Trigger: Rendering with an ImageMultiScaler whose output texture dimensions are smaller than MinSize or larger than MaxSize (per the scaler's configured limits), e.g. a 1x1 or an oversized render target.

Common situations: Dynamically resizing a render target to 0/tiny dimensions on window minimize; allocating an output larger than the supported limit for the current graphics profile.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/f45ab80d8f9e2cfe. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageScaler/ImageMultiScaler.cs:134

            var inputSize = inputTexture.Size;
            for (int i = 0; i < OutputCount; i++)
            {
                var outputTexture = GetOutput(i);
                if (outputTexture != null)
                {
                    // 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)

View on GitHub (pinned to 96fad776d2)