[Mesa-dev] glsl2: assignment write masks vs. swizzles

Aras Pranckevicius aras at unity3d.com
Thu Aug 5 09:21:11 PDT 2010


Since commit 5a7758efbe14dee026245a4f4f4fb3ccf7b2c23b (Add
ir_assignment::write_mask and associated methods) I'm somewhat
confused about types and swizzles.

Expression like this:
    gl_Position.zw = gl_Vertex.xy*2.0;
now produces IR that has vec4 node types:

    (declare (temporary ) vec2 tmpvar_1)
    (assign (constant bool (1))
        (var_ref tmpvar_1)
        (expression vec2 * (swiz xy (var_ref gl_Vertex))(constant
float (2.0)) ) )
    (assign (constant bool (1))
        (var_ref gl_Position)
        (swiz xxxy (var_ref tmpvar_1) ))

in the last two lines line, var_ref gl_Position has vec4 type, also
the xxxy swizzle has vec4 type.

Is that expected behavior, or something ir_assignment::set_lhs and
friends don't handle correctly?

If the behavior is expected, how a "xxxy" swizzle should be
interpreted? First two components ignored because a write mask is .zw
up above? Also, why vec4 node types come into play when everything in
the source was vec2?

Aras Pranckevičius
work: http://unity3d.com
home: http://aras-p.info

More information about the mesa-dev mailing list