Bug 31985 - [GLSL 1.20] initialized uniform array considered as "unsized"
Summary: [GLSL 1.20] initialized uniform array considered as "unsized"
Status: CLOSED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: 7.9
Hardware: All Linux (All)
: medium minor
Assignee: Ian Romanick
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-30 00:06 UTC by Gordon Jin
Modified: 2011-01-03 16:37 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
new test case for piglit shader_runner (381 bytes, application/octet-stream)
2010-11-30 00:06 UTC, Gordon Jin
Details

Description Gordon Jin 2010-11-30 00:06:13 UTC
Created attachment 40658 [details]
new test case for piglit shader_runner

below array is declared with implicit size, but after initialization (so it should be explicitly sized) it's still (wrongly) considered as unsized.

uniform float a[] = float[](0,1,2,3,4);


The attached case fails with below error:

Failed to compile FS: 0:5(15): error: length called on unsized array.

PIGLIT: {'result': 'fail' }


It will pass if the array is local variable instead of uniform variable.

Tested on Piketon (i965) with mesa master.
Comment 1 Vinson Lee 2010-12-03 22:59:58 UTC
Test case (attachment id=40658) committed to piglit.

commit 4a80100f8c735bc055bde1f18e4052c311f20eb3
Author: Gordon Jin <gordon.jin@intel.com>
Date:   Fri Dec 3 22:58:07 2010 -0800

    glsl-array-uniform-length: Add test case from FDO bug 31985.
Comment 2 Ian Romanick 2010-12-07 16:38:06 UTC
The piglit test array-compare-04.vert (bug #32035) also hits this issue.  Fixed by:

commit 7bdaa2c5ad7ef02c1c97367839962ec03361c528
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Tue Dec 7 16:27:22 2010 -0800

    glsl: Inherrit type of declared variable from initializer
    
    Types of declared variables and their initializer must match excatly
    except for unsized arrays.  Previously the type inherritance for
    unsized arrays happened implicitly in the emitted assignment.
    However, this assignment is never emitted for uniforms.  Now that type
    is explicitly copied unconditionally.
    
    Fixes piglit test array-compare-04.vert (bugzilla #32035) and
    glsl-array-uniform-length (bugzilla #31985).
    
    NOTE: This is a candidate for the 7.9 branch.
Comment 3 Gordon Jin 2010-12-09 20:08:43 UTC
verified
Comment 4 Gordon Jin 2010-12-09 20:12:18 UTC
oh, forgot this is being tracked for 7.9.
Comment 5 Ian Romanick 2011-01-03 14:23:16 UTC
commit 7b6b66d617b1f14f79fb7af2dad268a68e35b9e3
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Fri Dec 17 13:50:40 2010 -0800

    glsl: Inherrit type of declared variable from initializer after processing a
    
    do_assignment may apply implicit conversions to coerce the base type
    of initializer to the base type of the variable being declared.  Fixes
    piglit test glsl-implicit-conversion-02 (bugzilla #32287).  This
    probably also fixes bugzilla #32273.
    
    NOTE: This is a candidate for the 7.9 branch and the 7.10 branch.
    (cherry picked from commit d7f27e2e76eac9bc2ee0fa36f52542fdcb9563dd)
    
    Conflicts:
    
        src/glsl/ast_to_hir.cpp
Comment 6 Ian Romanick 2011-01-03 14:26:57 UTC
(In reply to comment #5)
> commit 7b6b66d617b1f14f79fb7af2dad268a68e35b9e3
> Author: Ian Romanick <ian.d.romanick@intel.com>
> Date:   Fri Dec 17 13:50:40 2010 -0800
> 
>     glsl: Inherrit type of declared variable from initializer after processing
> a
> 
>     do_assignment may apply implicit conversions to coerce the base type
>     of initializer to the base type of the variable being declared.  Fixes
>     piglit test glsl-implicit-conversion-02 (bugzilla #32287).  This
>     probably also fixes bugzilla #32273.
> 
>     NOTE: This is a candidate for the 7.9 branch and the 7.10 branch.
>     (cherry picked from commit d7f27e2e76eac9bc2ee0fa36f52542fdcb9563dd)
> 
>     Conflicts:
> 
>         src/glsl/ast_to_hir.cpp

Apologies.  That was the wrong commit.  This is the commit in the 7.9 branch that fixes this issue:

commit 2b4277dcf32a88d72fd4e89f3be61e7298c71637
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Tue Dec 7 16:27:22 2010 -0800

    glsl: Inherrit type of declared variable from initializer
    
    Types of declared variables and their initializer must match excatly
    except for unsized arrays.  Previously the type inherritance for
    unsized arrays happened implicitly in the emitted assignment.
    However, this assignment is never emitted for uniforms.  Now that type
    is explicitly copied unconditionally.
    
    Fixes piglit test array-compare-04.vert (bugzilla #32035) and
    glsl-array-uniform-length (bugzilla #31985).
    
    NOTE: This is a candidate for the 7.9 branch.
    (cherry picked from commit b0fc5103cbc9116806a9888f747baed4b8166246)


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.