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

Submitted by Philipp Zabel on June 5, 2018, 2:38 p.m.

Details

Message ID 20180605143845.2708-4-p.zabel@pengutronix.de
State New
Headers show
Series "Towards NIR support for etnaviv" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Philipp Zabel June 5, 2018, 2:38 p.m.
From: Michael Tretter <m.tretter@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@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 .../drivers/etnaviv/etnaviv_compiler.c        | 46 +++++++++++--------
 1 file changed, 27 insertions(+), 19 deletions(-)

Patch hide | download patch | download mbox

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)