From: Zack Rusin Date: Thu, 4 Apr 2013 04:15:13 +0000 (-0700) Subject: llvmpipe: implement ucmp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be9a42e980d9555f4f4c6c4a248dc269766085d9;p=mesa.git llvmpipe: implement ucmp and add a test for it Signed-off-by: Zack Rusin Reviewed-by: José Fonseca --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c index dfe581d1a11..f3ae7b6b6d8 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 00000000000..fa4ea25d967 --- /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