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

vulkan shader in/out variables do not need to have the same name. #3809

Open
theodoregoetz opened this issue Dec 12, 2024 · 1 comment
Open

Comments

@theodoregoetz
Copy link

A recent commit 69249e4 included in release 15.0.0 seems to indicate that the names of variables passed from one stage to the next must match, and only for vulkan. I could not find any documentation to that effect and found explicit mention to the contrary here, though there is no citation:

A very important detail, is that when compiling a pipeline which uses this sort of input and output variables, they always have to match. If there is a mismatch, the pipeline compilation will fail.

To create an output variable, we do this on the vertex shader.

layout (location = 0) out vec3 outColor;

layout(location = 0) is a decorator that lets us add “extra data” to variable declarations and other things in GLSL. In here, we are declaring location = 0, which means that this variable of type vec3 will be on the number 0 slot.

To read the variable from pixel stage, we do this.

layout (location = 0) in vec3 inColor;

The names of the variables do not need to match. On the vertex shader we are calling it outColor, but on the fragment shader > we are calling it inColor. What does need to match, is the Location decorator and the type of the variable. In this case, it’s a location 0 vec3 variable, so things match.

In addition to this, I see the same validation check fails when using gl_* input variables in the fragment shader that have no explicit output equivalent in the vertex shader. For example, if I use gl_SampleMaskIn in the fragment shader, I get this error when linking the program:

ERROR: Linking vertex and fragment stages: Input 'gl_SampleMaskIn' in fragment shader has no corresponding output in vertex shader.

It seems to be that there are two problems to be solved here:

  1. variable names do not matter when passing from one stage to the next, only location (and maybe type?)
  2. built-in variables should not be considered when trying to match inputs of one stage with the outputs of the previous stage.

All of this was seen on Linux Fedora 41 using the tagged source of glslang at 15.0.0, using shader code with the following first three lines:

#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_OES_sample_variables : enable
@jeremy-lunarg
Copy link
Contributor

We've reverted #3840. Can you verify that this issue is resolved?

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