for (unsigned i = 0; i < 4; i++) {
swiz[i] = ir->write_mask & (1 << i) ? component++ : 0;
}
- src = nir_swizzle(&b, src, swiz, num_components, !supports_ints);
+ src = nir_swizzle(&b, src, swiz, num_components, false);
}
if (ir->condition) {
type == GLSL_TYPE_INT16;
}
+static bool
+type_is_int(glsl_base_type type)
+{
+ return type == GLSL_TYPE_UINT || type == GLSL_TYPE_INT ||
+ type == GLSL_TYPE_UINT8 || type == GLSL_TYPE_INT8 ||
+ type == GLSL_TYPE_UINT16 || type == GLSL_TYPE_INT16 ||
+ type == GLSL_TYPE_UINT64 || type == GLSL_TYPE_INT64;
+}
+
void
nir_visitor::visit(ir_expression *ir)
{
glsl_base_type types[4];
for (unsigned i = 0; i < ir->num_operands; i++)
- if (supports_ints)
+ if (supports_ints || !type_is_int(ir->operands[i]->type->base_type))
types[i] = ir->operands[i]->type->base_type;
else
types[i] = GLSL_TYPE_FLOAT;
glsl_base_type out_type;
- if (supports_ints)
+ if (supports_ints || !type_is_int(ir->type->base_type))
out_type = ir->type->base_type;
else
out_type = GLSL_TYPE_FLOAT;
switch (ir->operation) {
case ir_unop_bit_not: result = nir_inot(&b, srcs[0]); break;
case ir_unop_logic_not:
- result = supports_ints ? nir_inot(&b, srcs[0]) : nir_fnot(&b, srcs[0]);
+ result = nir_inot(&b, srcs[0]);
break;
case ir_unop_neg:
result = type_is_float(types[0]) ? nir_fneg(&b, srcs[0])
result = supports_ints ? nir_u2f32(&b, srcs[0]) : nir_fmov(&b, srcs[0]);
break;
case ir_unop_b2f:
- result = supports_ints ? nir_b2f32(&b, srcs[0]) : nir_fmov(&b, srcs[0]);
+ result = nir_b2f32(&b, srcs[0]);
break;
case ir_unop_f2i:
result = supports_ints ? nir_f2i32(&b, srcs[0]) : nir_ftrunc(&b, srcs[0]);
case ir_binop_bit_or: result = nir_ior(&b, srcs[0], srcs[1]); break;
case ir_binop_bit_xor: result = nir_ixor(&b, srcs[0], srcs[1]); break;
case ir_binop_logic_and:
- result = supports_ints ? nir_iand(&b, srcs[0], srcs[1])
- : nir_fand(&b, srcs[0], srcs[1]);
+ result = nir_iand(&b, srcs[0], srcs[1]);
break;
case ir_binop_logic_or:
- result = supports_ints ? nir_ior(&b, srcs[0], srcs[1])
- : nir_for(&b, srcs[0], srcs[1]);
+ result = nir_ior(&b, srcs[0], srcs[1]);
break;
case ir_binop_logic_xor:
- result = supports_ints ? nir_ixor(&b, srcs[0], srcs[1])
- : nir_fxor(&b, srcs[0], srcs[1]);
+ result = nir_ixor(&b, srcs[0], srcs[1]);
break;
case ir_binop_lshift: result = nir_ishl(&b, srcs[0], srcs[1]); break;
case ir_binop_rshift:
case ir_binop_carry: result = nir_uadd_carry(&b, srcs[0], srcs[1]); break;
case ir_binop_borrow: result = nir_usub_borrow(&b, srcs[0], srcs[1]); break;
case ir_binop_less:
- if (supports_ints) {
- if (type_is_float(types[0]))
- result = nir_flt(&b, srcs[0], srcs[1]);
- else if (type_is_signed(types[0]))
- result = nir_ilt(&b, srcs[0], srcs[1]);
- else
- result = nir_ult(&b, srcs[0], srcs[1]);
- } else {
- result = nir_slt(&b, srcs[0], srcs[1]);
- }
+ if (type_is_float(types[0]))
+ result = nir_flt(&b, srcs[0], srcs[1]);
+ else if (type_is_signed(types[0]))
+ result = nir_ilt(&b, srcs[0], srcs[1]);
+ else
+ result = nir_ult(&b, srcs[0], srcs[1]);
break;
case ir_binop_gequal:
- if (supports_ints) {
- if (type_is_float(types[0]))
- result = nir_fge(&b, srcs[0], srcs[1]);
- else if (type_is_signed(types[0]))
- result = nir_ige(&b, srcs[0], srcs[1]);
- else
- result = nir_uge(&b, srcs[0], srcs[1]);
- } else {
- result = nir_sge(&b, srcs[0], srcs[1]);
- }
+ if (type_is_float(types[0]))
+ result = nir_fge(&b, srcs[0], srcs[1]);
+ else if (type_is_signed(types[0]))
+ result = nir_ige(&b, srcs[0], srcs[1]);
+ else
+ result = nir_uge(&b, srcs[0], srcs[1]);
break;
case ir_binop_equal:
- if (supports_ints) {
- if (type_is_float(types[0]))
- result = nir_feq(&b, srcs[0], srcs[1]);
- else
- result = nir_ieq(&b, srcs[0], srcs[1]);
- } else {
- result = nir_seq(&b, srcs[0], srcs[1]);
- }
+ if (type_is_float(types[0]))
+ result = nir_feq(&b, srcs[0], srcs[1]);
+ else
+ result = nir_ieq(&b, srcs[0], srcs[1]);
break;
case ir_binop_nequal:
- if (supports_ints) {
- if (type_is_float(types[0]))
- result = nir_fne(&b, srcs[0], srcs[1]);
- else
- result = nir_ine(&b, srcs[0], srcs[1]);
- } else {
- result = nir_sne(&b, srcs[0], srcs[1]);
- }
+ if (type_is_float(types[0]))
+ result = nir_fne(&b, srcs[0], srcs[1]);
+ else
+ result = nir_ine(&b, srcs[0], srcs[1]);
break;
case ir_binop_all_equal:
- if (supports_ints) {
- if (type_is_float(types[0])) {
- switch (ir->operands[0]->type->vector_elements) {
- case 1: result = nir_feq(&b, srcs[0], srcs[1]); break;
- case 2: result = nir_ball_fequal2(&b, srcs[0], srcs[1]); break;
- case 3: result = nir_ball_fequal3(&b, srcs[0], srcs[1]); break;
- case 4: result = nir_ball_fequal4(&b, srcs[0], srcs[1]); break;
- default:
- unreachable("not reached");
- }
- } else {
- switch (ir->operands[0]->type->vector_elements) {
- case 1: result = nir_ieq(&b, srcs[0], srcs[1]); break;
- case 2: result = nir_ball_iequal2(&b, srcs[0], srcs[1]); break;
- case 3: result = nir_ball_iequal3(&b, srcs[0], srcs[1]); break;
- case 4: result = nir_ball_iequal4(&b, srcs[0], srcs[1]); break;
- default:
- unreachable("not reached");
- }
+ if (type_is_float(types[0])) {
+ switch (ir->operands[0]->type->vector_elements) {
+ case 1: result = nir_feq(&b, srcs[0], srcs[1]); break;
+ case 2: result = nir_ball_fequal2(&b, srcs[0], srcs[1]); break;
+ case 3: result = nir_ball_fequal3(&b, srcs[0], srcs[1]); break;
+ case 4: result = nir_ball_fequal4(&b, srcs[0], srcs[1]); break;
+ default:
+ unreachable("not reached");
}
} else {
switch (ir->operands[0]->type->vector_elements) {
- case 1: result = nir_seq(&b, srcs[0], srcs[1]); break;
- case 2: result = nir_fall_equal2(&b, srcs[0], srcs[1]); break;
- case 3: result = nir_fall_equal3(&b, srcs[0], srcs[1]); break;
- case 4: result = nir_fall_equal4(&b, srcs[0], srcs[1]); break;
+ case 1: result = nir_ieq(&b, srcs[0], srcs[1]); break;
+ case 2: result = nir_ball_iequal2(&b, srcs[0], srcs[1]); break;
+ case 3: result = nir_ball_iequal3(&b, srcs[0], srcs[1]); break;
+ case 4: result = nir_ball_iequal4(&b, srcs[0], srcs[1]); break;
default:
unreachable("not reached");
}
}
break;
case ir_binop_any_nequal:
- if (supports_ints) {
- if (type_is_float(types[0])) {
- switch (ir->operands[0]->type->vector_elements) {
- case 1: result = nir_fne(&b, srcs[0], srcs[1]); break;
- case 2: result = nir_bany_fnequal2(&b, srcs[0], srcs[1]); break;
- case 3: result = nir_bany_fnequal3(&b, srcs[0], srcs[1]); break;
- case 4: result = nir_bany_fnequal4(&b, srcs[0], srcs[1]); break;
- default:
- unreachable("not reached");
- }
- } else {
- switch (ir->operands[0]->type->vector_elements) {
- case 1: result = nir_ine(&b, srcs[0], srcs[1]); break;
- case 2: result = nir_bany_inequal2(&b, srcs[0], srcs[1]); break;
- case 3: result = nir_bany_inequal3(&b, srcs[0], srcs[1]); break;
- case 4: result = nir_bany_inequal4(&b, srcs[0], srcs[1]); break;
- default:
- unreachable("not reached");
- }
+ if (type_is_float(types[0])) {
+ switch (ir->operands[0]->type->vector_elements) {
+ case 1: result = nir_fne(&b, srcs[0], srcs[1]); break;
+ case 2: result = nir_bany_fnequal2(&b, srcs[0], srcs[1]); break;
+ case 3: result = nir_bany_fnequal3(&b, srcs[0], srcs[1]); break;
+ case 4: result = nir_bany_fnequal4(&b, srcs[0], srcs[1]); break;
+ default:
+ unreachable("not reached");
}
} else {
switch (ir->operands[0]->type->vector_elements) {
- case 1: result = nir_sne(&b, srcs[0], srcs[1]); break;
- case 2: result = nir_fany_nequal2(&b, srcs[0], srcs[1]); break;
- case 3: result = nir_fany_nequal3(&b, srcs[0], srcs[1]); break;
- case 4: result = nir_fany_nequal4(&b, srcs[0], srcs[1]); break;
+ case 1: result = nir_ine(&b, srcs[0], srcs[1]); break;
+ case 2: result = nir_bany_inequal2(&b, srcs[0], srcs[1]); break;
+ case 3: result = nir_bany_inequal3(&b, srcs[0], srcs[1]); break;
+ case 4: result = nir_bany_inequal4(&b, srcs[0], srcs[1]); break;
default:
unreachable("not reached");
}
result = nir_flrp(&b, srcs[0], srcs[1], srcs[2]);
break;
case ir_triop_csel:
- if (supports_ints)
- result = nir_bcsel(&b, srcs[0], srcs[1], srcs[2]);
- else
- result = nir_fcsel(&b, srcs[0], srcs[1], srcs[2]);
+ result = nir_bcsel(&b, srcs[0], srcs[1], srcs[2]);
break;
case ir_triop_bitfield_extract:
result = (out_type == GLSL_TYPE_INT) ?
{
unsigned swizzle[4] = { ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w };
result = nir_swizzle(&b, evaluate_rvalue(ir->val), swizzle,
- ir->type->vector_elements, !supports_ints);
+ ir->type->vector_elements, false);
}
void