shaderc_compile_into_spv() ignores the entry point name parameter
It seems like shaderc_compile_into_spv() completely ignores whatever string you put into the entry_point_name parameter. You can specify anything into it without affecting anything at all, for example an empty string (just a null terminator). The output SPIR-V is completely identical regardless of what is set as the entry point.
This does not seem like intended behaviour, as this is written in a comment in the source code:
The entry_point_name null-terminated string defines the name of the entry point to associate with this GLSL source.
From this, while it is unclear if the entry point name should control which function is used in GLSL, it does seem like it definitely should at least affect the entry point name in the output SPIR-V. Currently, the entry point name "main" is always used, both when finding what function to use as an entry point in the GLSL code, and as the name for the entry point in the output SPIR-V.
I would be very grateful if someone could reproduce this issue. I'm using Shaderc through the latest version of the LWJGL Java binding, but have verified that the data I'm passing in is correct. However, I'm not entirely sure which version of Shaderc that LWJGL uses, so it would be good to confirm it. A minimal shader with just an empty main() function is enough to reproduce the issue.
Bump:
std::string code = R"(
#version 450
void mainVS()
{
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
)";
auto compileRes = compiler.CompileGlslToSpv(
code,
shaderc_vertex_shader,
"shader",
"mainVS",
options
);
if (compileRes.GetCompilationStatus() != shaderc_compilation_status_success) {
printf("%s\n", compileRes.GetErrorMessage().c_str());
}
gives: shader: error: Linking vertex stage: Missing entry point: Each stage requires one entry point
Thanks for reproducing it! Glad to know I'm not crazy. :)
Had a look at the code here, found this:
https://github.com/google/shaderc/blob/690d259384193c90c01b52288e280b05a8481121/libshaderc/include/shaderc/shaderc.hpp#L413-L414
// The entry_point_name parameter is a null-terminated string specifying // the entry point name for HLSL compilation. For GLSL compilation, the // entry point name is assumed to be "main".
So it looks like this is actually intended behaviour. The question is: why? It would be quite useful for me to specify multiple entry points in the same shader file and select one during compilation time.
I meet the same issue. It makes me confuse, why we need a argument that only works for hlsl in this glsl interface CompileGlslToSpv?
I'm guessing it's not changed exactly a year later? VkPipelineShaderStageCreateInfo literally has an entrypoint parameter: pName. :(