{"record":{"id":"53d7ee158502dc88","repo":"stride3d/stride","slug":"assign-back-to-matrix-swizzle-is-not-implemented-yet","errorCode":null,"errorMessage":"Assign back to matrix swizzle is not implemented yet","messagePattern":"Assign back to matrix swizzle is not implemented yet","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs","lineNumber":792,"sourceCode":"                        var bufferValue = builder.Convert(context, rvalue, resultType);\n                        builder.Insert(new OpImageWrite(buffer.Id, location.Id, bufferValue.Id, null, []));\n                        // We stop there\n                        return;\n                    }\n                // ImageWrite\n                case (PointerType { BaseType: TextureType textureType }, IndexerExpression indexer):\n                    {\n                        var resultType = textureType.ReturnType;\n                        var image = builder.AsValue(context, lvalueBase);\n\n                        var imageCoordValue = ConvertTexCoord(context, builder, textureType, indexer.Index.CompileAsValue(table, compiler), ScalarType.Int);\n                        var texelValue = builder.Convert(context, rvalue, resultType);\n                        builder.Insert(new OpImageWrite(image.Id, imageCoordValue.Id, texelValue.Id, null, []));\n                        // We stop there\n                        return;\n                    }\n                case (PointerType { BaseType: MatrixType } or MatrixType, Identifier { Name: var swizzle } id) when id.IsMatrixSwizzle((MatrixType)currentValueType.GetValueType(), out var swizzles):\n                    throw new NotImplementedException(\"Assign back to matrix swizzle is not implemented yet\");\n                case (PointerType { BaseType: VectorType or ScalarType } or VectorType or ScalarType, Identifier { Name: var swizzle } id) when id.IsVectorSwizzle():\n                    // Swizzle: we transform the value to assign accordingly\n\n                    // We load the original value (if pointer)\n                    var lvalueType = currentValueType;\n                    if (lvalueType is PointerType p)\n                    {\n                        lvalueBase = new(builder.InsertData(new OpLoad(context.GetOrRegister(p.BaseType), context.Bound++, lvalueBase.Id, null, [])));\n                        lvalueType = p.BaseType;\n                    }\n\n                    // Shuffle with new data\n                    switch (lvalueType)\n                    {\n                        case VectorType v:\n                            var shuffleIndices = shuffleBuffer[..v.Size];\n                            // Default: lvalue\n                            for (int j = 0; j < v.Size; ++j)","sourceCodeStart":774,"sourceCodeEnd":810,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs#L774-L810","documentation":"During SPIR-V codegen of an assignment, the compiler pattern-matches the assignment target. When the target is a matrix swizzle (e.g. m._m00_m11 = v) it has no implementation, so it throws NotImplementedException — matrix swizzle write-back is simply not yet supported by this SDSL compiler stage.","triggerScenarios":"Assigning to a matrix swizzle lvalue (pattern: target is MatrixType or pointer-to-matrix with an identifier that IsMatrixSwizzle) inside an SDSL shader being translated to SPIR-V.","commonSituations":"Writing GLSL-style code like mat._11_22 = ... ported from other shading languages; auto-translated shaders that assume swizzle assignment works for matrices.","solutions":["Rewrite the shader to assign matrix rows/elements individually instead of via swizzle","Use a temporary: compute the swizzled result into locals, then assign each element","Express the operation with matrix constructors or index assignment","Implement the missing codegen case in Expression.cs if you control the compiler"],"exampleFix":"// before\nm._m00_m11 = vec2(a, b);\n// after\nm[0][0] = a;\nm[1][1] = b;","handlingStrategy":"fallback","validationCode":"static bool AssignableViaSwizzle(object target) => target is VectorType or ScalarType or PointerType;","typeGuard":"bool IsMatrixSwizzleTarget(Identifier id, MatrixType t) => id.IsMatrixSwizzle(t, out _);","tryCatchPattern":"try { EmitAssignment(target, value); } catch (NotImplementedException e) when (e.Message.Contains(\"matrix swizzle\")) { EmitElementWiseAssignment(target, value); }","preventionTips":["Avoid assigning through matrix swizzles in SDSL shaders","Assign matrix elements individually or via row/column constructors","Track Stride releases for matrix-swizzle write-back support"],"tags":["sdsl","shader","codegen","not-implemented"],"backgroundTag":"method-not-implemented","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"}