Mesa (master): freedreno: Share constlen between different stages properly

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 26 10:04:31 UTC 2020


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Tue Jun 23 14:12:09 2020 +0200

freedreno: Share constlen between different stages properly

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5607>

---

 src/gallium/drivers/freedreno/ir3/ir3_cache.c   | 27 ++++++++++++++++++++-----
 src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 23 ++++++++++++++++++---
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cache.c b/src/gallium/drivers/freedreno/ir3/ir3_cache.c
index 0a121c41358..5f6bb20fe8b 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cache.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cache.c
@@ -105,12 +105,13 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
 	};
 
 	struct ir3_shader_variant *variants[MESA_SHADER_STAGES];
+	struct ir3_shader_key shader_key = key->key;
 
 	for (gl_shader_stage stage = MESA_SHADER_VERTEX;
 		 stage < MESA_SHADER_STAGES; stage++) {
 		if (shaders[stage]) {
 			variants[stage] =
-				ir3_shader_variant(shaders[stage], key->key, false, debug);
+				ir3_shader_variant(shaders[stage], shader_key, false, debug);
 			if (!variants[stage])
 				return NULL;
 		} else {
@@ -118,12 +119,28 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
 		}
 	}
 
+	uint32_t safe_constlens = ir3_trim_constlen(variants, key->vs->compiler);
+	shader_key.safe_constlen = true;
+
+	for (gl_shader_stage stage = MESA_SHADER_VERTEX;
+		 stage < MESA_SHADER_STAGES; stage++) {
+		if (safe_constlens & (1 << stage)) {
+			variants[stage] =
+				ir3_shader_variant(shaders[stage], shader_key, false, debug);
+			if (!variants[stage])
+				return NULL;
+		}
+	}
+
 	/* For tessellation, the binning shader is derived from the DS. */
 	struct ir3_shader_variant *bs;
-	if (key->ds)
-		bs = ir3_shader_variant(key->ds, key->key, true, debug);
-	else
-		bs = ir3_shader_variant(key->vs, key->key, true, debug);
+	if (key->ds) {
+		shader_key.safe_constlen = !!(safe_constlens & (1 << MESA_SHADER_TESS_EVAL));
+		bs = ir3_shader_variant(key->ds, shader_key, true, debug);
+	} else {
+		shader_key.safe_constlen = !!(safe_constlens & (1 << MESA_SHADER_VERTEX));
+		bs = ir3_shader_variant(key->vs, shader_key, true, debug);
+	}
 	if (!bs)
 		return NULL;
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
index cc986f3dc4e..2a6bc936a31 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
@@ -203,10 +203,27 @@ ir3_shader_create(struct ir3_compiler *compiler,
 		break;
 	}
 
-	ir3_shader_variant(shader, key, false, debug);
+	key.safe_constlen = false;
+	struct ir3_shader_variant *v = ir3_shader_variant(shader, key, false, debug);
+	if (!v)
+		return NULL;
+
+	if (v->constlen > compiler->max_const_safe) {
+		key.safe_constlen = true;
+		ir3_shader_variant(shader, key, false, debug);
+	}
+
+	if (nir->info.stage == MESA_SHADER_VERTEX) {
+		key.safe_constlen = false;
+		v = ir3_shader_variant(shader, key, true, debug);
+		if (!v)
+			return NULL;
 
-	if (nir->info.stage == MESA_SHADER_VERTEX)
-		ir3_shader_variant(shader, key, true, debug);
+		if (v->constlen > compiler->max_const_safe) {
+			key.safe_constlen = true;
+			ir3_shader_variant(shader, key, true, debug);
+		}
+	}
 
 	shader->initial_variants_done = true;
 



More information about the mesa-commit mailing list