{"record":{"id":"81aa6a7242e78d4b","repo":"stride3d/stride","slug":"cross-compilersetentrypoint-compiler-entrypoint-value","errorCode":null,"errorMessage":"{cross.CompilerSetEntryPoint(compiler, entryPoint.Value.RealName, entryPoint.Value.ExecutionModel)} : could not set entry point","messagePattern":"(.+?) : could not set entry point","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/SpirvTranslator.cs","lineNumber":110,"sourceCode":"            // RenderDoc's shader viewer when displaying the cross-compiled HLSL/GLSL.\n            // OpLine in the SPIR-V is preserved for Vulkan/RenderDoc callstacks.\n            cross.CompilerOptionsSetBool(compilerOptions, CompilerOption.EmitLineDirectives, 0);\n            if (backend == Backend.Hlsl)\n            {\n                cross.CompilerOptionsSetUint(compilerOptions, CompilerOption.HlslShaderModel, 50);\n                cross.CompilerOptionsSetBool(compilerOptions, CompilerOption.HlslPreserveStructuredBuffers, 1);\n                // FXC rejects uninitialized loop-carried variables (from OpUndef phi inputs) with a\n                // bogus \"error X4555: cannot use casts on l-values\" when they end up assigned in a\n                // for-loop continue expression.\n                cross.CompilerOptionsSetBool(compilerOptions, CompilerOption.ForceZeroInitializedVariables, 1);\n            }\n            cross.CompilerInstallCompilerOptions(compiler, compilerOptions);\n        }\n\n        if (entryPoint != null)\n        {\n            if (cross.CompilerSetEntryPoint(compiler, entryPoint.Value.RealName, entryPoint.Value.ExecutionModel) != Result.Success)\n                throw new Exception($\"{cross.CompilerSetEntryPoint(compiler, entryPoint.Value.RealName, entryPoint.Value.ExecutionModel)} : could not set entry point\");\n        }\n\n        if (cross.CompilerCreateShaderResources(compiler, &resources) != Result.Success)\n            throw new Exception($\"{cross.CompilerCreateShaderResources(compiler, &resources)} : could not create shader resources\");\n\n        // HLSL: remove type_ prefix from cbuffer (they get names from struct instead of cbuffer variable itself)\n        if (backend == Backend.Hlsl)\n        {\n\n            ReflectedResource* resourcesList;\n            nuint resourcesCount;\n            cross.ResourcesGetResourceListForType(resources, ResourceType.UniformBuffer, &resourcesList, &resourcesCount);\n            for (uint i = 0; i < resourcesCount; ++i)\n            {\n                var resource = resourcesList[i];\n                var cbufferName = Marshal.PtrToStringAnsi((IntPtr)resource.Name)!;\n                if (cbufferName.StartsWith(\"type.\"))\n                {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/SpirvTranslator.cs#L92-L128","documentation":"Translate throws this when CompilerSetEntryPoint fails to select the requested entry point on the compiler. spirv-cross returns failure when the named entry point does not exist in the module or the ExecutionModel does not match the module's declared model for that name.","triggerScenarios":"Calling Translate(backend, entryPoint) with a RealName that is not an entry point in the SPIR-V (e.g. stale name after shader recompilation/renaming), or an ExecutionModel that disagrees with the module (e.g. passing Vertex for a fragment shader).","commonSituations":"Caching entry-point names from a previous shader version and reusing them after the effect was recompiled; mixing entry points across shader stages; case-sensitivity mistakes in the entry point name; getting names from a different SPIR-V module than the one being translated.","solutions":["Call GetEntryPoints first and verify the desired RealName/ExecutionModel pair exists before passing it to Translate","Re-fetch entry points whenever the shader module is recompiled instead of caching names","Check name spelling/case exactly matches the SPIR-V OpEntryPoint name","Confirm the ExecutionModel comes from the same module's entry-point list","Pass null entryPoint to translate the default entry point and compare results"],"exampleFix":"// before\nvar hlsl = translator.Translate(Backend.Hlsl, (\"mainPS\", \"main\", ExecutionModel.Fragment));\n// after\nvar eps = translator.GetEntryPoints(Backend.Hlsl);\nvar ep = eps.FirstOrDefault(e => e.RealName == \"mainPS\")\n         ?? throw new InvalidOperationException($\"Entry point 'mainPS' not found. Available: {string.Join(\", \", eps.Select(e => e.RealName))}\");\nvar hlsl = translator.Translate(Backend.Hlsl, (ep.RealName, \"main\", ep.ExecutionModel));","handlingStrategy":"validation","validationCode":"var available = translator.GetEntryPoints(backend);\nif (entryPoint != null && !available.Any(e => e.RealName == entryPoint.Value.RealName && e.ExecutionModel == entryPoint.Value.ExecutionModel))\n    throw new InvalidOperationException($\"Entry point '{entryPoint.Value.RealName}' ({entryPoint.Value.ExecutionModel}) not in module\");","typeGuard":null,"tryCatchPattern":"try { var src = translator.Translate(backend, entryPoint); } catch (Exception ex) when (ex.Message.Contains(\"could not set entry point\")) { Log.Error($\"Entry point '{entryPoint?.RealName}' invalid; available: {string.Join(\", \", translator.GetEntryPoints(backend).Select(e => e.RealName))}\"); throw; }","preventionTips":["Always derive entry points from GetEntryPoints on the same Words buffer being translated","Never cache entry-point names across shader recompilations","Match names case-sensitively","Pair RealName with its ExecutionModel from the same list entry"],"tags":["spirv-cross","entry-point","shader-compilation","invalid-argument"],"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-15T23:17:13.987Z"}