mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-16 07:38:14 +02:00
glsl: Fix type error when lowering integer divisions
This patch fixes a bug when lowering an integer division:
x/y
to a multiplication by a reciprocal:
int(float(x)*reciprocal(float(y)))
If x was a plain int and y was an ivecN, the lowering pass
incorrectly assigned the type of the product to be float, when in fact
it should be vecN. This caused mesa to abort with an IR validation
error.
Fixes piglit tests {fs,vs}-op-div-int-ivec{2,3,4}.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit af501e2b29)
This commit is contained in:
parent
0129d5297b
commit
f732b5a999
1 changed files with 4 additions and 0 deletions
|
|
@ -166,6 +166,10 @@ lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
|
|||
else
|
||||
op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL);
|
||||
|
||||
vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
|
||||
ir->type->vector_elements,
|
||||
ir->type->matrix_columns);
|
||||
|
||||
op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
|
||||
|
||||
ir->operation = ir_unop_f2i;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue