Mesa (master): v3d: Use nir_lower_io_to_scalar_early to DCE unused VS input components.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Oct 30 17:58:28 UTC 2018
Module: Mesa
Branch: master
Commit: 17c81989521731af25a633622a0ded437538ab00
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=17c81989521731af25a633622a0ded437538ab00
Author: Eric Anholt <eric at anholt.net>
Date: Tue Sep 18 10:34:11 2018 -0700
v3d: Use nir_lower_io_to_scalar_early to DCE unused VS input components.
This lets us trim unused trailing components in the vertex attributes,
reducing the size of our VPM allocations.
---
src/broadcom/compiler/vir.c | 16 ++++++++++++++++
src/gallium/drivers/v3d/v3d_program.c | 5 ++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 6b55b0e03b..faad654115 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -585,6 +585,12 @@ vir_compile_init(const struct v3d_compiler *compiler,
return c;
}
+static int
+type_size_vec4(const struct glsl_type *type)
+{
+ return glsl_count_attribute_slots(type, false);
+}
+
static void
v3d_lower_nir(struct v3d_compile *c)
{
@@ -713,6 +719,16 @@ uint64_t *v3d_compile_vs(const struct v3d_compiler *compiler,
c->vs_key = key;
+ /* Split our input vars and dead code eliminate the unused
+ * components.
+ */
+ NIR_PASS_V(c->s, nir_lower_io_to_scalar_early, nir_var_shader_in);
+ v3d_optimize_nir(c->s);
+ NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in);
+ NIR_PASS_V(c->s, nir_lower_io, nir_var_shader_in,
+ type_size_vec4,
+ (nir_lower_io_options)0);
+
v3d_lower_nir(c);
if (key->clamp_color)
diff --git a/src/gallium/drivers/v3d/v3d_program.c b/src/gallium/drivers/v3d/v3d_program.c
index 1d4b0bb208..17ded7571c 100644
--- a/src/gallium/drivers/v3d/v3d_program.c
+++ b/src/gallium/drivers/v3d/v3d_program.c
@@ -210,7 +210,10 @@ v3d_shader_state_create(struct pipe_context *pctx,
so->was_tgsi = true;
}
- NIR_PASS_V(s, nir_lower_io, nir_var_all & ~nir_var_uniform,
+ nir_variable_mode lower_mode = nir_var_all & ~nir_var_uniform;
+ if (s->info.stage == MESA_SHADER_VERTEX)
+ lower_mode &= ~nir_var_shader_in;
+ NIR_PASS_V(s, nir_lower_io, lower_mode,
type_size,
(nir_lower_io_options)0);
More information about the mesa-commit
mailing list