Mesa (master): freedreno/ir3: move nir finalization to after cache miss

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 26 16:34:30 UTC 2020


Module: Mesa
Branch: master
Commit: 189a0fecf54139cea128731fcc6ae00d46565cd4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=189a0fecf54139cea128731fcc6ae00d46565cd4

Author: Rob Clark <robdclark at chromium.org>
Date:   Tue Jun 23 10:09:30 2020 -0700

freedreno/ir3: move nir finalization to after cache miss

In cases where every variant is a shader-cache-hit, we never need the
post-finalize round of nir opt/lowering passes.  So defer this until
the first shader-cache-miss to avoid doing pointless work.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5372>

---

 src/freedreno/ir3/ir3_shader.c | 18 +++++++++++-------
 src/freedreno/ir3/ir3_shader.h |  1 +
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c
index 0950b62f92f..0a6e268d727 100644
--- a/src/freedreno/ir3/ir3_shader.c
+++ b/src/freedreno/ir3/ir3_shader.c
@@ -248,6 +248,17 @@ create_variant(struct ir3_shader *shader, const struct ir3_shader_key *key)
 	if (ir3_disk_cache_retrieve(shader->compiler, v))
 		return v;
 
+	if (!shader->nir_finalized) {
+		ir3_nir_post_finalize(shader->compiler, shader->nir);
+
+		if (ir3_shader_debug & IR3_DBG_DISASM) {
+			printf("dump nir%d: type=%d", shader->id, shader->type);
+			nir_print_shader(shader->nir, stdout);
+		}
+
+		shader->nir_finalized = true;
+	}
+
 	if (!compile_variant(v))
 		goto fail;
 
@@ -454,13 +465,6 @@ ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir,
 
 	ir3_disk_cache_init_shader_key(compiler, shader);
 
-	ir3_nir_post_finalize(compiler, nir);
-
-	if (ir3_shader_debug & IR3_DBG_DISASM) {
-		printf("dump nir%d: type=%d", shader->id, shader->type);
-		nir_print_shader(shader->nir, stdout);
-	}
-
 	ir3_setup_used_key(shader);
 
 	return shader;
diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h
index 45a4170e683..3d5dac453d3 100644
--- a/src/freedreno/ir3/ir3_shader.h
+++ b/src/freedreno/ir3/ir3_shader.h
@@ -690,6 +690,7 @@ struct ir3_shader {
 
 	unsigned num_reserved_user_consts;
 
+	bool nir_finalized;
 	struct nir_shader *nir;
 	struct ir3_stream_output_info stream_output;
 



More information about the mesa-commit mailing list