glsl: fix glsl to nir support for lower precision builtins

When we switch to the full nir based glsl linker in an upcomming merge
request this is required for existing tests from 8fcf8e7fd4 to
continue to pass, this is because they never exercised glsl to nir so
the missing support went unnoticed.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11456
Fixes: 8fcf8e7fd4 ("glsl: lower builtins to mediump that ignore precision of certain parameters ")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30395>
This commit is contained in:
Timothy Arceri 2024-07-27 18:27:03 +10:00 committed by Marge Bot
parent 50ce777edd
commit 140ca7e5d7

View file

@ -1730,10 +1730,24 @@ nir_visitor::visit(ir_expression *ir)
case ir_binop_interpolate_at_sample: {
ir_dereference *deref = ir->operands[0]->as_dereference();
ir_swizzle *swizzle = NULL;
ir_expression *precision_op = NULL;
if (!deref) {
swizzle = ir->operands[0]->as_swizzle();
assert(swizzle);
deref = swizzle->val->as_dereference();
precision_op = ir->operands[0]->as_expression();
if (precision_op) {
/* For some builtins precision is lowered to mediump for certain
* parameters that ignore precision. For example for Interpolation
* and Bitfield functions.
*/
assert(precision_op->operation == ir_unop_f2fmp);
deref = precision_op->operands[0]->as_dereference();
}
if (!deref) {
swizzle = ir->operands[0]->as_swizzle();
assert(swizzle);
deref = swizzle->val->as_dereference();
}
assert(deref);
}
@ -1775,6 +1789,10 @@ nir_visitor::visit(ir_expression *ir)
swizzle->type->vector_elements);
}
if (precision_op) {
result = nir_build_alu(&b, nir_op_f2fmp, result, NULL, NULL, NULL);
}
return;
}