radeonsi: move the guts of ARB_shader_group_vote emission to ac
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 6 Jun 2017 23:40:26 +0000 (16:40 -0700)
committerDave Airlie <airlied@redhat.com>
Fri, 8 Sep 2017 03:12:49 +0000 (04:12 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_shader.c

index ab93aa25d242c35f152be067d1eccaafb7de69c2..a765c0d7500392a138a18a1f056d4fc05763b4ff 100644 (file)
@@ -269,6 +269,36 @@ ac_build_ballot(struct ac_llvm_context *ctx,
                                  AC_FUNC_ATTR_CONVERGENT);
 }
 
+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,
index 8369e59f28cbe3128c0b71b698c99dcb610c0e6b..323fd3a1fba64115fc575107914c256694523bef 100644 (file)
@@ -80,6 +80,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,
index ffc0d8d9b1b776e6d7ff07ac2efcd593a465fe3f..e7888e6012b6d6f0a2ed3724cbc14d562dd948d9 100644 (file)
@@ -3821,13 +3821,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, "");
 }
@@ -3839,13 +3834,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, "");
 }
@@ -3857,16 +3847,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, "");
 }