[Bug 74026] Compiler rejects chained assignments involving array dereferences

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat Jan 25 10:37:32 PST 2014


https://bugs.freedesktop.org/show_bug.cgi?id=74026

Kenneth Graunke <kenneth at whitecape.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Kenneth Graunke <kenneth at whitecape.org> ---
commit 44a86e2b4fca7c7cab243dfa62dc17f4379fc8e3
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Jan 24 10:47:49 2014 -0800

    glsl: Fix chained assignments of vector channels.

    Simple shaders such as:

        void splat(vec2 v, float f) {
            v[0] = v[1] = f;
        }

    failed to compile with the following error:
    error: value of type vec2 cannot be assigned to variable of type float

    First, we would process v[1] = f, and transform:
    LHS: (expression float vector_extract (var_ref v) (constant int (1)))
    RHS: (var_ref f)
    into:
    LHS: (var_ref v)
    RHS: (expression vec2 vector_insert (var_ref v) (constant int (1))
                     (var_ref f))

    Note that the LHS type is now vec2, not a float.  This is surprising,
    but not the real problem.

    After emitting assignments, this ultimately becomes:
    (declare (temporary) vec2 assignment_tmp)
    (assign (xy)
      (var_ref assignment_tmp)
      (expression vec2 vector_insert (var_ref v) (constant int (1))
                  (var_ref f)))
      (assign (xy) (var_ref v) (var_ref assignment_tmp))

    We would then return (var_ref assignment_tmp) as the rvalue, which has
    the wrong type---it should be float, but is instead a vec2.

    To fix this, we simply return (vector_extract (var_ref assignment_temp)
    <the appropriate channel>) to pull out the desired float value.

    Fixes Piglit's chained-assignment-with-vector-constant-index.vert and
    chained-assignment-with-vector-dynamic-index.vert tests.

    Cc: mesa-stable at lists.freedesktop.org
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74026
    Reported-by: Dan Ginsburg <dang at valvesoftware.com>
    Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
    Reviewed-by: Matt Turner <mattst88 at gmail.com>
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20140125/be0e9024/attachment.html>


More information about the intel-3d-bugs mailing list