[Mesa-dev] Question for nir lower load uniform to scalar

Qiang Yu yuq825 at gmail.com
Sat Aug 26 01:50:06 UTC 2017


On Sat, Aug 26, 2017 at 3:07 AM, Eric Anholt <eric at anholt.net> wrote:
> Qiang Yu <yuq825 at gmail.com> writes:
>
>> Hi Eric,
>>
>> I'm working on lima gp compiler which should benefit from nir lowering
>> uniform load to scalar.
>> I notice you write the nir_lower_io_to_scalar.c which support lowering
>> shader_in/shader_out
>> but left the uniform lowering in vc4 driver, any reason why not
>> implement in the nir_lower_io_to_scalar.c?
>
> I think my theory was that drivers would want different units for the
> base/offset (bytes or dwords), so I left it in vc4.  Anyone else want to
> weigh in on this?  vc4 wants indirect load offsets in units of bytes.
Oh, I see, unfortunately lima gp need the base/offset in 4 components
just as the nir base/offset, so I have to come to add a component field.

>
>> I'm new to nir, tried to add it but seems not correct after
>> optimization pass. So I should missing
>> some place, anyone can help to point out?
>
> Your nir_lower_io.c code looks correct to me, so I'm not sure what might
> be missing.  I'm not sure about using the component field, though -- for
> VC4 all I want after lowering is a byte offset within the constant
> buffer.
After some dump, it just go wrong from the CSE pass which eliminate
the ssa from the component != 0. Maybe some change need for the
CSE to know the load_uniform component field just like load_input.

The problem is found to be my fault not change the num_indices:
- LOAD(uniform, 1, 2, BASE, RANGE, COMPONENT,
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
+ LOAD(uniform, 1, 3, BASE, RANGE, COMPONENT,
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)

Thanks,
Qiang


More information about the mesa-dev mailing list