summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Clark <robclark@freedesktop.org>2014-09-06 12:45:17 -0400
committerEmil Velikov <emil.l.velikov@gmail.com>2014-10-29 17:40:47 +0000
commitea955ffd4d902cda0a0ed4c4114bddbf1f38658c (patch)
tree62bb433f7ae55f2a8ef240ab08293d0d06797cba /src
parent9995edb7009f28350b7f1d4b25af412d17065703 (diff)
freedreno/ir3: add no-copy-propagate fallback step
Most of the things the new compiler still has trouble with basically amount to cp stage removing too many copies. But without the cp stage, the shaders the new compiler produces are still better (perf and correctness) than the old compiler. So a simple thing to do until I have more time to work on it is first trying falling back to new compiler without cp, before finally falling back to old compiler. Signed-off-by: Rob Clark <robclark@freedesktop.org> (cherry picked from commit fd4884e9291cd941c31e9ed7858a42bec2f1eca8)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_compiler.c6
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_compiler.h2
-rw-r--r--src/gallium/drivers/freedreno/ir3/ir3_shader.c24
3 files changed, 21 insertions, 11 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
index aa3773e9e98..affb775f75b 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c
@@ -2552,7 +2552,8 @@ compile_dump(struct ir3_compile_context *ctx)
int
ir3_compile_shader(struct ir3_shader_variant *so,
- const struct tgsi_token *tokens, struct ir3_shader_key key)
+ const struct tgsi_token *tokens, struct ir3_shader_key key,
+ bool cp)
{
struct ir3_compile_context ctx;
struct ir3_block *block;
@@ -2631,7 +2632,8 @@ ir3_compile_shader(struct ir3_shader_variant *so,
ir3_dump_instr_list(block->head);
}
- ir3_block_cp(block);
+ if (cp)
+ ir3_block_cp(block);
if (fd_mesa_debug & FD_DBG_OPTDUMP)
compile_dump(&ctx);
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.h b/src/gallium/drivers/freedreno/ir3/ir3_compiler.h
index 9b11b3d8abf..58532979af3 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.h
@@ -34,7 +34,7 @@
int ir3_compile_shader(struct ir3_shader_variant *so,
const struct tgsi_token *tokens,
- struct ir3_shader_key key);
+ struct ir3_shader_key key, bool cp);
int ir3_compile_shader_old(struct ir3_shader_variant *so,
const struct tgsi_token *tokens,
struct ir3_shader_key key);
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
index 65b11336cea..0a4dc66ab70 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c
@@ -95,6 +95,17 @@ fixup_vp_regfootprint(struct ir3_shader_variant *v)
}
}
+/* reset before attempting to compile again.. */
+static void reset_variant(struct ir3_shader_variant *v, const char *msg)
+{
+ debug_error(msg);
+ v->inputs_count = 0;
+ v->outputs_count = 0;
+ v->total_in = 0;
+ v->has_samp = false;
+ v->immediates_count = 0;
+}
+
static struct ir3_shader_variant *
create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
{
@@ -116,15 +127,12 @@ create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
}
if (!(fd_mesa_debug & FD_DBG_NOOPT)) {
- ret = ir3_compile_shader(v, tokens, key);
+ ret = ir3_compile_shader(v, tokens, key, true);
if (ret) {
- debug_error("new compiler failed, trying fallback!");
-
- v->inputs_count = 0;
- v->outputs_count = 0;
- v->total_in = 0;
- v->has_samp = false;
- v->immediates_count = 0;
+ reset_variant(v, "new compiler failed, trying without copy propagation!");
+ ret = ir3_compile_shader(v, tokens, key, false);
+ if (ret)
+ reset_variant(v, "new compiler failed, trying fallback!");
}
} else {
ret = -1; /* force fallback to old compiler */