[Mesa-dev] gl_nir_lower_samplers_as_deref vs drawpixels lowering

Connor Abbott cwabbott0 at gmail.com
Mon Nov 25 10:24:55 UTC 2019


Why are you calling gl_nir_lower_samplers_as_deref twice? The entire
point of it is to deal with the crazy legacy GL model where samplers
are "just normal uniforms" that can be embedded in structs and calling
glUniform() can update the sampler binding. It doesn't touch samplers
with an explicit binding at all. It does set nir->info.textures_used,
but that's a small part of what it does. So while you certainly could
make it re-entrant, it really wouldn't make any sense to call it twice
as it isn't necessary for any mesa-internal samplers besides the
(trivial) updating textures_used. So I'd say that the best course of
action is to just update nir->info.textures_used by yourself in the
drawpix lowering pass and not call gl_nir_lower_samplers_as_deref.
Maybe longer-term the solution is to fill that out in nir_gather_info?

Connor

On Mon, Nov 25, 2019 at 6:56 AM Dave Airlie <airlied at gmail.com> wrote:
>
> I was asked to use some newer radeonsi code in my tgsi info gathering
> wrapper for NIR. One of the things it does is use
> nir->info.textures_used.
>
> Now with the piglit test draw-pixel-with-texture there is a reentrancy
> issue with the passes.
>
> We create a shader and gl_nir_lower_samplers_as_deref get called on
> it, this sets nir->info.textures_used to 1, and it also lowers all
> texture derefs in the shader.
>
> The shader gets used in a variant later for drawpixels, the drawpixels
> lowering then adds it's own "drawpix" sampler an accesses it with
> derefs. Then gl_nir_lower_samplers_as_deref gets called again for the
> whole shader in finalisation, but this time the first set of derefs
> have already been lowered so it only lowers the new drawpix ones, and
> sets nir->info.textures_used to 2 (it's a bitfield), it should be 3.
>
> Are the other drivers seeing this? any ideas on what needs to be
> fixed, the nir sampler lowering could I suppose record
> nir->info.textures_used for non-deref textures as well.
>
> Dave.


More information about the mesa-dev mailing list