glsl: Link error if fs defines conflicting qualifiers for gl_FragCoord
GLSL 1.50 spec says: "If gl_FragCoord is redeclared in any fragment shader in a program, it must be redeclared in all the fragment shaders in that program that have a static use gl_FragCoord. All redeclarations of gl_FragCoord in all fragment shaders in a single program must have the same set of qualifiers." This patch causes the shader link to fail if we have multiple fragment shaders with conflicting layout qualifiers for gl_FragCoord. V2: Restructure the code and add conditions to correctly handle the following case: fragment shader 1: layout(origin_upper_left) in vec4 gl_FragCoord; void main() { foo(); gl_FragColor = gl_FragData; } fragment shader 2: layout(pixel_center_integer) in vec4 gl_FragCoord; void foo() { } V3: Allow linking in the following case: fragment shader 1: void main() { foo(); gl_FragColor = gl_FragCoord; } fragment shader 2: in vec4 gl_FragCoord; void foo() { ... } Signed-off-by:Anuj Phogat <anuj.phogat@gmail.com> Cc: <mesa-stable@lists.freedesktop.org> Reviewed-by:
Ian Romanick <ian.d.romanick@intel.com>
- src/glsl/ast_to_hir.cpp 5 additions, 0 deletionssrc/glsl/ast_to_hir.cpp
- src/glsl/glsl_parser_extras.cpp 21 additions, 0 deletionssrc/glsl/glsl_parser_extras.cpp
- src/glsl/glsl_parser_extras.h 1 addition, 0 deletionssrc/glsl/glsl_parser_extras.h
- src/glsl/linker.cpp 77 additions, 0 deletionssrc/glsl/linker.cpp
- src/mesa/main/mtypes.h 8 additions, 0 deletionssrc/mesa/main/mtypes.h