[Mesa-dev] [PATCH] llvmpipe: implement ucmp
Zack Rusin
zackr at vmware.com
Wed Apr 3 21:19:44 PDT 2013
and add a test for it
Signed-off-by: Zack Rusin <zackr at vmware.com>
---
src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 21 ++++++++++++++++++++
.../tests/graw/fragment-shader/frag-ucmp.sh | 11 ++++++++++
2 files changed, 32 insertions(+)
create mode 100644 src/gallium/tests/graw/fragment-shader/frag-ucmp.sh
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
index dfe581d..f3ae7b6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
@@ -986,6 +986,26 @@ cmp_emit_cpu(
cond, emit_data->args[1], emit_data->args[2]);
}
+/* TGSI_OPCODE_UCMP (CPU Only) */
+static void
+ucmp_emit_cpu(
+ const struct lp_build_tgsi_action * action,
+ struct lp_build_tgsi_context * bld_base,
+ struct lp_build_emit_data * emit_data)
+{
+ LLVMBuilderRef builder = bld_base->base.gallivm->builder;
+ struct lp_build_context *uint_bld = &bld_base->uint_bld;
+ LLVMValueRef unsigned_cond =
+ LLVMBuildBitCast(builder, emit_data->args[0], uint_bld->vec_type, "");
+ LLVMValueRef cond = lp_build_cmp(uint_bld, PIPE_FUNC_NOTEQUAL,
+ unsigned_cond,
+ uint_bld->zero);
+ emit_data->output[emit_data->chan] =
+ lp_build_select(&bld_base->base,
+ cond, emit_data->args[1], emit_data->args[2]);
+}
+
+
/* TGSI_OPCODE_CND (CPU Only) */
static void
cnd_emit_cpu(
@@ -1701,6 +1721,7 @@ lp_set_default_actions_cpu(
bld_base->sqrt_action.emit = sqrt_emit_cpu;
bld_base->op_actions[TGSI_OPCODE_UADD].emit = uadd_emit_cpu;
+ bld_base->op_actions[TGSI_OPCODE_UCMP].emit = ucmp_emit_cpu;
bld_base->op_actions[TGSI_OPCODE_UDIV].emit = udiv_emit_cpu;
bld_base->op_actions[TGSI_OPCODE_UMAX].emit = umax_emit_cpu;
bld_base->op_actions[TGSI_OPCODE_UMIN].emit = umin_emit_cpu;
diff --git a/src/gallium/tests/graw/fragment-shader/frag-ucmp.sh b/src/gallium/tests/graw/fragment-shader/frag-ucmp.sh
new file mode 100644
index 0000000..fa4ea25
--- /dev/null
+++ b/src/gallium/tests/graw/fragment-shader/frag-ucmp.sh
@@ -0,0 +1,11 @@
+FRAG
+DCL IN[0], COLOR, LINEAR
+DCL OUT[0], COLOR
+DCL TEMP[0]
+IMM[0] FLT32 { 10.0000, 1.0000, 0.0000, 0.0000}
+IMM[1] UINT32 {1, 0, 0, 0}
+0: MUL TEMP[0].x, IN[0].xxxx, IMM[0].xxxx
+1: F2U TEMP[0].x, TEMP[0].xxxx
+2: AND TEMP[0].x, TEMP[0].xxxx, IMM[1].xxxx
+3: UCMP OUT[0], TEMP[0].xxxx, IMM[0].yzzz, IMM[0].yyyz
+4: END
--
1.7.10.4
More information about the mesa-dev
mailing list