Will be used to implement interpolateAtOffset() and interpolateAtSample() from ARB_gpu_shader5.
Signed-off-by: Chris Forbes <[email protected]> --- src/glsl/ir.cpp | 2 ++ src/glsl/ir.h | 10 +++++++++- src/glsl/ir_builder.cpp | 6 ++++++ src/glsl/ir_builder.h | 1 + src/glsl/ir_constant_expression.cpp | 1 + src/glsl/ir_validate.cpp | 7 +++++++ src/mesa/program/ir_to_mesa.cpp | 1 + src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 + 8 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 74d59db..dcfece9 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -406,6 +406,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) case ir_binop_rshift: case ir_binop_bfm: case ir_binop_ldexp: + case ir_binop_interpolate_at_offset: this->type = op0->type; break; @@ -562,6 +563,7 @@ static const char *const operator_strs[] = { "ubo_load", "ldexp", "vector_extract", + "interpolate_at_offset", "fma", "lrp", "csel", diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 7e41008..5e9103f 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1321,9 +1321,17 @@ enum ir_expression_operation { ir_binop_vector_extract, /** + * Interpolate fs input at offset + * + * operand0 is the fs input + * operand1 is the offset from the pixel center + */ + ir_binop_interpolate_at_offset, + + /** * A sentinel marking the last of the binary operations. */ - ir_last_binop = ir_binop_vector_extract, + ir_last_binop = ir_binop_interpolate_at_offset, /** * \name Fused floating-point multiply-add, part of ARB_gpu_shader5. diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp index c532aea..09a32a3 100644 --- a/src/glsl/ir_builder.cpp +++ b/src/glsl/ir_builder.cpp @@ -502,6 +502,12 @@ interpolate_at_centroid(operand a) } ir_expression * +interpolate_at_offset(operand a, operand b) +{ + return expr(ir_binop_interpolate_at_offset, a, b); +} + +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 410e8ab..c049010 100644 --- a/src/glsl/ir_builder.h +++ b/src/glsl/ir_builder.h @@ -185,6 +185,7 @@ ir_expression *f2b(operand a); ir_expression *b2f(operand a); ir_expression *interpolate_at_centroid(operand a); +ir_expression *interpolate_at_offset(operand a, operand b); ir_expression *fma(operand a, operand b, operand c); ir_expression *lrp(operand x, operand y, operand a); diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 0efd1d5..dfffa1d 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -415,6 +415,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) case ir_binop_lshift: case ir_binop_rshift: case ir_binop_ldexp: + case ir_binop_interpolate_at_offset: case ir_binop_vector_extract: case ir_triop_csel: case ir_triop_bitfield_extract: diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 69dd18f..9e39afe 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -551,6 +551,13 @@ ir_validate::visit_leave(ir_expression *ir) && ir->operands[1]->type->is_integer()); break; + case ir_binop_interpolate_at_offset: + assert(ir->operands[0]->type == ir->type); + assert(ir->operands[0]->type->is_float()); + assert(ir->operands[1]->type->components() == 2); + assert(ir->operands[1]->type->is_float()); + break; + case ir_triop_fma: assert(ir->type->base_type == GLSL_TYPE_FLOAT); assert(ir->type == ir->operands[0]->type); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index f75c296..6fd9fb6 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1502,6 +1502,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_borrow: case ir_binop_imul_high: case ir_unop_interpolate_at_centroid: + case ir_binop_interpolate_at_offset: 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 418f27d..65e2925 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2008,6 +2008,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) case ir_binop_borrow: case ir_binop_imul_high: case ir_unop_interpolate_at_centroid: + case ir_binop_interpolate_at_offset: /* 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 [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
