OSDN Git Service

nir: Gather texture bitmasks in gl_nir_lower_samplers_as_deref.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 13 Jan 2019 18:39:41 +0000 (10:39 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 12 Feb 2019 05:34:45 +0000 (21:34 -0800)
commitf5c7df4dc95ca115b1a1c916b0b133692a7ea6d9
tree7eb9abcca491dafa9e08ee7293969d52ede42e17
parent120f9b8362284e6e8ad62aa85a9e2578db73f272
nir: Gather texture bitmasks in gl_nir_lower_samplers_as_deref.

Eric and I would like a bitmask of which samplers are used, similar to
prog->SamplersUsed, but available in NIR.  The linker uses SamplersUsed
for resource limit checking, but later optimizations may eliminate more
samplers.  So instead of propagating it through, we gather a new one.
While there, we also gather the existing textures_used_by_txf bitmask.

Gathering these bitfields in nir_shader_gather_info is awkward at best.
The main reason is that it introduces an ordering dependency between the
two passes.  If gathering runs before lower_samplers_as_deref, it can't
look at var->data.binding.  If the driver doesn't use the full lowering
to texture_index/texture_array_size (like radeonsi), then the gathering
can't use those fields.  Gathering might be run early /and/ late, first
to get varying info, and later to update it after variant lowering.  At
this point, should gathering work on pre-lowered or post-lowered code?
Pre-lowered is also harder due to the presence of structure types.

Just doing the gathering when we do the lowering alleviates these
ordering problems.  This fixes ordering issues in i965 and makes the
txf info gathering work for radeonsi (though they don't use it).

Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/gl_nir_lower_samplers_as_deref.c
src/compiler/nir/nir_gather_info.c
src/compiler/shader_info.h
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_nir.h
src/mesa/state_tracker/st_nir_builtins.c