Summary: | linker error "fragment shader input ... has no matching output in the previous stage" when previous stage's output declaration in a separate shader object | ||
---|---|---|---|
Product: | Mesa | Reporter: | Marcel Heinz <quisquilia> |
Component: | glsl-compiler | Assignee: | mesa-dev |
Status: | RESOLVED FIXED | QA Contact: | Intel 3D Bugs Mailing List <intel-3d-bugs> |
Severity: | minor | ||
Priority: | medium | CC: | quisquilia |
Version: | git | ||
Hardware: | All | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: |
C/OpenGL code to trigger the issue
updated reproducer code |
Should be fixed by: Author: vadym.shovkoplias <vadym.shovkoplias@globallogic.com> Date: Tue Aug 28 10:32:18 2018 +0300 glsl/linker: Link all out vars from a shader objects on a single stage During intra stage linking some out variables can be dropped because it is not used in a shader with the main function. But these out vars can be referenced on later stages which can lead to further linking errors. Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105731 Vadym, can you make a piglit test for this bug? (In reply to Mark Janes from comment #3) > Vadym, can you make a piglit test for this bug? Hi Mark, this was already done :) commit c98669cbd1f801c8fda25aceab23b5c54de76b9e Author: Vadym Shovkoplias <vadim.shovkoplias@gmail.com> Date: Mon Aug 27 15:19:40 2018 +0300 glsl-1.30: add linker test for inter stage in/out vars usage This test exposes a Mesa GLSL linker bug. The test fails with the following error message: error: fragment shader input `foo' has no matching output in the previous stage Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias@globallogic.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105731 Created attachment 142005 [details]
updated reproducer code
Comment on attachment 142005 [details] updated reproducer code The bugfix from https://patchwork.freedesktop.org/patch/246171/ did solve the issue for my first reproducer, the issue is not completely resolved. This is an updated version of the reproducer code, which triggers the issue again. The only changes are that there are now _two_ VS outputs which are not written to, but both are used in the fragment shader: Reopened bug because bug was not completely resolved. See the second attachment with the updated reproducer code for another case to tirgger the issue. (In reply to Marcel Heinz from comment #7) > Reopened bug because bug was not completely resolved. See the second > attachment with the updated reproducer code for another case to tirgger the > issue. Hi Marcel, Thanks for the new test. I also able to reproduce this. Already found the reason and pushed new patch: https://patchwork.freedesktop.org/patch/258176/ Hi Vadym, thank you for that patch. Again, it does fix the updated reproducer, but the issue is still not completely resolved in the real application. However, it is down from 17 failing programs to only 2, so we are getting closer. I will try to isolate the issue in the two remaining programs, and report back my findings. Hi Vadym, I have to take my last comment back. It turned out that in the two remaining cases, there was actually no output declaration for the variable in question, so mesa's behavior was perfectly right already. Changed bug to RESOLVED status. Thank You very much. Hi Marcel, Glad to hear this issue is finally fixed! Thanks a lot for such a high quality bug report and assistance/testing. Piglit test is also updated with the additional out variable: https://patchwork.freedesktop.org/patch/258899/ |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.
Created attachment 138342 [details] C/OpenGL code to trigger the issue GLSL spec (using version 4.30 here, section "4.3.4 Input variables", page 43f) states that there should be no link error if an input variable is used for which there is no static use in the previous stage, but a valid output declaration. Mesa's linker seems to adhere to this not in every case. If the declaration is in a separate shader object, it fails to link. See the attached example code. The key point is the following vertex shader: static const char *vs_part1= "out vec4 foo;\n" "void unused() {foo=vec4(1);}\n"; static const char *vs_part2= "in vec4 pos;\n" "void main() { gl_Position = pos; }\n"; used in conjunction with this fragment shader: static const char *fs_part1= "in vec4 foo;\n" "out vec4 color;\n" "void main() {color=foo;}\n"; When this is created as a single GL_VERTEX_SHADER with both strings concatenated (via glShaderSource), the resulting program will link, just with a warning warning: fragment shader varying foo not written by vertex shader which is conforming behavior. However, when vs_part1 and vs_part2 are compiled as separate shader objects, the final link fails with error: fragment shader input `foo' has no matching output in the previous stage which (in my interpretation of the spec) should not happen. Tested with: OpenGL vendor string: Intel Open Source Technology Center OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.1.1 (git-092c485) as well as: OpenGL vendor string: Intel Open Source Technology Center OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.1.0-devel (git-ff0e3fa1fe)