{"record":{"id":"7d8e722d0bf1ba5d","repo":"stride3d/stride","slug":"unsupported-uint-vector-size-v-length","errorCode":null,"errorMessage":"Unsupported uint vector size: {v.Length}","messagePattern":"Unsupported uint vector size: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/SDSL/ShaderMixer.CBuffers.cs","lineNumber":653,"sourceCode":"            {\n                float => v.Length switch\n                {\n                    2 => new Vector2((float)v[0], (float)v[1]),\n                    3 => new Vector3((float)v[0], (float)v[1], (float)v[2]),\n                    4 => (object)new Vector4((float)v[0], (float)v[1], (float)v[2], (float)v[3]),\n                    _ => throw new NotSupportedException($\"Unsupported float vector size: {v.Length}\"),\n                },\n                int => v.Length switch\n                {\n                    2 => new Int2((int)v[0], (int)v[1]),\n                    3 => new Int3((int)v[0], (int)v[1], (int)v[2]),\n                    4 => (object)new Int4((int)v[0], (int)v[1], (int)v[2], (int)v[3]),\n                    _ => throw new NotSupportedException($\"Unsupported int vector size: {v.Length}\"),\n                },\n                uint => v.Length switch\n                {\n                    4 => (object)new UInt4((uint)v[0], (uint)v[1], (uint)v[2], (uint)v[3]),\n                    _ => throw new NotSupportedException($\"Unsupported uint vector size: {v.Length}\"),\n                },\n                _ => throw new NotSupportedException($\"Unsupported constant composite element type: {v[0]?.GetType()}\"),\n            };\n        }\n    }\n}\n","sourceCodeStart":635,"sourceCodeEnd":660,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/SDSL/ShaderMixer.CBuffers.cs#L635-L660","documentation":"For uint constant composites, ConvertDefaultValue only maps length-4 vectors to UInt4. Any other length (1, 2, 3, 5, ...) hits the switch default and throws NotSupportedException, since no UInt1/UInt2/UInt3 mapping exists in this path.","triggerScenarios":"A uint cbuffer member default declared with 2 or 3 components (e.g. uint2(1,2)) reaching ConvertDefaultValue during ComputeCBufferReflection.","commonSituations":"uvec2/uvec3 defaults ported from GLSL; bitflag packs written as uint2/uint3; codegen emitting shortened uint composites.","solutions":["Pad the default to uint4 (e.g. uint4(v, 0))","Change the member to int2/int3 so the int branch handles it","Use a plain uint scalar for 1-component values"],"exampleFix":"// before\nuint2 TileOffset = uint2(4, 8);\n// after\nuint4 TileOffset = uint4(4, 8, 0, 0);","handlingStrategy":"validation","validationCode":"if (elemType == \"uint\" && composite.Length != 4)\n    throw new ArgumentException(\"uint default composites must have exactly 4 components\");","typeGuard":null,"tryCatchPattern":"try { result = mixer.MergeSDSL(tree); }\ncatch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported uint vector size\")) {\n    padToUInt4(memberName);\n}","preventionTips":["Prefer int2/int3 over uint2/uint3 for small default vectors","Pad uint defaults to uint4","Avoid uint composites in ported GLSL code without review"],"tags":["shaders","sdsl","default-values","uint"],"backgroundTag":"unsupported-dtype","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"}