Will be used to implement interpolateAtCentroid() from ARB_gpu_shader5. Signed-off-by: Chris Forbes <chr...@ijw.co.nz> --- src/glsl/ir.cpp | 2 ++ src/glsl/ir.h | 9 ++++++++- src/glsl/ir_builder.cpp | 6 ++++++ src/glsl/ir_builder.h | 2 ++ src/glsl/ir_validate.cpp | 5 +++++ src/mesa/program/ir_to_mesa.cpp | 1 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + 7 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 1b49736..74d59db 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -251,6 +251,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0) case ir_unop_dFdx: case ir_unop_dFdy: case ir_unop_bitfield_reverse: + case ir_unop_interpolate_at_centroid: this->type = op0->type; break; @@ -527,6 +528,7 @@ static const char *const operator_strs[] = { "find_msb", "find_lsb", "noise", + "interpolate_at_centroid", "+", "-", "*", diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 2f06fb9..7e41008 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1193,9 +1193,16 @@ enum ir_expression_operation { ir_unop_noise, /** + * Interpolate fs input at centroid + * + * operand0 is the fs input. + */ + ir_unop_interpolate_at_centroid, + + /** * A sentinel marking the last of the unary operations. */ - ir_last_unop = ir_unop_noise, + ir_last_unop = ir_unop_interpolate_at_centroid, ir_binop_add, ir_binop_sub, diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp index 6c49734..c532aea 100644 --- a/src/glsl/ir_builder.cpp +++ b/src/glsl/ir_builder.cpp @@ -496,6 +496,12 @@ b2f(operand a) } ir_expression * +interpolate_at_centroid(operand a) +{ + return expr(ir_unop_interpolate_at_centroid, a); +} + +ir_expression * fma(operand a, operand b, operand c) { return expr(ir_triop_fma, a, b, c); diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h index 1f07788..410e8ab 100644 --- a/src/glsl/ir_builder.h +++ b/src/glsl/ir_builder.h @@ -184,6 +184,8 @@ ir_expression *i2b(operand a); ir_expression *f2b(operand a); ir_expression *b2f(operand a); +ir_expression *interpolate_at_centroid(operand a); + ir_expression *fma(operand a, operand b, operand c); ir_expression *lrp(operand x, operand y, operand a); ir_expression *csel(operand a, operand b, operand c); diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 13e41a0..69dd18f 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -410,6 +410,11 @@ ir_validate::visit_leave(ir_expression *ir) /* XXX what can we assert here? */ break; + case ir_unop_interpolate_at_centroid: + assert(ir->operands[0]->type == ir->type); + assert(ir->operands[0]->type->is_float()); + break; + case ir_binop_add: case ir_binop_sub: case ir_binop_mul: diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index c833a12..f75c296 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1501,6 +1501,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_carry: case ir_binop_borrow: case ir_binop_imul_high: + case ir_unop_interpolate_at_centroid: assert(!"not supported"); break; diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 0eaf746..418f27d 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2007,6 +2007,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) case ir_binop_carry: case ir_binop_borrow: case ir_binop_imul_high: + case ir_unop_interpolate_at_centroid: /* This operation is not supported, or should have already been handled. */ assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()"); -- 1.8.4.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev