{"record":{"id":"053cd428f90c6f30","repo":"stride3d/stride","slug":"a-texture-with-size-0-already-exist-with-the-same-output","errorCode":null,"errorMessage":"A texture with size [{0}] already exist with the same output size","messagePattern":"A texture with size \\[(.+?)\\] already exist with the same output size","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/ImageScaler/ImageMultiScaler.cs","lineNumber":154,"sourceCode":"\n                    if (inputSize == outputSize)\n                    {\n                        throw new InvalidOperationException(\"Input and output texture cannot have same size [{0}]\".ToFormat(inputSize));\n                    }\n\n                    int newScalingDirection = outputSize.CompareTo(inputSize);\n                    if (scalingDirection != 0 && Math.Sign(scalingDirection) != Math.Sign(newScalingDirection))\n                    {\n                        throw new InvalidOperationException(\"Support only output scaling to the same direction\");\n                    }\n                    scalingDirection = newScalingDirection;\n\n                    // Check that we are scaling to different texture sizes\n                    foreach (var existingOutput in outputTextures)\n                    {\n                        if (existingOutput.Size == outputTexture.Size)\n                        {\n                            throw new InvalidOperationException(\"A texture with size [{0}] already exist with the same output size\".ToFormat(existingOutput.Size));\n                        }\n                    }\n\n                    // If the textrue is valid use it\n                    outputTextures.Add(outputTexture);\n                }\n            }\n\n            return outputTextures.Count > 0;\n        }\n\n        private Texture FindOutputMatchingSize(Size3 targetSize, int scalingDirection)\n        {\n            for (int i = 0; i < outputTextures.Count; i++)\n            {\n                var outputTexture = outputTextures[i];\n                if (outputTexture == null)\n                {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/ImageScaler/ImageMultiScaler.cs#L136-L172","documentation":"Each output of an ImageMultiScaler must have a unique size, because the scaler keeps one output per size step. PrepareScaling throws InvalidOperationException when a newly added output texture has the same Size as one already registered in outputTextures.","triggerScenarios":"Adding two output textures with identical dimensions to the same ImageMultiScaler (e.g. two mip-like outputs both at half input resolution) and rendering.","commonSituations":"Loop-generated outputs with a rounding bug making two sizes collide (integer division); copy-pasted SetOutput calls using the same size texture; UI code that binds the same render target twice.","solutions":["Give every output texture a distinct Size before adding it to the scaler.","Fix size-computation loops so consecutive outputs differ (check integer rounding: Math.Max(1, size >> level) collisions).","Check the message's size value and find the duplicate SetOutput call producing that dimension."],"exampleFix":"// before\nfor (int i = 0; i < levels; i++) scaler.SetOutput(i, RenderTexture(w >> i, h >> i)); // level rounding may duplicate\n// after\nvar used = new HashSet<Size3>();\nforeach (var size in ComputeDistinctSizes()) if (used.Add(size)) scaler.SetOutput(...);","handlingStrategy":"validation","validationCode":"var seen = new HashSet<Size3>();\nforeach (var o in outputs)\n    if (!seen.Add(o.Size)) throw new InvalidOperationException($\"Duplicate output size {o.Size}\");","typeGuard":null,"tryCatchPattern":"try { scaler.Draw(context); }\ncatch (InvalidOperationException) { Log.Warning(\"Duplicate multi-scaler output size; removing duplicate\"); }","preventionTips":["Deduplicate generated mip-level sizes (watch integer rounding collisions like w>>i == w>>(i+1) near 1).","Use a HashSet of sizes when programmatically adding outputs.","Verify each SetOutput call uses a distinct texture size."],"tags":["duplicate-output","texture-size","rendering","stride"],"backgroundTag":"conflicting-config-options","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}