[PATCH 03/21] etnaviv: compiler: extract compile shader from tgsi

Philipp Zabel p.zabel at pengutronix.de
Tue Jun 5 14:38:27 UTC 2018


From: Michael Tretter <m.tretter at pengutronix.de>

Prepare for compilation from NIR. etna_compile_shader will call either
etna_compile_shader_tgsi or etna_compile_shader_nir, depending on
whether the input is TGSI or NIR.

Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
 .../drivers/etnaviv/etnaviv_compiler.c        | 46 +++++++++++--------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index ded5154c6f96..4caf0504d24b 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2287,17 +2287,8 @@ copy_uniform_state_to_shader(struct etna_compile *c, struct etna_shader_variant
    etna_set_shader_uniforms_dirty_flags(sobj);
 }
 
-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;
-
-   if (unlikely(!v))
-      return false;
-
+static void
+etna_compile_shader_tgsi(struct etna_compile *c, struct etna_shader_variant *v) {
    const struct etna_specs *specs = v->shader->specs;
 
    struct tgsi_lowering_config lconfig = {
@@ -2310,16 +2301,8 @@ etna_compile_shader(struct etna_shader_variant *v)
       .lower_TRUNC = true,
    };
 
-   c = CALLOC_STRUCT(etna_compile);
-   if (!c)
-      return false;
-
-   memset(&c->lbl_usage, -1, sizeof(c->lbl_usage));
-
    const struct tgsi_token *tokens = v->shader->tokens;
 
-   c->specs = specs;
-   c->key = &v->key;
    c->tokens = tgsi_transform_lowering(&lconfig, tokens, &c->info);
    c->free_tokens = !!c->tokens;
    if (!c->tokens) {
@@ -2445,6 +2428,31 @@ etna_compile_shader(struct etna_shader_variant *v)
    etna_compile_add_z_div_if_needed(c);
    etna_compile_frag_rb_swap(c);
    etna_compile_add_nop_if_needed(c);
+}
+
+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;
+
+   if (unlikely(!v))
+      return false;
+
+   const struct etna_specs *specs = v->shader->specs;
+
+   c = CALLOC_STRUCT(etna_compile);
+   if (!c)
+      return false;
+
+   memset(&c->lbl_usage, -1, sizeof(c->lbl_usage));
+
+   c->specs = specs;
+   c->key = &v->key;
+
+   etna_compile_shader_tgsi(c, v);
 
    ret = etna_compile_check_limits(c);
    if (!ret)
-- 
2.17.1



More information about the etnaviv mailing list