stride3d/stride · error · InvalidOperationException

Expecting texture input on slot

Error message

Expecting texture input on slot [{0}]

What it means

GetSafeInput is the non-null variant of GetInput: after fetching the texture at the slot it throws InvalidOperationException when that slot was never assigned a texture. This catches logical errors where a draw pass assumes an input that upstream effects never produced.

Solutions

  1. Call SetInput(index, texture) for every slot consumed before Draw
  2. Reorder effects so producers run before consumers
  3. Use GetInput (nullable) where a missing input is legitimate

Example fix

// before
var src = effect.GetSafeInput(1); // slot 1 never set
// after
effect.SetInput(1, previousEffectOutput);
var src = effect.GetSafeInput(1);
Defensive patterns

Strategy: validation

Validate before calling

if (index >= 0 && index <= effect.MaxInputTextureIndex && effect.GetInput(index) == null) { /* slot missing; run producer or bind */ }

Type guard

bool HasInput(ImageEffect e, int i) => i >= 0 && i <= e.MaxInputTextureIndex && e.GetInput(i) != null;

Try / catch

try { var tex = effect.GetSafeInput(index); } catch (InvalidOperationException) { /* bind input or skip pass */ }

Prevention

When it happens

Trigger: Calling effect.GetSafeInput(index) where the slot is in range but inputTextures[index] is null — e.g. an upstream image effect never ran or never called SetInput for that slot.

Common situations: Forgetting to call SetInput for one slot in a multi-input pipeline; disabling an upstream effect during debugging; order-of-draw mistakes where the source effect runs after the consumer.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs:352

            if (index < 0 || index > maxInputTextureIndex)
            {
                throw new ArgumentOutOfRangeException("index", string.Format("Invald texture input index [{0}]. Max value is [{1}]", index, maxInputTextureIndex));
            }
            return inputTextures[index];
        }

        /// <summary>
        /// Gets a non-null input texture by the specified index.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns>Texture.</returns>
        /// <exception cref="System.InvalidOperationException"></exception>
        protected Texture GetSafeInput(int index)
        {
            var input = GetInput(index);
            if (input == null)
            {
                throw new InvalidOperationException(string.Format("Expecting texture input on slot [{0}]", index));
            }

            return input;
        }

        /// <summary>
        /// Gets the output depth stencil texture.
        /// </summary>
        /// <value>
        /// The depth stencil output.
        /// </value>
        protected Texture DepthStencil => outputDepthStencilView;

        /// <summary>
        /// Gets a value indicating whether this effect has depth stencil output texture binded.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance has depth stencil output; otherwise, <c>false</c>.

View on GitHub (pinned to 96fad776d2)