{"record":{"id":"27f9c5c08fc376c9","repo":"stride3d/stride","slug":"maxtexcoord-must-be-0","errorCode":null,"errorMessage":"maxTexcoord must be >= 0","messagePattern":"maxTexcoord must be >= 0","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/VertexHelper.cs","lineNumber":124,"sourceCode":"        /// <exception cref=\"System.ArgumentOutOfRangeException\">\n        /// vertexCount;vertexCount must be > 0\n        /// or\n        /// vertexStride;vertexStride must be >= 0\n        /// or\n        /// maxTexcoord;maxTexcoord must be >= 0\n        /// </exception>\n        /// <exception cref=\"System.InvalidOperationException\">The vertex buffer must contain at least the TEXCOORD</exception>\n        /// <remarks>\n        /// The original vertex buffer must contain at least a TEXCOORD[0-9] attribute in order for this method to work.\n        /// This method will copy the value of the first existing TEXCOORD found in the vertex buffer to the newly created TEXCOORDS.\n        /// </remarks>\n        public static unsafe VertexTransformResult GenerateMultiTextureCoordinates(VertexDeclaration vertexDeclaration, IntPtr vertexBufferData, int vertexCount, int vertexOffset, int vertexStride, int maxTexcoord = 9)\n        {\n            if (vertexDeclaration == null) throw new ArgumentNullException(\"vertexDeclaration\");\n            if (vertexBufferData == IntPtr.Zero) throw new ArgumentNullException(\"vertexBufferData\");\n            if (vertexCount <= 0) throw new ArgumentOutOfRangeException(\"vertexCount\", \"vertexCount must be > 0\");\n            if (vertexStride < 0) throw new ArgumentOutOfRangeException(\"vertexStride\", \"vertexStride must be >= 0\");\n            if (maxTexcoord < 0) throw new ArgumentOutOfRangeException(\"maxTexcoord\", \"maxTexcoord must be >= 0\");\n\n            // Get the stride from the vertex declaration if necessary\n            if (vertexStride == 0)\n            {\n                vertexStride = vertexDeclaration.VertexStride;\n            }\n\n            // TODO: Usage index in key\n            var offsetMapping = vertexDeclaration\n                .EnumerateWithOffsets()\n                .ToDictionary(x => x.VertexElement.SemanticAsText, x => x.Offset);\n\n            var newVertexElements = new List<VertexElement>();\n\n            int vertexUVOffset = -1;\n\n            // Use R16G16_SNorm as it is supported from HW Level 9.1\n            // See https://msdn.microsoft.com/en-us/library/windows/desktop/ff471324%28v=vs.85%29.aspx","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexHelper.cs#L106-L142","documentation":"The core overload throws ArgumentOutOfRangeException('maxTexcoord', 'maxTexcoord must be >= 0') when the requested maximum texture-coordinate index is negative. maxTexcoord bounds how many TEXCOORD slots get duplicated.","triggerScenarios":"Calling GenerateMultiTextureCoordinates with maxTexcoord < 0 — e.g. a config value that should have defaulted to 9 but was set to -1 to mean 'auto'.","commonSituations":"Using -1 as a sentinel for 'unlimited'; reading maxTexcoord from bad settings/config; passing a wrong variable into the parameter.","solutions":["Pass a positive count (default 9) or omit the parameter to use the default.","Fix the config/sentinel logic so 'auto' maps to a valid value rather than -1.","Validate the value before the call."],"exampleFix":"// before\nvar result = VertexHelper.GenerateMultiTextureCoordinates(decl, ptr, count, 0, stride, maxTexcoord: -1);\n// after\nvar result = VertexHelper.GenerateMultiTextureCoordinates(decl, ptr, count, 0, stride); // default maxTexcoord = 9","handlingStrategy":"validation","validationCode":"if (maxTexcoord < 0) maxTexcoord = 9; // library default","typeGuard":null,"tryCatchPattern":"try { var r = VertexHelper.GenerateMultiTextureCoordinates(decl, ptr, count, offset, stride, maxTexcoord); } catch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"maxTexcoord\") { /* clamp to default 9 */ }","preventionTips":["Use the default parameter instead of sentinel values like -1","Clamp or sanitize config-derived maxTexcoord values before the call"],"tags":["argument-out-of-range","graphics","texture-coordinates"],"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"}