{"record":{"id":"6126aced27e1e584","repo":"stride3d/stride","slug":"expecting-texture-output-on-slot-0","errorCode":null,"errorMessage":"Expecting texture output on slot [{0}]","messagePattern":"Expecting texture output on slot \\[(.+?)\\]","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs","lineNumber":413,"sourceCode":"            {\n                throw new ArgumentOutOfRangeException(\"index\", string.Format(\"Invald texture outputindex [{0}] cannot be negative for effect [{1}]\", index, Name));\n            }\n\n            return outputRenderTargetView ?? (outputRenderTargetViews != null ? outputRenderTargetViews[index] : null);\n        }\n\n        /// <summary>\n        /// Gets an non-null output render target for the specified index.\n        /// </summary>\n        /// <param name=\"index\">The index.</param>\n        /// <returns>RenderTarget.</returns>\n        /// <exception cref=\"System.InvalidOperationException\"></exception>\n        protected Texture GetSafeOutput(int index)\n        {\n            var output = GetOutput(index);\n            if (output == null)\n            {\n                throw new InvalidOperationException(string.Format(\"Expecting texture output on slot [{0}]\", index));\n            }\n\n            return output;\n        }\n\n        /// <summary>\n        /// Gets a render target with the specified description, scoped for the duration of the <see cref=\"RendererBase.DrawCore\"/>.\n        /// </summary>\n        /// <returns>A new instance of texture.</returns>\n        protected Texture NewScopedRenderTarget2D(TextureDescription description)\n        {\n            // TODO: Check if we should introduce an enum for the kind of scope (per DrawCore, per Frame...etc.)\n            CheckIsInDrawCore();\n            return PushScopedResource(Context.Allocator.GetTemporaryTexture2D(description));\n        }\n\n        /// <summary>\n        /// Gets a render target output for the specified description with a single mipmap, scoped for the duration of the <see cref=\"RendererBase.DrawCore\"/>.","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs#L395-L431","documentation":"GetSafeOutput fetches the output render target via GetOutput and throws InvalidOperationException when the result is null, i.e. no output was ever bound (SetOutput never called, or slot beyond bound views). It guarantees a non-null texture for the caller.","triggerScenarios":"Calling effect.GetSafeOutput(index) before any SetOutput/SetOutput(params) call, or with an index exceeding the number of bound outputs (outputRenderTargetViews[i] is null or array access issues).","commonSituations":"Reading an effect's result before Draw ran; a code path skipped SetOutput during render-target resize; mixing single-output (outputRenderTargetView) and multi-output configurations.","solutions":["Call SetOutput with the destination render target before drawing/reading","Ensure the effect's Draw executed before consuming outputs","Verify index is within the number of outputs passed to SetOutput(params ...)"],"exampleFix":"// before\nvar outTex = effect.GetSafeOutput(0); // no output bound\n// after\neffect.SetOutput(myRenderTarget);\n// ... draw ...\nvar outTex = effect.GetSafeOutput(0);","handlingStrategy":"validation","validationCode":"if (!outputBound) throw new InvalidOperationException(\"Call SetOutput before reading effect output\");","typeGuard":"bool HasOutput(ImageEffect e, int i) => i == 0 ? e.GetOutput(0) != null : e.GetOutput(i) != null;","tryCatchPattern":"try { var tex = effect.GetSafeOutput(index); } catch (InvalidOperationException) { /* bind output before draw */ }","preventionTips":["Always call SetOutput before Draw and before reading results","Preserve output binding across render-target resizes","Verify effect execution order in the render pipeline"],"tags":["invalid-state","null-check","rendering"],"backgroundTag":"invalid-state-transition","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"}