stride3d/stride · error · ArgumentOutOfRangeException
index
Error message
index
What it means
GetInput retrieves an input texture by slot index and throws ArgumentOutOfRangeException("index") when the index is negative or greater than maxInputTextureIndex (size of the input texture array minus 1, based on TexturingKeys.DefaultTextures.Count). The message reports both the invalid index and the maximum allowed value.
Solutions
- Clamp/validate the index against maxInputTextureIndex before calling
- Derive slot indices from TexturingKeys.DefaultTextures.Count rather than hard-coding
- Use foreach/for bounded by the effect's input count
Example fix
// before
var tex = effect.GetInput(8);
// after
if (index >= 0 && index <= effect.MaxInputTextureIndex)
var tex = effect.GetInput(index); Defensive patterns
Strategy: validation
Validate before calling
if (index < 0 || index > effect.MaxInputTextureIndex) return null;
Try / catch
try { var tex = effect.GetInput(index); } catch (ArgumentOutOfRangeException) { /* log invalid slot */ } Prevention
- Bound loops by the effect's declared input count
- Avoid hard-coded slot numbers; use named constants matching shader inputs
- Prefer GetSafeInput only when the slot is known to be configured
When it happens
Trigger: Calling effect.GetInput(i) with i < 0, or with i >= maxInputTextureIndex (e.g. GetInput(8) when the effect supports only 4 inputs); also triggered inside GetSafeInput when given an out-of-range slot.
Common situations: Hard-coding slot indices that don't match the shader's declared input count; iterating with a wrong loop bound; using indices from another effect with a different input count.
Related errors
- Asked for " + i + " but no more than 10 default textures…
- BoundingVolumeBufferDownsampleLevel
- Can not use more than
- Can not use more than
- Destination texture is a MSAA texture.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e0f0789761cb6d85.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs:336
public int InputCount
{
get
{
return maxInputTextureIndex + 1;
}
}
/// <summary>
/// Gets an input texture by the specified index.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>Texture.</returns>
/// <exception cref="System.ArgumentOutOfRangeException">index</exception>
public Texture GetInput(int index)
{
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));
}
View on GitHub (pinned to 96fad776d2)