summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2020-12-17 12:39:14 +0100
committerMarge Bot <eric+marge@anholt.net>2021-02-23 14:55:34 +0000
commitdba692c6187d2de284bb909f9da7fee483b064ff (patch)
tree6b6aba435d152a0d5950b8e55f46a4736677b2cc
parent1837135f7ca7ab80df215c4b1364c817fb8c2e84 (diff)
etnaviv: use nir_lower_uniforms_to_ubo(..)
This removes our local copy and fixes the following nir validation problem: error: nir_intrinsic_range(instr) != 0 (../src/compiler/nir/nir_validate.c:646) No piglit or deqp regression seen. shader-db results for GC3000: instructions helped: shaders/deqp_gles2/23470.shader_test VERT: 328 -> 316 (-3.66%) instructions helped: shaders/deqp_gles2/23473.shader_test FRAG: 328 -> 316 (-3.66%) instructions helped: shaders/glamor/88.shader_test FRAG: 472 -> 452 (-4.24%) instructions helped: shaders/chromeos/36.shader_test VERT: 60 -> 56 (-6.67%) instructions helped: shaders/chromeos/24.shader_test VERT: 60 -> 56 (-6.67%) instructions helped: shaders/chromeos/18.shader_test VERT: 60 -> 56 (-6.67%) instructions helped: shaders/chromeos/45.shader_test VERT: 60 -> 56 (-6.67%) instructions helped: shaders/deqp_gles2/23494.shader_test VERT: 176 -> 164 (-6.82%) instructions helped: shaders/deqp_gles2/23497.shader_test FRAG: 176 -> 164 (-6.82%) instructions helped: shaders/glamor/82.shader_test FRAG: 280 -> 260 (-7.14%) instructions helped: shaders/chromeos/21.shader_test VERT: 56 -> 52 (-7.14%) instructions helped: shaders/chromeos/15.shader_test VERT: 56 -> 52 (-7.14%) instructions helped: shaders/tesseract/268.shader_test VERT: 152 -> 136 (-10.53%) instructions helped: shaders/tesseract/270.shader_test VERT: 184 -> 164 (-10.87%) instructions helped: shaders/tesseract/272.shader_test VERT: 216 -> 192 (-11.11%) instructions helped: shaders/tesseract/266.shader_test VERT: 88 -> 76 (-13.64%) instructions helped: shaders/deqp_gles2/23488.shader_test VERT: 112 -> 96 (-14.29%) instructions helped: shaders/deqp_gles2/23491.shader_test FRAG: 112 -> 96 (-14.29%) instructions helped: shaders/chromeos/102.shader_test VERT: 168 -> 144 (-14.29%) instructions helped: shaders/deqp_gles2/23449.shader_test FRAG: 64 -> 52 (-18.75%) instructions helped: shaders/deqp_gles2/23446.shader_test VERT: 64 -> 52 (-18.75%) instructions helped: shaders/deqp_gles2/23461.shader_test FRAG: 124 -> 100 (-19.35%) instructions helped: shaders/deqp_gles2/23458.shader_test VERT: 124 -> 100 (-19.35%) instructions helped: shaders/chromeos/39.shader_test VERT: 124 -> 100 (-19.35%) temps helped: shaders/chromeos/102.shader_test VERT: 6 -> 5 (-16.67%) temps helped: shaders/deqp_gles2/23470.shader_test VERT: 5 -> 4 (-20.00%) temps helped: shaders/deqp_gles2/23473.shader_test FRAG: 5 -> 4 (-20.00%) temps HURT: shaders/tesseract/272.shader_test VERT: 6 -> 7 (16.67%) immediates helped: shaders/deqp_gles2/23470.shader_test VERT: 24 -> 20 (-16.67%) immediates helped: shaders/deqp_gles2/23473.shader_test FRAG: 24 -> 20 (-16.67%) immediates helped: shaders/chromeos/102.shader_test VERT: 8 -> 4 (-50.00%) immediates helped: shaders/chromeos/39.shader_test VERT: 8 -> 4 (-50.00%) immediates HURT: shaders/glamor/88.shader_test FRAG: 32 -> 36 (12.50%) immediates HURT: shaders/deqp_gles2/23494.shader_test VERT: 4 -> 8 (100.00%) immediates HURT: shaders/deqp_gles2/23497.shader_test FRAG: 4 -> 8 (100.00%) total instructions in shared programs: 1123728 -> 1123392 (-0.03%) instructions in affected programs: 3644 -> 3308 (-9.22%) helped: 24 HURT: 0 helped stats (abs) min: 4 max: 24 x̄: 14.00 x̃: 12 helped stats (rel) min: 3.66% max: 19.35% x̄: 10.74% x̃: 8.83% 95% mean confidence interval for instructions value: -17.11 -10.89 95% mean confidence interval for instructions %-change: -13.03% -8.45% Instructions are helped. total temps in shared programs: 86978 -> 86976 (<.01%) temps in affected programs: 22 -> 20 (-9.09%) helped: 3 HURT: 1 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 16.67% max: 20.00% x̄: 18.89% x̃: 20.00% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 16.67% max: 16.67% x̄: 16.67% x̃: 16.67% 95% mean confidence interval for temps value: -2.09 1.09 95% mean confidence interval for temps %-change: -38.40% 18.40% Inconclusive result (value mean confidence interval includes 0). total immediates in shared programs: 141464 -> 141460 (<.01%) immediates in affected programs: 104 -> 100 (-3.85%) helped: 4 HURT: 3 helped stats (abs) min: 4 max: 4 x̄: 4.00 x̃: 4 helped stats (rel) min: 16.67% max: 50.00% x̄: 33.33% x̃: 33.33% HURT stats (abs) min: 4 max: 4 x̄: 4.00 x̃: 4 HURT stats (rel) min: 12.50% max: 100.00% x̄: 70.83% x̃: 100.00% 95% mean confidence interval for immediates value: -4.53 3.38 95% mean confidence interval for immediates %-change: -48.17% 70.79% Inconclusive result (value mean confidence interval includes 0). Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9039>
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c4
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_nir.c33
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_screen.c1
3 files changed, 5 insertions, 33 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
index b80f48d9738..97f42553ebd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c
@@ -1107,6 +1107,10 @@ etna_compile_shader_nir(struct etna_shader_variant *v)
etna_optimize_loop(s);
+ /* TODO: remove this extra run if nir_opt_peephole_select is able to handle ubo's. */
+ if (OPT(s, etna_nir_lower_ubo_to_uniform))
+ etna_optimize_loop(s);
+
NIR_PASS_V(s, etna_lower_io, v);
if (v->shader->specs->vs_need_z_div)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 9c650c45147..bbb02467cf0 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -77,39 +77,6 @@ etna_lower_io(nir_shader *shader, struct etna_shader_variant *v)
alu->src[0].swizzle[2] = 0;
nir_instr_rewrite_src(instr, &intr->src[1], nir_src_for_ssa(ssa));
} break;
- case nir_intrinsic_load_uniform: {
- /* convert indirect load_uniform to load_ubo when possible
- * this is required on HALTI5+ because address register is not implemented
- * address register loads also arent done optimally
- */
- if (v->shader->specs->halti < 2 || nir_src_is_const(intr->src[0]))
- break;
-
- nir_intrinsic_instr *load_ubo =
- nir_intrinsic_instr_create(b.shader, nir_intrinsic_load_ubo);
- load_ubo->num_components = intr->num_components;
- nir_intrinsic_set_align(load_ubo, intr->dest.ssa.bit_size / 8, 0);
- nir_ssa_dest_init(&load_ubo->instr, &load_ubo->dest,
- load_ubo->num_components, 32, NULL);
-
- b.cursor = nir_before_instr(instr);
- load_ubo->src[0] = nir_src_for_ssa(nir_imm_int(&b, 0));
- load_ubo->src[1] = nir_src_for_ssa(nir_iadd(&b,
- nir_imul(&b, intr->src[0].ssa, nir_imm_int(&b, 16)),
- nir_imm_int(&b, nir_intrinsic_base(intr) * 16)));
- nir_builder_instr_insert(&b, &load_ubo->instr);
- nir_ssa_def_rewrite_uses(&intr->dest.ssa,
- nir_src_for_ssa(&load_ubo->dest.ssa));
- nir_instr_remove(&intr->instr);
- } break;
- case nir_intrinsic_load_ubo: {
- nir_const_value *idx = nir_src_as_const_value(intr->src[0]);
- assert(idx);
- /* offset index by 1, index 0 is used for converted load_uniform */
- b.cursor = nir_before_instr(instr);
- nir_instr_rewrite_src(instr, &intr->src[0],
- nir_src_for_ssa(nir_imm_int(&b, idx[0].u32 + 1)));
- } break;
case nir_intrinsic_load_vertex_id:
case nir_intrinsic_load_instance_id:
/* detect use of vertex_id/instance_id */
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index d54b0cdb274..e6a71c070d7 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -1050,6 +1050,7 @@ etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
.lower_fceil = !screen->specs.has_sign_floor_ceil,
.lower_fsqrt = !screen->specs.has_sin_cos_sqrt,
.lower_sincos = !screen->specs.has_sin_cos_sqrt,
+ .lower_uniforms_to_ubo = screen->specs.halti >= 2,
};
/* apply debug options that disable individual features */