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. */
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