From da0083f1237cb89bc818be99dd0717b7e76b6248 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 4 Oct 2017 15:37:30 +0200 Subject: [PATCH] radeonsi: use postponed KILL only when derivatives are used MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/radeonsi/si_shader.c | 3 +-- src/gallium/drivers/radeonsi/si_shader.h | 1 + src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c | 2 +- src/gallium/drivers/radeonsi/si_state_shaders.c | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 8abacac8c8d..c3430487307 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -5846,8 +5846,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx, } } - if (ctx->type == PIPE_SHADER_FRAGMENT && sel->info.uses_kill && - ctx->screen->b.debug_flags & DBG(FS_CORRECT_DERIVS_AFTER_KILL)) { + if (sel->force_correct_derivs_after_kill) { ctx->postponed_kill = lp_build_alloca_undef(&ctx->gallivm, ctx->i1, ""); /* true = don't kill. */ LLVMBuildStore(ctx->ac.builder, LLVMConstInt(ctx->i1, 1, 0), diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index ebe956e709e..78a2ee14c13 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -344,6 +344,7 @@ struct si_shader_selector { /* PIPE_SHADER_[VERTEX|FRAGMENT|...] */ unsigned type; bool vs_needs_prolog; + bool force_correct_derivs_after_kill; unsigned pa_cl_vs_out_cntl; ubyte clipdist_mask; ubyte culldist_mask; diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c index ad7a42f7b84..283a889d847 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c @@ -68,7 +68,7 @@ static void kil_emit(const struct lp_build_tgsi_action *action, visible = LLVMConstInt(ctx->i1, false, 0); } - if (ctx->postponed_kill) { + if (ctx->shader->selector->force_correct_derivs_after_kill) { LLVMValueRef mask = LLVMBuildLoad(builder, ctx->postponed_kill, ""); mask = LLVMBuildAnd(builder, mask, visible, ""); LLVMBuildStore(builder, mask, ctx->postponed_kill); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 9340328a72a..af7f6ecfd60 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -2052,6 +2052,12 @@ static void *si_create_shader_selector(struct pipe_context *ctx, sel->info.num_inputs && !sel->info.properties[TGSI_PROPERTY_VS_BLIT_SGPRS]; + sel->force_correct_derivs_after_kill = + sel->type == PIPE_SHADER_FRAGMENT && + sel->info.uses_derivatives && + sel->info.uses_kill && + sctx->screen->b.debug_flags & DBG(FS_CORRECT_DERIVS_AFTER_KILL); + /* Set which opcode uses which (i,j) pair. */ if (sel->info.uses_persp_opcode_interp_centroid) sel->info.uses_persp_centroid = true; -- 2.30.2