{"record":{"id":"55dec126dd6e9ef1","repo":"stride3d/stride","slug":"hull-shader-patch-constant-function-patchconstantfuncname","errorCode":null,"errorMessage":"Hull shader patch constant function {patchConstantFuncName} was not found","messagePattern":"Hull shader patch constant function (.+?) was not found","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/InterfaceProcessor.cs","lineNumber":745,"sourceCode":"                        {\n                            Target: int target,\n                            Decoration: Decoration.PatchConstantFuncSDSL,\n                            Value: string funcName\n                        } && target == overrideChain[index])\n                    {\n                        patchConstantFuncName = funcName;\n                        break;\n                    }\n                }\n            }\n\n            Symbol? patchConstantEntryPoint = null;\n            if (patchConstantFuncName != null)\n            {\n                // Resolve the patch constant function\n                patchConstantEntryPoint = ResolveEntryPoint(table, patchConstantFuncName);\n                if (patchConstantEntryPoint == null)\n                    throw new InvalidOperationException($\"Hull shader patch constant function {patchConstantFuncName} was not found\");\n            }\n\n            return patchConstantEntryPoint;\n        }\n    }\n}\n","sourceCodeStart":727,"sourceCodeEnd":752,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Processing/Interfaces/InterfaceProcessor.cs#L727-L752","documentation":"For a hull shader, InterfaceProcessor.ResolveHullPatchConstantEntryPoint resolves the patch constant function named by the patchconstantfunc attribute in the symbol table. If the named function does not exist as an entry point, it throws because hull stage processing needs the patch constant stage to evaluate per-patch constants.","triggerScenarios":"MergeSDSL with a hull shader whose patchconstantfunc attribute names a function (e.g. 'HSPatchConstant') that is not present as an entry point in the merged SPIR-V symbol table — ResolveEntryPoint returns null.","commonSituations":"Typo in the patchconstantfunc attribute value; renaming/refactoring the patch constant function without updating the attribute; the patch constant function lives in a mixin not included in the composition; porting HLSL where the function name casing differs.","solutions":["Make the patchconstantfunc name match the actual function in the shader (fix spelling/casing)","Include the mixin/class containing the patch constant function in the shader composition","Ensure the patch constant function is declared as an entry-point-eligible method so it lands in the symbol table"],"exampleFix":"// before\n[patchconstantfunc(\"PatchConstantFunc\")] // function is actually named HSConstants\n// after\n[patchconstantfunc(\"HSConstants\")]","handlingStrategy":"validation","validationCode":"var hs = composition.Classes.SelectMany(c => c.GetMethods()).First(m => m.Name == \"HSMain\");\nvar patchFuncName = (string?)hs.GetCustomAttributes()\n    .FirstOrDefault(a => a.Type.Name.Contains(\"patchconstantfunc\"))?.ConstructorArguments.FirstOrDefault().Value;\nif (patchFuncName != null &&\n    !composition.Classes.SelectMany(c => c.GetMethods()).Any(m => m.Name == patchFuncName))\n    throw new InvalidOperationException($\"Patch constant function '{patchFuncName}' not found in composition.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    mixer.MergeSDSL(shaderSource, options, log, out var bytecode, out _, out _, out _);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"patch constant function\"))\n{\n    log.Error(\"Hull patch constant function missing: \" + ex.Message);\n}","preventionTips":["Keep patchconstantfunc name and the function declaration in the same class/file so renames stay in sync","Use nameof-style constants rather than string literals for the function name where possible","Include the mixin defining the patch constant function in every composition that uses the hull shader"],"tags":["spirv","shader-compilation","hull-shader","missing-function"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}