glsl: lower builtins to mediump that ignore precision of certain parameters

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
This commit is contained in:
Marek Olšák
2020-07-01 13:11:33 -04:00
parent 3781697c23
commit 8fcf8e7fd4
2 changed files with 97 additions and 0 deletions

View File

@@ -499,10 +499,28 @@ is_lowerable_builtin(ir_call *ir,
assert(ir->callee->return_precision == GLSL_PRECISION_NONE);
/* Number of parameters to check if they are lowerable. */
unsigned check_parameters = ir->actual_parameters.length();
/* Interpolation functions only consider the precision of the interpolant. */
/* Bitfield functions ignore the precision of "offset" and "bits". */
if (!strcmp(ir->callee_name(), "interpolateAtOffset") ||
!strcmp(ir->callee_name(), "interpolateAtSample") ||
!strcmp(ir->callee_name(), "bitfieldExtract")) {
check_parameters = 1;
} else if (!strcmp(ir->callee_name(), "bitfieldInsert")) {
check_parameters = 2;
}
foreach_in_list(ir_rvalue, param, &ir->actual_parameters) {
if (!check_parameters)
break;
if (!param->as_constant() &&
_mesa_set_search(lowerable_rvalues, param) == NULL)
return false;
--check_parameters;
}
return true;