{"record":{"id":"9054bd9ddafce102","repo":"stride3d/stride","slug":"system-value-semantic-not-implemented-semantic2-for-stage","errorCode":null,"errorMessage":"System-value Semantic not implemented: {semantic2} for stage {executionModel} as {type}","messagePattern":"System-value Semantic not implemented: (.+?) for stage (.+?) as (.+?)","errorType":"validation","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/Generation/BuiltinProcessor.cs","lineNumber":138,"sourceCode":"            (ExecutionModel.Vertex, StreamVariableType.Input, \"SV_INSTANCEID\") => AddBuiltin(context, variable, BuiltIn.InstanceIndex),\n            (ExecutionModel.Vertex, StreamVariableType.Input, \"SV_VERTEXID\") => AddBuiltin(context, variable, BuiltIn.VertexIndex),\n            ( >= ExecutionModel.Vertex, _, \"SV_INSTANCEID\" or \"SV_VERTEXID\") => false, // forward from VS to the next stages\n            // Pixel shader inputs (SV_IsFrontFace)\n            (ExecutionModel.Fragment, StreamVariableType.Input, \"SV_ISFRONTFACE\") => AddBuiltin(context, variable, BuiltIn.FrontFacing),\n            // SV_PrimitiveID\n            (ExecutionModel.Geometry, StreamVariableType.Output, \"SV_PRIMITIVEID\") => AddBuiltin(context, variable, BuiltIn.PrimitiveId),\n            (not ExecutionModel.Vertex, StreamVariableType.Input, \"SV_PRIMITIVEID\") => AddBuiltin(context, variable, BuiltIn.PrimitiveId),\n            // Tessellation\n            (ExecutionModel.TessellationControl or ExecutionModel.TessellationEvaluation, _, \"SV_TESSFACTOR\") => AddBuiltin(context, variable, BuiltIn.TessLevelOuter),\n            (ExecutionModel.TessellationControl or ExecutionModel.TessellationEvaluation, _, \"SV_INSIDETESSFACTOR\") => AddBuiltin(context, variable, BuiltIn.TessLevelInner),\n            (ExecutionModel.TessellationEvaluation, StreamVariableType.Input, \"SV_DOMAINLOCATION\") => AddBuiltin(context, variable, BuiltIn.TessCoord),\n            (ExecutionModel.TessellationControl, StreamVariableType.Input, \"SV_OUTPUTCONTROLPOINTID\") => AddBuiltin(context, variable, BuiltIn.InvocationId),\n            // Compute shaders\n            (ExecutionModel.GLCompute, StreamVariableType.Input, \"SV_GROUPID\") => AddBuiltin(context, variable, BuiltIn.WorkgroupId),\n            (ExecutionModel.GLCompute, StreamVariableType.Input, \"SV_GROUPINDEX\") => AddBuiltin(context, variable, BuiltIn.LocalInvocationIndex),\n            (ExecutionModel.GLCompute, StreamVariableType.Input, \"SV_GROUPTHREADID\") => AddBuiltin(context, variable, BuiltIn.LocalInvocationId),\n            (ExecutionModel.GLCompute, StreamVariableType.Input, \"SV_DISPATCHTHREADID\") => AddBuiltin(context, variable, BuiltIn.GlobalInvocationId),\n            (_, _, { } semantic2) when semantic2.StartsWith(\"SV_\") => throw new NotImplementedException($\"System-value Semantic not implemented: {semantic2} for stage {executionModel} as {type}\"),\n            _ => false,\n        };\n    }\n}\n","sourceCodeStart":120,"sourceCodeEnd":143,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/Generation/BuiltinProcessor.cs#L120-L143","documentation":"BuiltinProcessor.ProcessBuiltinsDecoration maps D3D-style SV_ system-value semantics (e.g. SV_GroupID, SV_Position) to SPIR-V BuiltIn decorations for each shader stage. When an SV_ semantic is encountered for a stage/usage combination that has no mapping in the switch expression, it throws NotImplementedException because the generator cannot emit a correct SPIR-V builtin. This is an intentional 'unsupported feature' guard, not a user-data validation error.","triggerScenarios":"Calling ProcessBuiltinsDecoration (directly or via EntryPointWrapperGenerator.GenerateWrapper) with a StreamVariableType.Input semantic starting with \"SV_\" whose (ExecutionModel, StreamVariableType, semantic) tuple is not one of the explicitly mapped cases (e.g. SV_Position in a GLCompute stage, SV_TessFactor, SV_InsideTessFactor, SV_DomainLocation, or any unmapped SV_ name), or any SV_ semantic used as an Output stream.","commonSituations":"Porting HLSL shaders using system-value semantics Stride's SPIR-V frontend does not yet translate for the target stage; using an SV_ semantic in a stage where HLSL exposes it but the processor lacks a mapping; custom SDSL streams referencing newer or exotic system values; semantic typos like SV_POSITON that miss the exact mapped names.","solutions":["Check the mapped cases in BuiltinProcessor.cs and change the semantic to one supported for your ExecutionModel (e.g. use SV_GROUPID only in a GLCompute entry point).","Fix typos in the semantic name so it matches an exact mapped entry (case-insensitive SV_GROUPID, SV_GROUPTHREADID, etc.).","If the semantic is genuinely needed, add a mapping arm to the switch in BuiltinProcessor mapping it to the appropriate Spv.Specification BuiltIn value.","For unsupported system values, pass the data in via a regular input/binding (e.g. a push constant or SSBO populated by the engine) instead of an SV_ semantic.","Vote for / implement the missing stage support (e.g. tessellation domain semantics) upstream in Stride's shader processor."],"exampleFix":"// before (in a GLCompute stage)\nfloat2 SV_Position : SV_Position; // SV_Position unmapped for GLCompute input -> NotImplementedException\n\n// after\nuint3 SV_DispatchThreadID : SV_DISPATCHTHREADID; // explicitly mapped for GLCompute -> BuiltIn.GlobalInvocationId","handlingStrategy":"try-catch","validationCode":"// Pre-check semantics against known mappings before invoking the processor\nstatic readonly HashSet<string> KnownSv = new(StringComparer.OrdinalIgnoreCase)\n    { \"SV_OUTPUTCONTROLPOINTID\", \"SV_GROUPID\", \"SV_GROUPINDEX\", \"SV_GROUPTHREADID\", \"SV_DISPATCHTHREADID\" };\nbool IsSupported(string semantic) => !semantic.StartsWith(\"SV_\", StringComparison.OrdinalIgnoreCase) || KnownSv.Contains(semantic);","typeGuard":"static bool IsMappedSystemValue(string semantic, ExecutionModel model) =>\n    !semantic.StartsWith(\"SV_\", StringComparison.OrdinalIgnoreCase) ||\n    (model == ExecutionModel.GLCompute && new[]{\"SV_GROUPID\",\"SV_GROUPINDEX\",\"SV_GROUPTHREADID\",\"SV_DISPATCHTHREADID\"}.Any(s => s.Equals(semantic, StringComparison.OrdinalIgnoreCase)) ||\n     model == ExecutionModel.TessellationControl && semantic.Equals(\"SV_OUTPUTCONTROLPOINTID\", StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try\n{\n    BuiltinProcessor.ProcessBuiltinsDecoration(context, executionModel, variableId, StreamVariableType.Input, semantic, ref type);\n}\ncatch (NotImplementedException ex)\n{\n    log.Error($\"System value '{semantic}' unsupported for stage {executionModel}: {ex.Message}\");\n    throw new ShaderCompilationException($\"Unsupported system value {semantic} for stage {executionModel}\", ex);\n}","preventionTips":["Restrict SV_ semantics to the stages BuiltinProcessor maps them for (compute: SV_GROUPID/GROUPINDEX/GROUPTHREADID/DISPATCHTHREADID; tessellation control: SV_OUTPUTCONTROLPOINTID).","Lint shaders for SV_ semantics outside the supported list before compilation.","Keep a central enum/table of supported system values instead of free-form strings in SDSL.","Write a unit test per (stage, semantic) pair you rely on to catch missing mappings early."],"tags":["spirv","shader-compilation","not-implemented","system-value"],"backgroundTag":"unsupported-operation","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"}