Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shaderc_compile_into_spv() ignores the entry point name parameter #1465

Open
theagentd opened this issue Dec 26, 2024 · 3 comments
Open

shaderc_compile_into_spv() ignores the entry point name parameter #1465

theagentd opened this issue Dec 26, 2024 · 3 comments

Comments

@theagentd
Copy link

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.

@SC5Shout
Copy link

SC5Shout commented Jan 5, 2025

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

@theagentd
Copy link
Author

Thanks for reproducing it! Glad to know I'm not crazy. :)

@theagentd
Copy link
Author

Had a look at the code here, found this:

// the entry point name for HLSL compilation. For GLSL compilation, the
// entry point name is assumed to be "main".

// 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants