[Mesa-dev] Question about implementing viewport transfer and const load in nir

Rob Clark robdclark at gmail.com
Tue Aug 29 12:28:49 UTC 2017

On Sat, Aug 26, 2017 at 9:40 AM, Qiang Yu <yuq825 at gmail.com> wrote:
> Hi guys,
> When working on lima gp compiler, I come across two problems about
> inserting extra uniform
> and instructions in nir for the driver and don't know where's the
> right place to do it. So I'd like
> to hear your opinion and if there's other driver already did so.
> 1. viewport transfer
> lima gp needs embed viewport transfer into vertex shader, so need to
> insert a uniform which
> holds the scale and transfer and some instruction to apply the
> calculation to the gl_Position
> varying output. If do this in driver callback create_vs_state(), seems
> won't affect the state
> tracker to allocate uniform space for it, maybe add something in
> st_create_vp_variant()?
> 2. const load
> lima gp needs const be loaded just as uniform, so I have to allocate
> uniform space for them.
> Besides the same problem as 1 (where to do it), the const node may be
> eliminated after driver
> nir optimization and won't have a base filed as uniform.
> Seems some of these (space allocation) need be done in non-driver
> layer and some (instruction
> insertion and uniform base assign to const) can be done in driver.
> BTW. lima gp can only have one uniform buffer, so I can't just use a
> dedicated uniform buffer
> for viewport transfer and const uniform.

btw, does lima have some way to write to memory from cmdstream (ie.
without setting up a full blown draw)?  If so perhaps you could get
away with leaving some extra space at the end of your uniform buffer
that you copy driver internal uniforms into before kicking the draw?

fwiw, freedreno does have driver specific uniforms, see
ir3_driver_param.  Although normal uniforms (ie. non-UBO) get copied
into internal memory, so I just upload driver specific uniforms (as
needed) and immediates to the tail of the uniform memory before the


More information about the mesa-dev mailing list