{"record":{"id":"ddb5a4c4be15e1fd","repo":"stride3d/stride","slug":"unsupported-format-when-converting-vertex-element","errorCode":null,"errorMessage":"Unsupported format when converting vertex element ({elementData.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":258,"sourceCode":"        IConverter<Byte4, TDest>,\n        IConverter<Color, TDest>,\n        ISemantic \n        where TDest : unmanaged\n        where TReader : IReader<TDest>, allows ref struct\n    {\n        if (Binding.Declaration.TryGetElement(TSemantic.Name, semanticIndex, out var elementData))\n        {\n            switch (elementData.VertexElement.Format)\n            {\n                case PixelFormat.R32G32_Float: InnerRead<TSemantic, TReader, Vector2, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R32G32B32_Float: InnerRead<TSemantic, TReader, Vector3, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R32G32B32A32_Float: InnerRead<TSemantic, TReader, Vector4, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R16G16_Float: InnerRead<TSemantic, TReader, Half2, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R16G16B16A16_Float: InnerRead<TSemantic, TReader, Half4, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R16G16B16A16_UInt: InnerRead<TSemantic, TReader, UShort4, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R8G8B8A8_UInt: InnerRead<TSemantic, TReader, Byte4, TDest>(destination, reader, elementData); break;\n                case PixelFormat.R8G8B8A8_UNorm: InnerRead<TSemantic, TReader, Color, TDest>(destination, reader, elementData); break;\n                default: throw new NotImplementedException($\"Unsupported format when converting vertex element ({elementData.VertexElement.Format})\");\n            }\n\n            return true;\n        }\n\n        return false;\n    }\n\n    private unsafe void InnerRead<TConverter, TReader, TSource, TDest>(Span<TDest> destination, TReader reader, VertexElementWithOffset element) \n        where TConverter : IConverter<TSource, TDest> \n        where TSource : unmanaged\n        where TReader : IReader<TDest>, allows ref struct\n    {\n        if (sizeof(TSource) != element.Size)\n            throw new ArgumentException($\"{typeof(TSource)} does not match element size ({sizeof(TSource)} != {element.Size})\");\n\n        var stride = Binding.Declaration.VertexStride;\n        var offset = element.Offset;","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexBufferHelper.cs#L240-L276","documentation":"The typed Read path of VertexBufferHelper converts each vertex element by dispatching on its PixelFormat to an InnerRead<...,TSource,...> instantiation. The supported set is R32G32B32A32_Float, R16G16_Float, R16G16B16A16_Float, R16G16B16A16_UInt, R8G8B8A8_UInt, R8G8B8A8_UNorm; any other format throws NotImplementedException. This is a deliberate guard so element reads never misinterpret raw bytes.","triggerScenarios":"Calling Read on a vertex buffer whose element format (elementData.VertexElement.Format) is not among the supported formats, e.g. reading positions stored as R32G32B32_Float or SNorm colors.","commonSituations":"Reading buffers produced by exporters that use compact formats; platform-specific vertex compression; custom vertex declarations using formats the helper never learned to decode.","solutions":["Use one of the supported PixelFormats in the vertex declaration","Decode the unsupported element manually from the raw byte data and feed supported data to the helper","Add a new case to the switch mapping the format to an InnerRead instantiation with the matching unmanaged type","Check the format string in the exception message to identify exactly which element/format to fix"],"exampleFix":"// before\ncolorElement = new VertexElement(\"COLOR\", 0, PixelFormat.R8G8B8A8_SNorm, 0); // throws\n// after\ncolorElement = new VertexElement(\"COLOR\", 0, PixelFormat.R8G8B8A8_UNorm, 0); // supported","handlingStrategy":"validation","validationCode":"if (!supportedFormats.Contains(elementData.VertexElement.Format)) return false; // skip or pre-convert","typeGuard":null,"tryCatchPattern":"try { read = reader.Read<...>(destination); }\ncatch (NotImplementedException ex) { logger.Error(ex, $\"Cannot read element format\"); throw; }","preventionTips":["Pre-convert SNorm/compact formats to supported ones before reading","Check formats before choosing a Read strategy","Pin down exporter settings that control vertex compression"],"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"}