stride3d/stride · error · InvalidOperationException

Output texture format

Error message

Output texture format [{0}] is not matching other output texture format [{1}]

What it means

ImageMultiScaler.PrepareScaling (invoked from DrawCore) supports multiple output textures but requires all of them to share the same pixel format. When iterating outputs, if a texture's ViewFormat differs from the format established by a previous output, it throws InvalidOperationException. The scaler builds one shared scaling pipeline, so mixed formats would render incorrectly.

Solutions

  1. Make every output texture connected to the ImageMultiScaler use the same PixelFormat/ViewFormat.
  2. Check the error text: the first formatted value is the offending texture's format, the second is the established format; change the mismatched one.
  3. If outputs genuinely need different formats, use separate ImageScaler instances instead of one ImageMultiScaler.

Example fix

// before
scaler.SetOutput(0, rtRgba8);   // Rgba8
scaler.SetOutput(1, rtBgra8);   // Bgra8 -> throws
// after
scaler.SetOutput(0, rtRgba8);
scaler.SetOutput(1, rtRgba8b);  // same format
Defensive patterns

Strategy: validation

Validate before calling

var formats = outputs.Select(o => o.ViewFormat).Distinct().ToList();
if (formats.Count > 1) throw new InvalidOperationException($"All ImageMultiScaler outputs must share one format, got: {string.Join(", ", formats)}");

Try / catch

try { scaler.Draw(context); }
catch (InvalidOperationException) { Log.Warning("ImageMultiScaler output formats mismatch — skipping pass"); }

Prevention

When it happens

Trigger: Adding two or more outputs to an ImageMultiScaler whose ViewFormats differ (e.g. one output is Rgba8 and another is Bgra8 or R11G11B10Float), then rendering a frame that triggers DrawCore.

Common situations: Wiring multiple render targets/swap-chain backbuffers with different formats into one multi-scaler; an engine/asset format change (e.g. HDR pipeline switching to half-float) leaving one output on the old format.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

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

            // Query all ouptut
            outputTextures.Clear();

            outputPixelFormat = PixelFormat.None;
            scalingDirection = 0;

            var maxSize = new Size3(1 << 15, 1 << 15, 1 << 15);
            var minSize = Size3.One;

            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))

View on GitHub (pinned to 96fad776d2)