[Mesa-dev] [PATCH 1/2] gallivm: Have a default emit function for min/max opcode

Tom Stellard tom at stellard.net
Fri Nov 30 08:24:40 PST 2012


On Thu, Nov 29, 2012 at 11:51:32PM +0100, Vincent Lejeune wrote:
> ---
>  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 31 ++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> index ff21879..070945c 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c
> @@ -743,6 +743,34 @@ umul_emit(
>                                     emit_data->args[0], emit_data->args[1]);
>  }
>  
> +/* TGSI_OPCODE_MAX */
> +static void fmax_emit(
> +   const struct lp_build_tgsi_action * action,
> +   struct lp_build_tgsi_context * bld_base,
> +   struct lp_build_emit_data * emit_data)
> +{
> +   LLVMValueRef comparison;
> +   comparison = lp_build_cmp(&bld_base->base, PIPE_FUNC_GEQUAL, emit_data->args[0],
> +                                   emit_data->args[1]);
> +   emit_data->output[emit_data->chan] = lp_build_select(&bld_base->base,
> +                                   comparison, emit_data->args[0],
> +                                   emit_data->args[1]);
> +}

What you had in the previous patch was fine, the lp_build_cmp() function may
generate SSE intrinsics.

> +
> +/* TGSI_OPCODE_MIN */
> +static void fmin_emit(
> +   const struct lp_build_tgsi_action * action,
> +   struct lp_build_tgsi_context * bld_base,
> +   struct lp_build_emit_data * emit_data)
> +{
> +  LLVMValueRef comparison;
> +  comparison = lp_build_cmp(&bld_base->base, PIPE_FUNC_GEQUAL, emit_data->args[0],
> +                                  emit_data->args[1]);
> +  emit_data->output[emit_data->chan] = lp_build_select(&bld_base->base,
> +                                  comparison, emit_data->args[1],
> +                                  emit_data->args[0]);
> +}

Same here too.

> +
>  /* TGSI_OPCODE_XPD */
>  
>  static void
> @@ -843,6 +871,9 @@ lp_set_default_actions(struct lp_build_tgsi_context * bld_base)
>     bld_base->op_actions[TGSI_OPCODE_U2F].emit = u2f_emit;
>     bld_base->op_actions[TGSI_OPCODE_UMAD].emit = umad_emit;
>     bld_base->op_actions[TGSI_OPCODE_UMUL].emit = umul_emit;
> +
> +   bld_base->op_actions[TGSI_OPCODE_MAX].emit = fmax_emit;
> +   bld_base->op_actions[TGSI_OPCODE_MIN].emit = fmin_emit;
>  }
>  
>  /* CPU Only default actions */
> -- 
> 1.8.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list