{"record":{"id":"1b8a7706bf488f27","repo":"stride3d/stride","slug":"can-not-use-more-than-commandlist-imageeffect","errorCode":null,"errorMessage":"Can not use more than {CommandList.MaxViewportAndScissorRectangleCount} scissors simultaneously","messagePattern":"Can not use more than (.+?) scissors simultaneously","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs","lineNumber":210,"sourceCode":"                var scissor = value.Value;\n                SetScissorRectangles(MemoryMarshal.CreateReadOnlySpan(ref scissor, 1));\n            }\n            else\n            {\n                SetScissorRectangles(ReadOnlySpan<Rectangle>.Empty);\n            }\n        }\n\n        /// <summary>\n        /// Binds a set of scissor rectangles to the rasterizer stage.\n        /// </summary>\n        /// <param name=\"values\">The set of scissor rectangles to bind.</param>\n        /// <remarks>Only <see cref=\"CommandList\"/>'s `MaxViewportAndScissorRectangleCount` viewports can be used simultaneously</remarks>\n        public void SetScissorRectangles(ReadOnlySpan<Rectangle> values)\n        {\n            if (values.Length > CommandList.MaxViewportAndScissorRectangleCount)\n            {\n                throw new ArgumentException($\"Can not use more than {CommandList.MaxViewportAndScissorRectangleCount} scissors simultaneously\");\n            }\n\n            boundScissorCount = values.Length;\n            values.CopyTo(scissors);\n        }\n\n        protected override void PreDrawCore(RenderDrawContext context)\n        {\n            base.PreDrawCore(context);\n\n            if (EnableSetRenderTargets)\n            {\n                SetRenderTargets(context);\n            }\n        }\n\n        /// <summary>\n        /// Set the render targets for the image effect.","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs#L192-L228","documentation":"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.","triggerScenarios":"Calling effect.SetScissorRectangles(ReadOnlySpan<Rectangle>) with a span whose length exceeds MaxViewportAndScissorRectangleCount; called indirectly by SetScissorRectangle overloads.","commonSituations":"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.","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"],"exampleFix":"// before\neffect.SetScissorRectangles(allTiles);\n// after\nvar rects = allTiles;\nif (rects.Length > CommandList.MaxViewportAndScissorRectangleCount)\n    rects = rects.Slice(0, CommandList.MaxViewportAndScissorRectangleCount);\neffect.SetScissorRectangles(rects);","handlingStrategy":"validation","validationCode":"if (values.Length > CommandList.MaxViewportAndScissorRectangleCount) throw new ArgumentException(\"too many scissor rects\");","typeGuard":null,"tryCatchPattern":"try { effect.SetScissorRectangles(span); } catch (ArgumentException) { /* truncate/batch and retry */ }","preventionTips":["Coalesce/deduplicate scissor rectangles before binding","Bind the hardware limit once and reference the constant","Split tiling passes into multiple draw groups"],"tags":["argument-out-of-range","rendering","gpu-limits"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}