llvmpipe: implement ucmp
authorZack Rusin <zackr@vmware.com>
Thu, 4 Apr 2013 04:15:13 +0000 (21:15 -0700)
committerZack Rusin <zackr@vmware.com>
Thu, 4 Apr 2013 19:09:55 +0000 (12:09 -0700)
and add a test for it

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
src/gallium/tests/graw/fragment-shader/frag-ucmp.sh [new file with mode: 0644]

index dfe581d1a115ec774bc3216afa71648640b40554..f3ae7b6b6d8b67cf3d19c3ea1e7d011d7e995108 100644 (file)
@@ -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 (file)
index 0000000..fa4ea25
--- /dev/null
@@ -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