Bug 31650 - [GLSL] varying gl_TexCoord fails to be re-declared to different size in the second shader
[GLSL] varying gl_TexCoord fails to be re-declared to different size in the s...
Status: VERIFIED FIXED
Product: Mesa
Classification: Unclassified
Component: glsl-compiler
7.10
All Linux (All)
: medium normal
Assigned To: Ian Romanick
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-15 22:07 UTC by Gordon Jin
Modified: 2011-01-04 19:32 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
test case for piglit shader_runner (428 bytes, text/plain)
2010-11-15 22:07 UTC, Gordon Jin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon Jin 2010-11-15 22:07:13 UTC
Created attachment 40303 [details]
test case for piglit shader_runner

GLSL spec v1.10 Section 7.6 says:
"Unlike user-defined varying variables, the built-in varying variables don't have a strict one-to-one correspondence between the vertex language and the fragment language. Two sets are provided, one for each language."

The attached case tries to declare varying built-in variable gl_TexCoord to different sizes between vertex and fragment shaders, but it fails to link:
error: vertex shader output 'gl_TexCoord' declared as type 'vec4[2]', but fragment shader input declared as type 'vec4[1]'

Tested on Piketon (i965) with mesa master.
Comment 1 Ian Romanick 2010-11-16 12:25:27 UTC
In the vertex shader, there are built-in outputs called gl_FrontColor and gl_BackColor.  One of these ends up in the fragment shader built-in input gl_Color.  This is what section 7.6 is referring to.

gl_TexCoord is a bit of a special case.  It's declared as 'vec4 gl_TexCoord[]' (unsized array), and shaders that will use variable accesses to it must redeclare it with a size.  This sizes of other arrays, even built-in arrays, are required to match between the vertex shader and the fragment shader.

What does this test do on other GL implementations?  Perhaps Vinson and Ken can try it on "the other three" and let us know.
Comment 2 Kenneth Graunke 2010-11-16 14:17:52 UTC
Catalyst 10.10 succesfully links the two shaders and draws green.  I was concerned that gl_TexCoord might have been dead-code eliminated, seeing as the test never reads nor writes it, but even after modifying the test to use it, the two shaders still link.

I don't have access to my nVidia hardware at the moment, but I can try it soon.
Comment 3 Vinson Lee 2010-11-16 20:41:32 UTC
The attached piglit case (id=40303) passes on Mac OS X. The entire window is green.
Comment 4 Vinson Lee 2010-11-19 19:12:31 UTC
The attached piglit case (id=40303) passes on the Windows Intel driver. The entire window is green.
Comment 5 Vinson Lee 2010-11-19 19:15:12 UTC
The attached piglit case (id=40303) passes with the NVIDIA driver. The entire window is green.
Comment 6 Vinson Lee 2010-11-24 16:27:44 UTC
I've committed the attachment id=40303 to piglit.
Comment 7 Ian Romanick 2010-12-13 15:25:43 UTC
commit cb2b547a4771ddf56975ede566dbf3a8f5389689
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Mon Dec 13 15:16:39 2010 -0800

    linker: Allow built-in arrays to have different sizes between shader stages
    
    Fixes pitlit test glsl-link-varying-TexCoord (bugzilla #31650).
Comment 8 Ian Romanick 2010-12-13 15:51:28 UTC
Reopening until the fix is cherry-picked to the 7.10 and 7.9 branches.  Apologies for the breach of procedure.
Comment 9 Ian Romanick 2011-01-03 16:50:38 UTC
commit 4febfee3b77faa8abbcc152896d76de30043c823
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Mon Dec 13 15:16:39 2010 -0800

    linker: Allow built-in arrays to have different sizes between shader stages
    
    Fixes pitlit test glsl-link-varying-TexCoord (bugzilla #31650).
    (cherry picked from commit cb2b547a4771ddf56975ede566dbf3a8f5389689)
Comment 10 Gordon Jin 2011-01-04 19:32:27 UTC
verified on 7.10 branch