mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
Add ir_constant_expression.cpp support for <, >, <=, >=.
This results in folding one more constant expression in CorrectParse2.frag.
This commit is contained in:
parent
62735694a1
commit
85171c2dd8
1 changed files with 66 additions and 0 deletions
|
|
@ -252,6 +252,72 @@ ir_constant_visitor::visit(ir_expression *ir)
|
|||
for (c = 0; c < ir->operands[0]->type->components(); c++)
|
||||
b[c] = op[0]->value.b[c] || op[1]->value.b[c];
|
||||
break;
|
||||
|
||||
case ir_binop_less:
|
||||
type = glsl_type::bool_type;
|
||||
switch (ir->operands[0]->type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
b[0] = op[0]->value.u[0] < op[1]->value.u[0];
|
||||
break;
|
||||
case GLSL_TYPE_INT:
|
||||
b[0] = op[0]->value.i[0] < op[1]->value.i[0];
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
b[0] = op[0]->value.f[0] < op[1]->value.f[0];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
break;
|
||||
case ir_binop_greater:
|
||||
type = glsl_type::bool_type;
|
||||
switch (ir->operands[0]->type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
b[0] = op[0]->value.u[0] > op[1]->value.u[0];
|
||||
break;
|
||||
case GLSL_TYPE_INT:
|
||||
b[0] = op[0]->value.i[0] > op[1]->value.i[0];
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
b[0] = op[0]->value.f[0] > op[1]->value.f[0];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
break;
|
||||
case ir_binop_lequal:
|
||||
type = glsl_type::bool_type;
|
||||
switch (ir->operands[0]->type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
|
||||
break;
|
||||
case GLSL_TYPE_INT:
|
||||
b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
break;
|
||||
case ir_binop_gequal:
|
||||
type = glsl_type::bool_type;
|
||||
switch (ir->operands[0]->type->base_type) {
|
||||
case GLSL_TYPE_UINT:
|
||||
b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
|
||||
break;
|
||||
case GLSL_TYPE_INT:
|
||||
b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
|
||||
break;
|
||||
case GLSL_TYPE_FLOAT:
|
||||
b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue