summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2016-05-17 12:46:27 -0700
committerEric Anholt <[email protected]>2016-05-17 18:07:39 -0700
commit474e2bbcc12b1f7d959c55a1d730ad54ecef98f4 (patch)
tree7ebeb619dc7a887e1cc77f0e10daafbfd59a3abd /src/gallium/drivers
parent734fe41092e8ad87a9bfaac24c3603d2bb6df1b2 (diff)
vc4: Move tgsi_to_nir to precompile time.
Now we have an immutable nir shader in our shader's CSO that we can clone and lower/optimize.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 36ad3875e7e..90c4b2d9014 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -1788,16 +1788,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
break;
}
- const struct tgsi_token *tokens = key->shader_state->base.tokens;
-
- if (vc4_debug & VC4_DEBUG_TGSI) {
- fprintf(stderr, "%s prog %d/%d TGSI:\n",
- qir_get_stage_name(c->stage),
- c->program_id, c->variant_id);
- tgsi_dump(tokens, 0);
- }
-
- c->s = tgsi_to_nir(tokens, &nir_options);
+ c->s = nir_shader_clone(c, key->shader_state->base.ir.nir);
NIR_PASS_V(c->s, nir_opt_global_to_local);
NIR_PASS_V(c->s, nir_convert_to_ssa);
@@ -1943,9 +1934,21 @@ vc4_shader_state_create(struct pipe_context *pctx,
if (!so)
return NULL;
- so->base.tokens = tgsi_dup_tokens(cso->tokens);
so->program_id = vc4->next_uncompiled_program_id++;
+ nir_shader *s = tgsi_to_nir(cso->tokens, &nir_options);
+
+ if (vc4_debug & VC4_DEBUG_TGSI) {
+ fprintf(stderr, "%s prog %d TGSI:\n",
+ gl_shader_stage_name(s->stage),
+ so->program_id);
+ tgsi_dump(cso->tokens, 0);
+ fprintf(stderr, "\n");
+ }
+
+ so->base.type = PIPE_SHADER_IR_NIR;
+ so->base.ir.nir = s;
+
return so;
}
@@ -2293,7 +2296,7 @@ vc4_shader_state_delete(struct pipe_context *pctx, void *hwcso)
hash_table_foreach(vc4->vs_cache, entry)
delete_from_cache_if_matches(vc4->vs_cache, entry, so);
- free((void *)so->base.tokens);
+ ralloc_free(so->base.ir.nir);
free(so);
}