summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Abbott <cwabbott0@gmail.com>2017-06-06 16:40:26 -0700
committerConnor Abbott <cwabbott0@gmail.com>2017-08-07 16:41:54 -0700
commit33c18a66bbe7b22cc6e20cdf996bb3a99855137f (patch)
tree62b7e1323ccbf031201a0ff17ffeb82ee4acf5cc
parent1b6e3bdc323e34a6c69b7b707a5b1e0cff4fea14 (diff)
radeonsi: move the guts of ARB_shader_group_vote emission to ac
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--src/amd/common/ac_llvm_build.c30
-rw-r--r--src/amd/common/ac_llvm_build.h6
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c24
3 files changed, 39 insertions, 21 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 4a203abaef..7b024aa4b4 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -270,6 +270,36 @@ ac_build_ballot(struct ac_llvm_context *ctx,
}
LLVMValueRef
+ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value)
+{
+ LLVMValueRef active_set = ac_build_ballot(ctx, ctx->i32_1);
+ LLVMValueRef vote_set = ac_build_ballot(ctx, value);
+ return LLVMBuildICmp(ctx->builder, LLVMIntEQ, vote_set, active_set, "");
+}
+
+LLVMValueRef
+ac_build_vote_any(struct ac_llvm_context *ctx, LLVMValueRef value)
+{
+ LLVMValueRef vote_set = ac_build_ballot(ctx, value);
+ return LLVMBuildICmp(ctx->builder, LLVMIntNE, vote_set,
+ LLVMConstInt(ctx->i64, 0, 0), "");
+}
+
+LLVMValueRef
+ac_build_vote_eq(struct ac_llvm_context *ctx, LLVMValueRef value)
+{
+ LLVMValueRef active_set = ac_build_ballot(ctx, ctx->i32_1);
+ LLVMValueRef vote_set = ac_build_ballot(ctx, value);
+
+ LLVMValueRef all = LLVMBuildICmp(ctx->builder, LLVMIntEQ,
+ vote_set, active_set, "");
+ LLVMValueRef none = LLVMBuildICmp(ctx->builder, LLVMIntEQ,
+ vote_set,
+ LLVMConstInt(ctx->i64, 0, 0), "");
+ return LLVMBuildOr(ctx->builder, all, none, "");
+}
+
+LLVMValueRef
ac_build_gather_values_extended(struct ac_llvm_context *ctx,
LLVMValueRef *values,
unsigned value_count,
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 92db656d8f..13655f148e 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -81,6 +81,12 @@ void ac_build_optimization_barrier(struct ac_llvm_context *ctx,
LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value);
+LLVMValueRef ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value);
+
+LLVMValueRef ac_build_vote_any(struct ac_llvm_context *ctx, LLVMValueRef value);
+
+LLVMValueRef ac_build_vote_eq(struct ac_llvm_context *ctx, LLVMValueRef value);
+
LLVMValueRef
ac_build_gather_values_extended(struct ac_llvm_context *ctx,
LLVMValueRef *values,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index d7635bb7e5..4e8ba556ff 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3754,13 +3754,8 @@ static void vote_all_emit(
{
struct si_shader_context *ctx = si_shader_context(bld_base);
struct gallivm_state *gallivm = &ctx->gallivm;
- LLVMValueRef active_set, vote_set;
- LLVMValueRef tmp;
-
- active_set = ac_build_ballot(&ctx->ac, ctx->i32_1);
- vote_set = ac_build_ballot(&ctx->ac, emit_data->args[0]);
- tmp = LLVMBuildICmp(gallivm->builder, LLVMIntEQ, vote_set, active_set, "");
+ LLVMValueRef tmp = ac_build_vote_all(&ctx->ac, emit_data->args[0]);
emit_data->output[emit_data->chan] =
LLVMBuildSExt(gallivm->builder, tmp, ctx->i32, "");
}
@@ -3772,13 +3767,8 @@ static void vote_any_emit(
{
struct si_shader_context *ctx = si_shader_context(bld_base);
struct gallivm_state *gallivm = &ctx->gallivm;
- LLVMValueRef vote_set;
- LLVMValueRef tmp;
- vote_set = ac_build_ballot(&ctx->ac, emit_data->args[0]);
-
- tmp = LLVMBuildICmp(gallivm->builder, LLVMIntNE,
- vote_set, LLVMConstInt(ctx->i64, 0, 0), "");
+ LLVMValueRef tmp = ac_build_vote_any(&ctx->ac, emit_data->args[0]);
emit_data->output[emit_data->chan] =
LLVMBuildSExt(gallivm->builder, tmp, ctx->i32, "");
}
@@ -3790,16 +3780,8 @@ static void vote_eq_emit(
{
struct si_shader_context *ctx = si_shader_context(bld_base);
struct gallivm_state *gallivm = &ctx->gallivm;
- LLVMValueRef active_set, vote_set;
- LLVMValueRef all, none, tmp;
-
- active_set = ac_build_ballot(&ctx->ac, ctx->i32_1);
- vote_set = ac_build_ballot(&ctx->ac, emit_data->args[0]);
- all = LLVMBuildICmp(gallivm->builder, LLVMIntEQ, vote_set, active_set, "");
- none = LLVMBuildICmp(gallivm->builder, LLVMIntEQ,
- vote_set, LLVMConstInt(ctx->i64, 0, 0), "");
- tmp = LLVMBuildOr(gallivm->builder, all, none, "");
+ LLVMValueRef tmp = ac_build_vote_eq(&ctx->ac, emit_data->args[0]);
emit_data->output[emit_data->chan] =
LLVMBuildSExt(gallivm->builder, tmp, ctx->i32, "");
}