i965/fs: Fix stride field for uniforms.
authorFrancisco Jerez <currojerez@riseup.net>
Mon, 13 Jul 2015 12:29:39 +0000 (15:29 +0300)
committerFrancisco Jerez <currojerez@riseup.net>
Tue, 21 Jul 2015 14:54:00 +0000 (17:54 +0300)
commit9383664a9cbc5bc4858fc50d7fa565f43028d779
treee18260dbaf8717f3b811e747da84ab088f3126b9
parent5f8d9ae5a54961deb02eb52e924a84b99b60f035
i965/fs: Fix stride field for uniforms.

This fixes essentially the same problem as for immediates.  Registers
of the UNIFORM file are typically accessed according to the formula:

 read_uniform(r, channel_index, array_index) =
    read_element(r, channel_index * 0 + array_index * 1)

Which matches the general direct addressing formula for stride=0:

 read_direct(r, channel_index, array_index) =
    read_element(r, channel_index * stride +
                    array_index * max{1, stride * width})

In either case if reladdr is present the access will be according to
the composition of two register regions, the first one determining the
per-channel array_index used for the second, like:

 read_indirect(r, channel_index, array_index) =
    read_direct(r, channel_index,
                read(r.reladdr, channel_index, array_index))

where:
 read(r, channel_index, array_index) = if r.reladdr == NULL
    then read_direct(r, channel_index, array_index)
    else read_indirect(r, channel_index, array_index)

In conclusion we can handle uniforms consistently with the other
register files if we set stride to zero.  After lowering to a GRF
using VARYING_PULL_CONSTANT_LOAD in demote_pull_constant_loads() the
stride of the source is set to one again because the result of
VARYING_PULL_CONSTANT_LOAD is generally non-uniform.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/mesa/drivers/dri/i965/brw_fs.cpp