Mesa (18.2): radeonsi: add a workaround for bitfield_extract when count is 0
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 3 12:42:51 UTC 2018
Module: Mesa
Branch: 18.2
Commit: b4c8c67f31ee6da763b100a96d837c422764f76c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4c8c67f31ee6da763b100a96d837c422764f76c
Author: Timothy Arceri <tarceri at itsqueeze.com>
Date: Sat Sep 22 12:38:11 2018 +1000
radeonsi: add a workaround for bitfield_extract when count is 0
This ports the fix from 3d41757788ac. Both LLVM 7 & 8 continue
to have this problem.
It fixes rendering issues in some menu and loading screens of
Civ VI which can be seen in the trace from bug 104602.
Note: This does not fix the black triangles on Vega for bug
104602.
Cc: mesa-stable at lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104602
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107276
---
src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c | 41 +++++++++++++++++------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
index c51d057967..7042bc306c 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
@@ -505,18 +505,37 @@ static void emit_bfe(const struct lp_build_tgsi_action *action,
struct lp_build_emit_data *emit_data)
{
struct si_shader_context *ctx = si_shader_context(bld_base);
- LLVMValueRef bfe_sm5;
- LLVMValueRef cond;
-
- bfe_sm5 = ac_build_bfe(&ctx->ac, emit_data->args[0],
- emit_data->args[1], emit_data->args[2],
- emit_data->info->opcode == TGSI_OPCODE_IBFE);
- /* Correct for GLSL semantics. */
- cond = LLVMBuildICmp(ctx->ac.builder, LLVMIntUGE, emit_data->args[2],
- LLVMConstInt(ctx->i32, 32, 0), "");
- emit_data->output[emit_data->chan] =
- LLVMBuildSelect(ctx->ac.builder, cond, emit_data->args[0], bfe_sm5, "");
+ if (HAVE_LLVM < 0x0700) {
+ LLVMValueRef bfe_sm5 =
+ ac_build_bfe(&ctx->ac, emit_data->args[0],
+ emit_data->args[1], emit_data->args[2],
+ emit_data->info->opcode == TGSI_OPCODE_IBFE);
+
+ /* Correct for GLSL semantics. */
+ LLVMValueRef cond = LLVMBuildICmp(ctx->ac.builder, LLVMIntUGE, emit_data->args[2],
+ LLVMConstInt(ctx->i32, 32, 0), "");
+ emit_data->output[emit_data->chan] =
+ LLVMBuildSelect(ctx->ac.builder, cond, emit_data->args[0], bfe_sm5, "");
+ } else {
+ /* FIXME: LLVM 7 returns incorrect result when count is 0.
+ * https://bugs.freedesktop.org/show_bug.cgi?id=107276
+ */
+ LLVMValueRef zero = ctx->i32_0;
+ LLVMValueRef bfe_sm5 =
+ ac_build_bfe(&ctx->ac, emit_data->args[0],
+ emit_data->args[1], emit_data->args[2],
+ emit_data->info->opcode == TGSI_OPCODE_IBFE);
+
+ /* Correct for GLSL semantics. */
+ LLVMValueRef cond = LLVMBuildICmp(ctx->ac.builder, LLVMIntUGE, emit_data->args[2],
+ LLVMConstInt(ctx->i32, 32, 0), "");
+ LLVMValueRef cond2 = LLVMBuildICmp(ctx->ac.builder, LLVMIntEQ, emit_data->args[2],
+ zero, "");
+ bfe_sm5 = LLVMBuildSelect(ctx->ac.builder, cond, emit_data->args[0], bfe_sm5, "");
+ emit_data->output[emit_data->chan] =
+ LLVMBuildSelect(ctx->ac.builder, cond2, zero, bfe_sm5, "");
+ }
}
/* this is ffs in C */
More information about the mesa-commit
mailing list