nir: fix nir_link_varying_precision

link_varyings ignores precisions and can assign the same location to
variables with different precisions.  nir_link_varying_precision should
check location_frac as well.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20113>
This commit is contained in:
Chia-I Wu 2022-12-01 11:17:04 -08:00 committed by Marge Bot
parent 4663d6fc9c
commit 7244d88516

View file

@ -1322,6 +1322,18 @@ nir_link_precision(unsigned producer, unsigned consumer, bool fs)
return fs ? MAX2(producer, consumer) : consumer;
}
static nir_variable *
find_consumer_variable(const nir_shader *consumer,
const nir_variable *producer_var)
{
nir_foreach_variable_with_modes(var, consumer, nir_var_shader_in) {
if (var->data.location == producer_var->data.location &&
var->data.location_frac == producer_var->data.location_frac)
return var;
}
return NULL;
}
void
nir_link_varying_precision(nir_shader *producer, nir_shader *consumer)
{
@ -1332,8 +1344,8 @@ nir_link_varying_precision(nir_shader *producer, nir_shader *consumer)
if (producer_var->data.location < 0)
continue;
nir_variable *consumer_var = nir_find_variable_with_location(consumer,
nir_var_shader_in, producer_var->data.location);
nir_variable *consumer_var = find_consumer_variable(consumer,
producer_var);
/* Skip if the variable will be eliminated */
if (!consumer_var)