Browse Source

glsl: Add IR builder shortcuts for a bunch of random opcodes.

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.

v2: Add fma() and rename lrp() operands to x/y/a to match the GLSL
    specification (suggested by Matt Turner).  Fix whitespace issues.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
tags/mesa-10.1-devel
Kenneth Graunke 12 years ago
parent
commit
666df56551
2 changed files with 94 additions and 0 deletions
  1. 80
    0
      src/glsl/ir_builder.cpp
  2. 14
    0
      src/glsl/ir_builder.h

+ 80
- 0
src/glsl/ir_builder.cpp View File

@@ -264,6 +264,54 @@ 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 +468,38 @@ 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 *
fma(operand a, operand b, operand c)
{
return expr(ir_triop_fma, a, b, c);
}

ir_expression *
lrp(operand x, operand y, operand a)
{
return expr(ir_triop_lrp, x, y, a);
}

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)

+ 14
- 0
src/glsl/ir_builder.h View File

@@ -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,12 @@ 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 *fma(operand a, operand b, operand c);
ir_expression *lrp(operand x, operand y, operand a);
ir_expression *bitfield_insert(operand a, operand b, operand c, operand d);

ir_swizzle *swizzle(operand a, int swizzle, int components);
/**

Loading…
Cancel
Save