{"record":{"id":"7fe48b9796762b77","repo":"stride3d/stride","slug":"execution-mode-primitive-is-missing-for-first-parameter-of","errorCode":null,"errorMessage":"Execution mode primitive is missing for first parameter of geometry shader","messagePattern":"Execution mode primitive is missing for first parameter of geometry shader","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/Generation/EntryPointWrapperGenerator.cs","lineNumber":354,"sourceCode":"                    buffer.Add(new OpFunctionCall(voidType, context.Bound++, patchConstantEntryPoint.IdRef, new(patchArguments)));\n                    ProcessTessellationArguments(patchConstantEntryPoint, patchArguments);\n\n                    buffer.Add(new OpBranch(mergeLabel));\n\n                    // Merge block\n                    buffer.Add(new OpLabel(mergeLabel));\n                }\n            }\n            else if (executionModel == ExecutionModel.Geometry)\n            {\n                // Change signature of main() to not use the output Stream anymore\n                // TODO: Check it's really the 2nd parameter\n                SpirvBuilder.FunctionRemoveParameter(context, buffer, entryPoint, 1);\n\n                // Extract and remove execution mode (line, point, triangleadj, etc.)\n                var executionMode = entryPointFunctionType.ParameterTypes[0].Modifiers;\n                if (executionMode == ParameterModifiers.None)\n                    throw new InvalidOperationException(\"Execution mode primitive is missing for first parameter of geometry shader\");\n\n                // Extract output topology from the GeometryStreamType parameter before removing it\n                var outputStreamType = ((PointerType)entryPointFunctionType.ParameterTypes[1].Type).BaseType as GeometryStreamType\n                    ?? throw new InvalidOperationException(\"Second parameter of geometry shader must be a GeometryStreamType\");\n\n                entryPointFunctionType.ParameterTypes[0] = entryPointFunctionType.ParameterTypes[0] with { Modifiers = ParameterModifiers.None };\n                entryPointFunctionType.ParameterTypes.RemoveAt(1);\n\n                context.ReplaceType(entryPointFunctionType, entryPointTypeId);\n                context.Add(new OpExecutionMode(entryPoint.IdRef, executionMode switch\n                {\n                    ParameterModifiers.Point => ExecutionMode.InputPoints,\n                    ParameterModifiers.Line => ExecutionMode.InputLines,\n                    ParameterModifiers.LineAdjacency => ExecutionMode.InputLinesAdjacency,\n                    ParameterModifiers.Triangle => ExecutionMode.Triangles,\n                    ParameterModifiers.TriangleAdjacency => ExecutionMode.InputTrianglesAdjacency,\n                    _ => throw new NotSupportedException($\"Unsupported geometry input execution mode: {executionMode}\"),\n                }, []));","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/Generation/EntryPointWrapperGenerator.cs#L336-L372","documentation":"When wrapping a geometry-shader entry point, GenerateWrapper reads the input primitive type from the modifiers of the first parameter (point/line/triangle/adjacency forms) so it can emit the matching SPIR-V OpExecutionMode (InputPoints, InputLines, Triangles, ...). If that parameter has ParameterModifiers.None, there is no primitive topology to encode, and the generator throws this InvalidOperationException. In SDSL/HLSL convention the first GS parameter must carry the input-primitive modifier.","triggerScenarios":"Declaring a geometry shader entry point whose first parameter (the input patch/stream parameter) is written without a primitive modifier (e.g. missing `triangle`, `point`, `lineadj`, etc.) so its ParameterModifiers is None when the wrapper generator runs.","commonSituations":"Hand-porting an HLSL geometry shader where the primitive-type modifier was dropped or renamed; copying a vertex/fragment-style signature into a GS; SDSL parse layers that silently strip unknown modifiers so the generator sees None.","solutions":["Add the input primitive modifier to the first geometry shader parameter: point, line, triangle, lineadj, or triangleadj","Verify the SDSL source actually parses the modifier (check for typos like 'triangles' vs the recognized forms)","Confirm the shader is genuinely a geometry shader — for other stages remove the GS-style parameter so this path is not taken"],"exampleFix":"// before\nvoid GSMain(StreamsInputStream inputs)\n// after\nvoid GSMain(triangle StreamsInputStream inputs)","handlingStrategy":"validation","validationCode":"// Caller-side check before generating the wrapper\nbool hasPrimitiveModifier = entryPointFunctionType.ParameterTypes[0].Modifiers != ParameterModifiers.None;","typeGuard":"static bool HasInputPrimitive(ParameterType p) => p.Modifiers is\n    ParameterModifiers.Point or ParameterModifiers.Line or ParameterModifiers.LineAdjacency\n    or ParameterModifiers.Triangle or ParameterModifiers.TriangleAdjacency;","tryCatchPattern":"try { wrapperGen.GenerateWrapper(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Execution mode primitive is missing\"))\n{\n    // report: GS entry point missing input primitive modifier on first parameter\n}","preventionTips":["Always declare the GS input primitive modifier (point/line/lineadj/triangle/triangleadj) on the first parameter","Copy signatures from working Stride GS examples rather than adapting vertex/fragment signatures","Add a pre-validation pass over entry-point signatures before invoking wrapper generation"],"tags":["shader-compilation","spirv","geometry-shader","missing-modifier"],"backgroundTag":"missing-required-argument","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"}