[Mesa-dev] [PATCH 16/21] glsl: Add IR builder shortcuts for a bunch of random opcodes.
Matt Turner
mattst88 at gmail.com
Wed Sep 4 19:11:30 PDT 2013
On Wed, Sep 4, 2013 at 3:22 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Adding new convenience emitters makes it easier to generate IR involving
> these opcodes.
>
> bitfield_insert is particularly useful, since there is no expr() for
> quadops.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/glsl/ir_builder.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
> src/glsl/ir_builder.h | 13 ++++++++++
> 2 files changed, 79 insertions(+)
>
> diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
> index e12ae3c..31a457d 100644
> --- a/src/glsl/ir_builder.cpp
> +++ b/src/glsl/ir_builder.cpp
> @@ -264,6 +264,46 @@ abs(operand a)
> return expr(ir_unop_abs, a);
> }
>
> +ir_expression *neg(operand a)
> +{
> + return expr(ir_unop_neg, a);
> +}
> +
> +ir_expression *sin(operand a)
> +{
> + return expr(ir_unop_sin, a);
> +}
> +
> +ir_expression *cos(operand a)
> +{
> + return expr(ir_unop_cos, a);
> +}
> +
> +ir_expression *exp(operand a)
> +{
> + return expr(ir_unop_exp, a);
> +}
> +
> +ir_expression *rsq(operand a)
> +{
> + return expr(ir_unop_rsq, a);
> +}
> +
> +ir_expression *sqrt(operand a)
> +{
> + return expr(ir_unop_sqrt, a);
> +}
> +
> +ir_expression *log(operand a)
> +{
> + return expr(ir_unop_log, a);
> +}
> +
> +ir_expression *sign(operand a)
> +{
> + return expr(ir_unop_sign, a);
> +}
> +
> ir_expression*
> equal(operand a, operand b)
> {
> @@ -420,6 +460,32 @@ b2i(operand a)
> return expr(ir_unop_b2i, a);
> }
>
> +ir_expression*
> +f2b(operand a)
> +{
> + return expr(ir_unop_f2b, a);
> +}
> +
> +ir_expression*
> +b2f(operand a)
> +{
> + return expr(ir_unop_b2f, a);
> +}
> +
> +ir_expression *
> +lrp(operand a, operand b, operand c)
> +{
> + return expr(ir_triop_lrp, a, b, c);
> +}
> +
> +ir_expression *
> +bitfield_insert(operand a, operand b, operand c, operand d)
> +{
> + void *mem_ctx = ralloc_parent(a.val);
> + return new(mem_ctx) ir_expression(ir_quadop_bitfield_insert,
> + a.val->type, a.val, b.val, c.val, d.val);
> +}
> +
> ir_if*
> if_tree(operand condition,
> ir_instruction *then_branch)
> diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
> index 091cf40..e4477b5 100644
> --- a/src/glsl/ir_builder.h
> +++ b/src/glsl/ir_builder.h
> @@ -140,6 +140,14 @@ ir_expression *dotlike(operand a, operand b);
> ir_expression *clamp(operand a, operand b, operand c);
> ir_expression *saturate(operand a);
> ir_expression *abs(operand a);
> +ir_expression *neg(operand a);
> +ir_expression *sin(operand a);
> +ir_expression *cos(operand a);
> +ir_expression *exp(operand a);
> +ir_expression *rsq(operand a);
> +ir_expression *sqrt(operand a);
> +ir_expression *log(operand a);
> +ir_expression *sign(operand a);
>
> ir_expression *equal(operand a, operand b);
> ir_expression *nequal(operand a, operand b);
> @@ -170,6 +178,11 @@ ir_expression *i2u(operand a);
> ir_expression *u2i(operand a);
> ir_expression *b2i(operand a);
> ir_expression *i2b(operand a);
> +ir_expression *f2b(operand a);
> +ir_expression *b2f(operand a);
> +
> +ir_expression *lrp(operand a, operand b, operand c);
Name these arguments x/y/a to match GLSL mix()?
Also, add fma() maybe?
> +ir_expression *bitfield_insert(operand a, operand b, operand c, operand d);
>
> ir_swizzle *swizzle(operand a, int swizzle, int components);
> /**
> --
> 1.8.3.4
More information about the mesa-dev
mailing list