st/nir: Re-vectorize shader IO
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 11 Apr 2019 19:28:48 +0000 (12:28 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 28 May 2019 08:06:48 +0000 (01:06 -0700)
commitc31b4420e7812e144d9d7601c037e3225000b24c
treef3061efb70d3b220bf78700e19326603b39e5b75
parent1d0a8cf40d87ee903d7738f05bf87fd4141ce40d
st/nir: Re-vectorize shader IO

We scalarize IO to enable further optimizations, such as propagating
constant components across shaders, eliminating dead components, and
so on.  This patch attempts to re-vectorize those operations after
the varying optimizations are done.

Intel GPUs are a scalar architecture, but IO operations work on whole
vec4's at a time, so we'd prefer to have a single IO load per vector
rather than 4 scalar IO loads.  This re-vectorization can help a lot.

Broadcom GPUs, however, really do want scalar IO.  radeonsi may want
this, or may want to leave it to LLVM.  So, we make a new flag in the
NIR compiler options struct, and key it off of that, allowing drivers
to pick.  (It's a bit awkward because we have per-stage settings, but
this is about IO between two stages...but I expect drivers to globally
prefer one way or the other.  We can adjust later if needed.)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/nir/nir.h
src/mesa/state_tracker/st_glsl_to_nir.cpp