Bug 44968

Summary: [bisected] piglit shaders_GLSL_link_two_programs,_global_initializer regressed
Product: Mesa Reporter: fangxun <xunx.fang>
Component: glsl-compilerAssignee: Ian Romanick <idr>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: christophe.prigent
Version: git   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description fangxun 2012-01-19 22:19:49 UTC
System Environment:
--------------------------
Arch:           i386
Platform:       Sugarbay
Libdrm:         (master)2.4.30-1-g66518ab5653cfdc840cd69e7b653ec05df060584
Mesa:           (8.0)c85402aba91755808729fadf57a9f92285f4e61a
Xserver:                (server-1.11-branch)xorg-server-1.11.3
Xf86_video_intel:(master)2.17.0-478-g35f81005f91d294e61bb4ced7cbddd1a76ccb324
Kernel:         (drm-intel-fixes) 8109021313c7a3d8947677391ce6ab9cd0bb1d28

Bug detailed description:
------------------------- 
It fails on Sandybridge, ironlake and pineview. 
Bisect shows f37b1ad937dd2c420f4c9fd9aa5887942bd31f3f is the first bad commit
commit f37b1ad937dd2c420f4c9fd9aa5887942bd31f3f
Author:     Ian Romanick <ian.d.romanick@intel.com>
AuthorDate: Mon Oct 31 14:31:07 2011 -0700
Commit:     Ian Romanick <ian.d.romanick@intel.com>
CommitDate: Thu Nov 3 13:36:00 2011 -0700

    linker: Check that initializers for global variables match

    This requires tracking a couple extra fields in ir_variable:

     * A flag to indicate that a variable had an initializer.

     * For non-const variables, a field to track the constant value of the
       variable's initializer.

Reproduce steps:
----------------
1. start X
2. ./glsl-link-initializer-03 -auto -fbo
Comment 1 Ian Romanick 2012-01-20 15:22:20 UTC
The comment around line 494 in linker.cpp explains the problem:

		  /* FINISHME: This is wrong.  The constant_value field should
		   * FINISHME: not be modified!  Imagine a case where a shader
		   * FINISHME: without an initializer is linked in two different
		   * FINISHME: programs with shaders that have differing
		   * FINISHME: initializers.  Linking with the first will
		   * FINISHME: modify the shader, and linking with the second
		   * FINISHME: will fail.
		   */

This test case was created specifically to trigger this bug.  Unfortunately, the fix is non-trival, and has no chance of making the 8.0 release.
Comment 2 Gordon Jin 2012-03-31 18:15:33 UTC
looks like not high priority bug to me.
Comment 3 Timothy Arceri 2018-03-06 04:23:37 UTC
Looks to have been fixed by:

commit 9bea01899433ca6a8047b4172ffec6e89afe7625
Author: Juan A. Suarez Romero <jasuarez@igalia.com>
Date:   Wed May 11 13:48:18 2016 +0200

    glsl: use var with initializer on global var validation
    
    Currently, when cross validating global variables, all global variables
    seen in the shaders that are part of a program are saved in a table.
    
    When checking a variable this already exist in the table, we check both
    are initialized to the same value. If the already saved variable does
    not have an initializer, we copy it from the new variable.
    
    Unfortunately this is wrong, as we are modifying something it is
    constant. Also, if this modified variable is used in
    another program, it will keep the initializer, when it should have none.
    
    Instead of copying the initializer, this commit replaces the old
    variable with the new one. So if we see again the same variable with an
    initializer, we can compare if both are the same or not.
    
    v2: convert tabs in whitespaces (Kenenth Graunke)
    
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

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.