{"record":{"id":"8f5a1aebb0b87d2a","repo":"stride3d/stride","slug":"unsupported-format-when-converting-vertex-element-srcdef","errorCode":null,"errorMessage":"Unsupported format when converting vertex element ({srcDef.VertexElement.Format})","messagePattern":"Unsupported format when converting vertex element \\((.+?)\\)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/VertexBufferHelper.cs","lineNumber":142,"sourceCode":"        {\n            if (Binding.Declaration.TryGetElement(destDef.VertexElement.SemanticName, destDef.VertexElement.SemanticIndex, out var srcDef))\n            {\n                var srcOffset = srcDef.Offset;\n                var destOffset = destDef.Offset;\n\n                var srcFormat = srcDef.VertexElement.Format;\n                switch (destDef.VertexElement.Format)\n                {\n                    // The particular semantic used doesn't matter too much here, we're just abusing the relaxed definition to fit any TDest\n                    case PixelFormat.R32G32_Float: SelectSrcType<Relaxed<PositionSemantic>, Vector2>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R32G32B32_Float: SelectSrcType<Relaxed<PositionSemantic>, Vector3>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R32G32B32A32_Float: SelectSrcType<Relaxed<PositionSemantic>, Vector4>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R16G16_Float: SelectSrcType<Relaxed<PositionSemantic>, Half2>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R16G16B16A16_Float: SelectSrcType<Relaxed<PositionSemantic>, Half4>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R16G16B16A16_UInt: SelectSrcType<Relaxed<PositionSemantic>, UShort4>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R8G8B8A8_UInt: SelectSrcType<Relaxed<PositionSemantic>, Byte4>(parameters, srcOffset, destOffset, srcFormat); break;\n                    case PixelFormat.R8G8B8A8_UNorm: SelectSrcType<Relaxed<PositionSemantic>, Color>(parameters, srcOffset, destOffset, srcFormat); break;\n                    default: throw new NotImplementedException($\"Unsupported format when converting vertex element ({srcDef.VertexElement.Format})\");\n                }\n            }\n            else\n            {\n                missing = true;\n            }\n        }\n\n        return missing;\n\n        static void SelectSrcType<TSemantic, TOutput>(InterleavedParameters param, int srcElemOffset, int destElemOffset, PixelFormat format) \n            where TSemantic : \n            IConverter<Vector2, TOutput>,\n            IConverter<Vector3, TOutput>,\n            IConverter<Vector4, TOutput>,\n            IConverter<Half2, TOutput>,\n            IConverter<Half4, TOutput>,\n            IConverter<UShort4, TOutput>,","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexBufferHelper.cs#L124-L160","documentation":"When converting vertex elements by semantic (e.g. POSITION), VertexBufferHelper dispatches on the source PixelFormat to pick a typed copy routine. Only a fixed set of formats (R32G32B32A32_Float, R16G16_Float, R16G16B16A16_Float, R16G16B16A16_UInt, R8G8B8A8_UInt, R8G8B8A8_UNorm) is implemented; anything else hits the default case and throws NotImplementedException. This signals the requested source format conversion is simply not implemented in this helper.","triggerScenarios":"Calling Convert (semantic-based vertex conversion) with an input declaration whose element format is outside the supported list, e.g. R32G32_Float, R10G10B10A2_UNorm, R16G16B16A16_SNorm or any integer/normalized format not in the switch.","commonSituations":"Importing meshes saved with a different vertex compression format than the helper supports; switching platform/exporter settings that change vertex formats; assuming the helper supports arbitrary formats like it might for interop with other engines.","solutions":["Re-export or convert the mesh so its vertex elements use one of the supported formats (R32G32B32A32_Float, R16G16_Float, R16G16B16A16_Float, R16G16B16A16_UInt, R8G8B8A8_UInt, R8G8B8A8_UNorm)","Convert the buffer yourself to a supported format (e.g. expand R32G32_Float to R32G32B32A32_Float) before calling the helper","Extend the switch in VertexBufferHelper with a SelectSrcType call for the missing format if you own the code","Inspect srcDef.VertexElement.Format at runtime and log it to identify the exact unsupported format"],"exampleFix":"// before\nvar decl = VertexElement.Layout<PositionColorVertex>(); // uses R32G32_Float position\nvar helper = new VertexBufferHelper(...); // helper.Convert throws\n// after\nvar decl = new VertexDeclaration(\n    new VertexElement(\"POSITION\", 0, PixelFormat.R32G32B32A32_Float, 0)); // supported format","handlingStrategy":"validation","validationCode":"static readonly PixelFormat[] supported = { PixelFormat.R32G32B32A32_Float, PixelFormat.R16G16_Float, PixelFormat.R16G16B16A16_Float, PixelFormat.R16G16B16A16_UInt, PixelFormat.R8G8B8A8_UInt, PixelFormat.R8G8B8A8_UNorm };\nbool ok = decl.VertexElements.All(e => supported.Contains(e.Format));","typeGuard":null,"tryCatchPattern":"try { helper.Convert(...); }\ncatch (NotImplementedException ex) { logger.Error(ex, \"Vertex format unsupported, re-export mesh with supported formats\"); throw; }","preventionTips":["Restrict mesh exporters to the six supported PixelFormats","Validate vertex declarations at asset-import time","Add unit tests covering every format in your vertex declarations"],"tags":["csharp","graphics","vertex-format","not-implemented"],"backgroundTag":"unsupported-enum-value","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"}