diff options
author | Christian Gmeiner <[email protected]> | 2017-03-19 16:32:40 +0100 |
---|---|---|
committer | Christian Gmeiner <[email protected]> | 2017-04-05 19:58:07 +0200 |
commit | 9da54fdcb5b591a7d6c96871e92f8b183c0a5130 (patch) | |
tree | 0abb110cb69f3a9bed76a647ced1699877454c3b /src/gallium/drivers/etnaviv/etnaviv_compiler.c | |
parent | ffd47623102a7c873684c5024d87747d280d3d5d (diff) |
etnaviv: pass a preallocated variant to compiler
In the long run the compiler needs to know the specifc variant
'key' in order to compile appropriate assembly. With this commit
the variant knows its shader and we are able pass the preallocated
variant into etna_compile_shader(..). This saves us from passing
extra ptrs everywhere.
Signed-off-by: Christian Gmeiner <[email protected]>
Reviewed-by: Lucas Stach <[email protected]>
Diffstat (limited to 'src/gallium/drivers/etnaviv/etnaviv_compiler.c')
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_compiler.c | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c index be3838d777d..7552a8f9d23 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c @@ -54,6 +54,7 @@ #include "etnaviv_context.h" #include "etnaviv_debug.h" #include "etnaviv_disasm.h" +#include "etnaviv_shader.h" #include "etnaviv_uniforms.h" #include "etnaviv_util.h" @@ -2253,15 +2254,18 @@ copy_uniform_state_to_shader(struct etna_compile *c, struct etna_shader_variant etna_set_shader_uniforms_dirty_flags(sobj); } -struct etna_shader_variant * -etna_compile_shader(const struct etna_specs *specs, - const struct tgsi_token *tokens) +bool +etna_compile_shader(struct etna_shader_variant *v) { /* Create scratch space that may be too large to fit on stack */ bool ret; struct etna_compile *c; - struct etna_shader_variant *shader; + + if (unlikely(!v)) + return false; + + const struct etna_specs *specs = v->shader->specs; struct tgsi_lowering_config lconfig = { .lower_SCS = specs->has_sin_cos_sqrt, @@ -2278,11 +2282,9 @@ etna_compile_shader(const struct etna_specs *specs, c = CALLOC_STRUCT(etna_compile); if (!c) - return NULL; + return false; - shader = CALLOC_STRUCT(etna_shader_variant); - if (!shader) - goto out; + const struct tgsi_token *tokens = v->shader->tokens; c->specs = specs; c->tokens = tgsi_transform_lowering(&lconfig, tokens, &c->info); @@ -2412,30 +2414,27 @@ etna_compile_shader(const struct etna_specs *specs, etna_compile_fill_in_labels(c); ret = etna_compile_check_limits(c); - if (!ret) { - FREE(shader); - shader = NULL; + if (!ret) goto out; - } /* fill in output structure */ - shader->processor = c->info.processor; - shader->code_size = c->inst_ptr * 4; - shader->code = mem_dup(c->code, c->inst_ptr * 16); - shader->num_loops = c->num_loops; - shader->num_temps = c->next_free_native; - shader->vs_pos_out_reg = -1; - shader->vs_pointsize_out_reg = -1; - shader->ps_color_out_reg = -1; - shader->ps_depth_out_reg = -1; - copy_uniform_state_to_shader(c, shader); + v->processor = c->info.processor; + v->code_size = c->inst_ptr * 4; + v->code = mem_dup(c->code, c->inst_ptr * 16); + v->num_loops = c->num_loops; + v->num_temps = c->next_free_native; + v->vs_pos_out_reg = -1; + v->vs_pointsize_out_reg = -1; + v->ps_color_out_reg = -1; + v->ps_depth_out_reg = -1; + copy_uniform_state_to_shader(c, v); if (c->info.processor == PIPE_SHADER_VERTEX) { - fill_in_vs_inputs(shader, c); - fill_in_vs_outputs(shader, c); + fill_in_vs_inputs(v, c); + fill_in_vs_outputs(v, c); } else if (c->info.processor == PIPE_SHADER_FRAGMENT) { - fill_in_ps_inputs(shader, c); - fill_in_ps_outputs(shader, c); + fill_in_ps_inputs(v, c); + fill_in_ps_outputs(v, c); } out: @@ -2445,7 +2444,7 @@ out: FREE(c->labels); FREE(c); - return shader; + return ret; } extern const char *tgsi_swizzle_names[]; |