{"record":{"id":"81a56d3278d90bda","repo":"stride3d/stride","slug":"cannot-specify-the-format-for-more-than-8-render-targets","errorCode":null,"errorMessage":"Cannot specify the format for more than 8 Render Targets.","messagePattern":"Cannot specify the format for more than 8 Render Targets\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/RenderOutputDescription.cs","lineNumber":185,"sourceCode":"        /// </param>\n        /// <param name=\"depthStencilFormat\">\n        ///   The depth format of the Depth-Stencil Buffer.\n        ///   Specify <see cref=\"PixelFormat.None\"/> to disable the Depth-Stencil Buffer.\n        /// </param>\n        /// <param name=\"multisampleCount\">\n        ///   The number of samples to use when multi-sampling.\n        ///   Specify <see cref=\"MultisampleCount.None\"/> to disable multi-sampling.\n        /// </param>\n        /// <exception cref=\"ArgumentOutOfRangeException\">\n        ///   Cannot specify the format for more than 8 Render Targets in <paramref name=\"renderTargetFormats\"/>.\n        /// </exception>\n        public RenderOutputDescription(ReadOnlySpan<PixelFormat> renderTargetFormats,\n                                       PixelFormat depthStencilFormat = PixelFormat.None,\n                                       MultisampleCount multisampleCount = MultisampleCount.None)\n            : this()\n        {\n            if (renderTargetFormats.Length > 8)\n                throw new ArgumentOutOfRangeException(nameof(renderTargetFormats), \"Cannot specify the format for more than 8 Render Targets.\");\n\n            int lastSetRenderTarget = -1;\n            for (int i = 0; i < MaximumRenderTargetCount; i++)\n                if (renderTargetFormats[i] != PixelFormat.None)\n                    lastSetRenderTarget = i;\n\n            RenderTargetCount = lastSetRenderTarget + 1; // +1 so 0 if -1, 1 if 0, etc.\n            renderTargetFormats.CopyTo(RenderTargetFormats);\n            DepthStencilFormat = depthStencilFormat;\n            MultisampleCount = multisampleCount;\n        }\n\n\n        /// <summary>\n        ///   Captures the description of the pipeline render output from a Command List.\n        /// </summary>\n        /// <param name=\"commandList\">The Command List from which to capture the pipeline render output configuration.</param>\n        public unsafe void CaptureState(CommandList commandList)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/RenderOutputDescription.cs#L167-L203","documentation":"RenderOutputDescription's constructor validates that the renderTargetFormats span has at most 8 entries, matching the MaximumRenderTargetCount supported by the underlying GPU API (D3D11/Vulkan simultaneous render target limit). The library throws ArgumentOutOfRangeException immediately if more formats are supplied.","triggerScenarios":"Passing a ReadOnlySpan<PixelFormat> with Length > 8 to the RenderOutputDescription constructor.","commonSituations":"Building a render frame description for a graphics API that supports more render targets than Stride's 8-MRT limit (e.g. Metal allows more), or programmatically generating formats without checking count.","solutions":["Reduce the number of render target formats to 8 or fewer","Split rendering into multiple passes if more than 8 simultaneous targets are needed","Assert/span slice: only take the first 8 formats if the extra entries were accidental"],"exampleFix":"// before\nvar desc = new RenderOutputDescription(formats); // formats.Length == 12\n// after\nvar desc = new RenderOutputDescription(formats.Slice(0, Math.Min(formats.Length, 8)));","handlingStrategy":"validation","validationCode":"if (formats.Length > 8) throw new InvalidOperationException(\"Max 8 render targets supported\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never exceed 8 simultaneous render target formats","Split heavy G-buffer setups into multiple passes"],"tags":["graphics","render-targets","argument-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}