intel/compiler: Do interpolateAtOffset coordinate scaling in NIR
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 5 Aug 2020 02:01:13 +0000 (19:01 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 18 Nov 2020 23:26:53 +0000 (23:26 +0000)
commit97ebb896afb6801d1fcd69556583975411379998
tree616d50d18d2f77af26286c6a4cbd0f86ba71610e
parent0d3b61dd7e8ce80f5ec0cbe27e901747e9e0e61d
intel/compiler: Do interpolateAtOffset coordinate scaling in NIR

In our source languages, interpolateAtOffset() takes a floating point
offset in the range [-0.5, +0.5].  However, the hardware takes integer
valued offsets in the range [-8, 7], in units of 1/16th of a pixel.

So, we need to multiply and clamp the coordinates.  We were doing this
in the FS backend, but with the advent of IBC, I'd like to avoid doing
it twice.  This patch instead moves the lowering to NIR so we can reuse
it across both backends.

v2: Use nir_shader_instructions_pass (suggested by Eric Anholt).

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6193>
src/intel/compiler/brw_fs_nir.cpp
src/intel/compiler/brw_nir.c