nir: Add a range_base+range to nir_intrinsic_load_ubo().
authorEric Anholt <eric@anholt.net>
Fri, 14 Aug 2020 20:10:02 +0000 (13:10 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 8 Sep 2020 18:20:51 +0000 (18:20 +0000)
commitf3b33a5a35e605101d45213bddf52f2f800a52bb
treef3d31817e38e31de8ffbb7101abd2bda7e5df448
parent3a9356831a962997e37589c7a04e12aaa85a99e3
nir: Add a range_base+range to nir_intrinsic_load_ubo().

For UBO accesses to be the same performance as classic GL default uniform
block uniforms, we need to be able to push them through the same path.  On
freedreno, we haven't been uploading UBOs as push constants when they're
used for indirect array access, because we don't know what range of the
UBO is needed for an access.

I believe we won't be able to calculate the range in general in spirv
given casts that can happen, so we define a [0, ~0] range to be "We don't
know anything".  We use that at the moment for all UBO loads except for
nir_lower_uniforms_to_ubo, where we now avoid losing the range information
that default uniform block loads come with.

In a departure from other NIR intrinsics with a "base", I didn't make the
base an be something you have to add to the src[1] offset.  This keeps us
from needing to modify all drivers (particularly since the base+offset
thing can mean needing to do addition in the backend), makes backend
tracking of ranges easy, and makes the range calculations in
load_store_vectorizer reasonable.  However, this could definitely cause
some confusion for people used to the normal NIR base.

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6359>
src/compiler/nir/nir.h
src/compiler/nir/nir_intrinsics.py
src/compiler/nir/nir_lower_io.c
src/compiler/nir/nir_lower_uniforms_to_ubo.c
src/compiler/nir/nir_opt_load_store_vectorize.c
src/compiler/nir/nir_print.c
src/compiler/nir/nir_validate.c
src/compiler/nir/tests/load_store_vectorizer_tests.cpp
src/compiler/spirv/vtn_variables.c
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/intel/vulkan/anv_nir_apply_pipeline_layout.c