stride3d/stride · error · ArgumentException
Can not use more than
Error message
Can not use more than {CommandList.MaxViewportAndScissorRectangleCount} scissors simultaneously What it means
SetScissorRectangles rejects any scissor rectangle array longer than CommandList.MaxViewportAndScissorRectangleCount. This mirrors the viewport limit and protects against exceeding hardware scissor counts. The message interpolates the constant at runtime.
Solutions
- Slice or truncate the rectangle span to CommandList.MaxViewportAndScissorRectangleCount
- Deduplicate/coalesce scissor rectangles before binding
- Check the span length before calling and split into batches
Example fix
// before
effect.SetScissorRectangles(allTiles);
// after
var rects = allTiles;
if (rects.Length > CommandList.MaxViewportAndScissorRectangleCount)
rects = rects.Slice(0, CommandList.MaxViewportAndScissorRectangleCount);
effect.SetScissorRectangles(rects); Defensive patterns
Strategy: validation
Validate before calling
if (values.Length > CommandList.MaxViewportAndScissorRectangleCount) throw new ArgumentException("too many scissor rects"); Try / catch
try { effect.SetScissorRectangles(span); } catch (ArgumentException) { /* truncate/batch and retry */ } Prevention
- Coalesce/deduplicate scissor rectangles before binding
- Bind the hardware limit once and reference the constant
- Split tiling passes into multiple draw groups
When it happens
Trigger: Calling effect.SetScissorRectangles(ReadOnlySpan<Rectangle>) with a span whose length exceeds MaxViewportAndScissorRectangleCount; called indirectly by SetScissorRectangle overloads.
Common situations: Tiled/region rendering generating many scissor rects per pass; reusing a shared rectangle list sized for a different device; concatenating per-tile rectangles without deduplication.
Related errors
- Can not use more than
- Asked for " + i + " but no more than 10 default textures…
- BoundingVolumeBufferDownsampleLevel
- Destination texture is a MSAA texture.
- index
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/1b8a7706bf488f27.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs:210
var scissor = value.Value;
SetScissorRectangles(MemoryMarshal.CreateReadOnlySpan(ref scissor, 1));
}
else
{
SetScissorRectangles(ReadOnlySpan<Rectangle>.Empty);
}
}
/// <summary>
/// Binds a set of scissor rectangles to the rasterizer stage.
/// </summary>
/// <param name="values">The set of scissor rectangles to bind.</param>
/// <remarks>Only <see cref="CommandList"/>'s `MaxViewportAndScissorRectangleCount` viewports can be used simultaneously</remarks>
public void SetScissorRectangles(ReadOnlySpan<Rectangle> values)
{
if (values.Length > CommandList.MaxViewportAndScissorRectangleCount)
{
throw new ArgumentException($"Can not use more than {CommandList.MaxViewportAndScissorRectangleCount} scissors simultaneously");
}
boundScissorCount = values.Length;
values.CopyTo(scissors);
}
protected override void PreDrawCore(RenderDrawContext context)
{
base.PreDrawCore(context);
if (EnableSetRenderTargets)
{
SetRenderTargets(context);
}
}
/// <summary>
/// Set the render targets for the image effect.View on GitHub (pinned to 96fad776d2)