diff options
author | Connor Abbott <[email protected]> | 2020-06-23 13:19:07 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-26 09:34:33 +0000 |
commit | d9dd989d2a5d08e465f3c7fcb427aa24ec6247d2 (patch) | |
tree | a471213a417c42d1e3660def586b3e28c4982a05 /src/gallium/drivers | |
parent | 8ad65609da345871465a8e1be8cbf7173913ede4 (diff) |
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>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_cache.c | 51 |
1 files 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 |