From 1aae039ee279f8ad300919d8af0fc4691ca2f514 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 17 Aug 2009 07:51:54 +0100 Subject: llvmpipe: Implement comparison opcodes. --- src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c | 61 +++++++++++++++++++++----- 1 file changed, 51 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c index 7ef01c0451..000b7d0198 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c @@ -693,17 +693,27 @@ emit_instruction( } break; -#if 0 case TGSI_OPCODE_SLT: /* TGSI_OPCODE_SETLT */ - emit_setcc( bld, inst, cc_LessThan ); + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_LESS, src0, src1 ); + dst0 = lp_build_select( &bld->base, tmp0, bld->base.one, bld->base.zero ); + STORE( bld, *inst, 0, chan_index, dst0); + } break; case TGSI_OPCODE_SGE: /* TGSI_OPCODE_SETGE */ - emit_setcc( bld, inst, cc_NotLessThan ); + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_GEQUAL, src0, src1 ); + dst0 = lp_build_select( &bld->base, tmp0, bld->base.one, bld->base.zero ); + STORE( bld, *inst, 0, chan_index, dst0); + } break; -#endif case TGSI_OPCODE_MAD: /* TGSI_OPCODE_MADD */ @@ -940,7 +950,13 @@ emit_instruction( break; case TGSI_OPCODE_SEQ: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_EQUAL, src0, src1 ); + dst0 = lp_build_select( &bld->base, tmp0, bld->base.one, bld->base.zero ); + STORE( bld, *inst, 0, chan_index, dst0); + } break; case TGSI_OPCODE_SFL: @@ -948,7 +964,13 @@ emit_instruction( break; case TGSI_OPCODE_SGT: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_GREATER, src0, src1 ); + dst0 = lp_build_select( &bld->base, tmp0, bld->base.one, bld->base.zero ); + STORE( bld, *inst, 0, chan_index, dst0); + } break; case TGSI_OPCODE_SIN: @@ -960,11 +982,23 @@ emit_instruction( break; case TGSI_OPCODE_SLE: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_LEQUAL, src0, src1 ); + dst0 = lp_build_select( &bld->base, tmp0, bld->base.one, bld->base.zero ); + STORE( bld, *inst, 0, chan_index, dst0); + } break; case TGSI_OPCODE_SNE: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_NOTEQUAL, src0, src1 ); + dst0 = lp_build_select( &bld->base, tmp0, bld->base.one, bld->base.zero ); + STORE( bld, *inst, 0, chan_index, dst0); + } break; case TGSI_OPCODE_STR: @@ -1040,11 +1074,18 @@ emit_instruction( STORE( bld, *inst, 0, chan_index, tmp0); } break; +#endif case TGSI_OPCODE_CMP: - emit_cmp (bld, inst); + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + src0 = FETCH( bld, *inst, 0, chan_index ); + src1 = FETCH( bld, *inst, 1, chan_index ); + src2 = FETCH( bld, *inst, 2, chan_index ); + tmp0 = lp_build_cmp( &bld->base, PIPE_FUNC_LESS, src0, bld->base.zero ); + dst0 = lp_build_select( &bld->base, tmp0, src1, src2); + STORE( bld, *inst, 0, chan_index, dst0); + } break; -#endif case TGSI_OPCODE_SCS: IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) { -- cgit v1.2.3