Mesa (master): freedreno: Refactor ir3_cache shader compilation

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


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Tue Jun 23 13:19:07 2020 +0200

freedreno: Refactor ir3_cache shader compilation

Use an array, which makes it more like turnip and makes implementing the
const limits easier.

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

---

 src/gallium/drivers/freedreno/ir3/ir3_cache.c | 51 +++++++++++++++------------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cache.c b/src/gallium/drivers/freedreno/ir3/ir3_cache.c
index fdf81769f5a..0a121c41358 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cache.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cache.c
@@ -93,17 +93,29 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
 		return entry->data;
 	}
 
-	struct ir3_shader_variant *vs = ir3_shader_variant(key->vs, key->key, false, debug);
-	if (!vs)
-		return NULL;
-
-	struct ir3_shader_variant *hs = NULL, *ds = NULL;
-	if (key->hs) {
+	if (key->hs)
 		debug_assert(key->ds);
-		hs = ir3_shader_variant(key->hs, key->key, false, debug);
-		ds = ir3_shader_variant(key->ds, key->key, false, debug);
-		if (!hs || ! ds)
-			return NULL;
+
+	struct ir3_shader *shaders[MESA_SHADER_STAGES] = {
+		[MESA_SHADER_VERTEX] = key->vs,
+		[MESA_SHADER_TESS_CTRL] = key->hs,
+		[MESA_SHADER_TESS_EVAL] = key->ds,
+		[MESA_SHADER_GEOMETRY] = key->gs,
+		[MESA_SHADER_FRAGMENT] = key->fs,
+	};
+
+	struct ir3_shader_variant *variants[MESA_SHADER_STAGES];
+
+	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);
+			if (!variants[stage])
+				return NULL;
+		} else {
+			variants[stage] = NULL;
+		}
 	}
 
 	/* For tessellation, the binning shader is derived from the DS. */
@@ -115,19 +127,14 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
 	if (!bs)
 		return NULL;
 
-	struct ir3_shader_variant *gs = NULL;
-	if (key->gs) {
-		gs = ir3_shader_variant(key->gs, key->key, false, debug);
-		if (!gs)
-			return NULL;
-	}
-
-	struct ir3_shader_variant *fs = ir3_shader_variant(key->fs, key->key, false, debug);
-	if (!fs)
-		return NULL;
-
 	struct ir3_program_state *state =
-		cache->funcs->create_state(cache->data, bs, vs, hs, ds, gs, fs, &key->key);
+		cache->funcs->create_state(cache->data, bs,
+								   variants[MESA_SHADER_VERTEX],
+								   variants[MESA_SHADER_TESS_CTRL],
+								   variants[MESA_SHADER_TESS_EVAL],
+								   variants[MESA_SHADER_GEOMETRY],
+								   variants[MESA_SHADER_FRAGMENT],
+								   &key->key);
 	state->key = *key;
 
 	/* NOTE: uses copy of key in state obj, because pointer passed by caller



More information about the mesa-commit mailing list