From: Dave Airlie <airl...@redhat.com> This is what it looks like, seems to work fine.
Signed-off-by: Dave Airlie <airl...@redhat.com> --- src/glsl/ir.cpp | 4 +++- src/glsl/ir.h | 1 + src/glsl/ir_builder.cpp | 6 ++++++ src/glsl/ir_builder.h | 1 + src/glsl/ir_validate.cpp | 10 ++++++---- src/glsl/lower_subroutine.cpp | 4 ++-- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 +++ 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 45efed9..2fbc631 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -260,6 +260,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0) case ir_unop_bit_count: case ir_unop_find_msb: case ir_unop_find_lsb: + case ir_unop_subroutine_to_int: this->type = glsl_type::get_instance(GLSL_TYPE_INT, op0->type->vector_elements, 1); break; @@ -411,7 +412,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) case ir_binop_gequal: case ir_binop_less: case ir_binop_greater: - assert(op0->type->is_subroutine() || op0->type == op1->type); + assert(op0->type == op1->type); this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, op0->type->vector_elements, 1); break; @@ -568,6 +569,7 @@ static const char *const operator_strs[] = { "frexp_sig", "frexp_exp", "noise", + "subroutine_to_int", "interpolate_at_centroid", "+", "-", diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 106c7fb..cb4c594 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1395,6 +1395,7 @@ enum ir_expression_operation { ir_unop_noise, + ir_unop_subroutine_to_int, /** * Interpolate fs input at centroid * diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp index e44b05c..cd03859 100644 --- a/src/glsl/ir_builder.cpp +++ b/src/glsl/ir_builder.cpp @@ -338,6 +338,12 @@ sign(operand a) return expr(ir_unop_sign, a); } +ir_expression * +subr_to_int(operand a) +{ + return expr(ir_unop_subroutine_to_int, a); +} + ir_expression* equal(operand a, operand b) { diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h index 8702658..f76453f 100644 --- a/src/glsl/ir_builder.h +++ b/src/glsl/ir_builder.h @@ -153,6 +153,7 @@ ir_expression *sqrt(operand a); ir_expression *log(operand a); ir_expression *sign(operand a); +ir_expression *subr_to_int(operand a); ir_expression *equal(operand a, operand b); ir_expression *nequal(operand a, operand b); ir_expression *less(operand a, operand b); diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index ec288d4..49f4f70 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -447,6 +447,10 @@ ir_validate::visit_leave(ir_expression *ir) ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); assert(ir->type->base_type == GLSL_TYPE_INT); break; + case ir_unop_subroutine_to_int: + assert(ir->operands[0]->type->base_type == GLSL_TYPE_SUBROUTINE); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; case ir_binop_add: case ir_binop_sub: case ir_binop_mul: @@ -494,11 +498,9 @@ ir_validate::visit_leave(ir_expression *ir) * vector type of the same size. */ assert(ir->type->base_type == GLSL_TYPE_BOOL); - assert(ir->operands[0]->type->is_subroutine() - || ir->operands[0]->type == ir->operands[1]->type); + assert(ir->operands[0]->type == ir->operands[1]->type); assert(ir->operands[0]->type->is_vector() - || ir->operands[0]->type->is_scalar() - || ir->operands[0]->type->is_subroutine()); + || ir->operands[0]->type->is_scalar()); assert(ir->operands[0]->type->vector_elements == ir->type->vector_elements); break; diff --git a/src/glsl/lower_subroutine.cpp b/src/glsl/lower_subroutine.cpp index 8480bb9..e5635a2 100644 --- a/src/glsl/lower_subroutine.cpp +++ b/src/glsl/lower_subroutine.cpp @@ -94,9 +94,9 @@ lower_subroutine_visitor::visit_leave(ir_call *ir) ir_call *new_call = new(mem_ctx) ir_call(sub_sig, return_deref, &ir->actual_parameters); if (!last_branch) - last_branch = if_tree(equal(var, lc), new_call); + last_branch = if_tree(equal(subr_to_int(var), lc), new_call); else - last_branch = if_tree(equal(var, lc), new_call, last_branch); + last_branch = if_tree(equal(subr_to_int(var), lc), new_call, last_branch); if (s > 0) return_deref = return_deref->clone(mem_ctx, NULL); diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 31757dc..4b2e682 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1486,6 +1486,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) result_src = op[0]; } break; + case ir_unop_subroutine_to_int: + emit(ir, TGSI_OPCODE_MOV, result_dst, op[0]); + break; case ir_unop_abs: emit(ir, TGSI_OPCODE_ABS, result_dst, op[0]); break; -- 2.1.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev