[Mesa-dev] [PATCH v2] nir: add nir_instr_type_tex support to nir_lower_phis_to_scalar()
Timothy Arceri
tarceri at itsqueeze.com
Fri Feb 22 21:59:20 UTC 2019
total instructions in shared programs: 13219105 -> 13024613 (-1.47%)
instructions in affected programs: 1155045 -> 960553 (-16.84%)
helped: 581
HURT: 100
total cycles in shared programs: 333968972 -> 324813762 (-2.74%)
cycles in affected programs: 129831032 -> 120675822 (-7.05%)
helped: 571
HURT: 159
total spills in shared programs: 57947 -> 29130 (-49.73%)
spills in affected programs: 53364 -> 24547 (-54.00%)
helped: 351
HURT: 0
total fills in shared programs: 51310 -> 25468 (-50.36%)
fills in affected programs: 44882 -> 19040 (-57.58%)
helped: 351
HURT: 0
---
src/compiler/nir/nir_lower_phis_to_scalar.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c
index 16001f73685..677ce505419 100644
--- a/src/compiler/nir/nir_lower_phis_to_scalar.c
+++ b/src/compiler/nir/nir_lower_phis_to_scalar.c
@@ -46,6 +46,16 @@ struct lower_phis_to_scalar_state {
static bool
should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state);
+static bool
+is_phi_src_a_texture(nir_phi_src *src)
+{
+ /* Don't know what to do with non-ssa sources */
+ assert(src->src.is_ssa);
+
+ nir_instr *src_instr = src->src.ssa->parent_instr;
+ return src_instr->type == nir_instr_type_tex;
+}
+
static bool
is_phi_src_scalarizable(nir_phi_src *src,
struct lower_phis_to_scalar_state *state)
@@ -150,9 +160,16 @@ should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state)
*/
entry = _mesa_hash_table_insert(state->phi_table, phi, (void *)(intptr_t)1);
- bool scalarizable = true;
+ bool scalarizable = false;
nir_foreach_phi_src(src, phi) {
+ /* A texture is not scalarizable but its likely still worth copying to
+ * temps if another phi source is scalarizable. This reduces register
+ * spilling by a huge amount in the i965 driver for Deus Ex: MD.
+ */
+ if (is_phi_src_a_texture(src))
+ continue;
+
scalarizable = is_phi_src_scalarizable(src, state);
if (!scalarizable)
break;
--
2.20.1
More information about the mesa-dev
mailing list