[Mesa-dev] [PATCH] glsl: Lower variable indexing of system value arrays; treat like inputs.

Kenneth Graunke kenneth at whitecape.org
Mon Apr 4 17:22:21 UTC 2016


On Monday, April 4, 2016 12:05:20 PM PDT Ilia Mirkin wrote:
> For those (few, I'm sure) of us who are exceedingly lazy, what [glsl
> ir] code ends up getting generated as a result of this?
> 
> int temp;
> if (zero == 0) temp = gl_SampleMaskIn[0]
> else leave temp undefined?

Running my new samplemaskin-indirect Piglit test, it appears to create:

(assign (x) (var_ref dereference_array_value)
            (array_ref (var_ref gl_SampleMaskIn) (constant uint (0))))

a.k.a.

   temp = gl_SampleMaskIn[0];

For arrays of size <= 4, lower_variable_index_to_cond_assign() creates
if-ladders that try array indexes sequentially.  It also unconditionally
reads the first element.

So, if there were 64 samples, the array size would be [2], and it would
generate:

    temp = gl_SampleMaskIn[0]
    if (index == 1)
        temp = gl_SampleMaskIn[1];

This seems optimal.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160404/48e2f25f/attachment.sig>


More information about the mesa-dev mailing list