nir: Count i/o slots correctly for per-view variables
This function wasn't counting driver slots correctly, resulting in incorrect driver_location's and input_count. It seems intel doesn't use this yet. Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6514>
This commit is contained in:
@@ -1098,7 +1098,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
|
|||||||
bool last_partial = false;
|
bool last_partial = false;
|
||||||
nir_foreach_variable_in_list(var, &io_vars) {
|
nir_foreach_variable_in_list(var, &io_vars) {
|
||||||
const struct glsl_type *type = var->type;
|
const struct glsl_type *type = var->type;
|
||||||
if (nir_is_per_vertex_io(var, stage) || var->data.per_view) {
|
if (nir_is_per_vertex_io(var, stage)) {
|
||||||
assert(glsl_type_is_array(type));
|
assert(glsl_type_is_array(type));
|
||||||
type = glsl_get_array_element(type);
|
type = glsl_get_array_element(type);
|
||||||
}
|
}
|
||||||
@@ -1112,7 +1112,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
|
|||||||
else
|
else
|
||||||
base = VARYING_SLOT_VAR0;
|
base = VARYING_SLOT_VAR0;
|
||||||
|
|
||||||
unsigned var_size;
|
unsigned var_size, driver_size;
|
||||||
if (var->data.compact) {
|
if (var->data.compact) {
|
||||||
/* If we are inside a partial compact,
|
/* If we are inside a partial compact,
|
||||||
* don't allow another compact to be in this slot
|
* don't allow another compact to be in this slot
|
||||||
@@ -1123,11 +1123,12 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* compact variables must be arrays of scalars */
|
/* compact variables must be arrays of scalars */
|
||||||
|
assert(!var->data.per_view);
|
||||||
assert(glsl_type_is_array(type));
|
assert(glsl_type_is_array(type));
|
||||||
assert(glsl_type_is_scalar(glsl_get_array_element(type)));
|
assert(glsl_type_is_scalar(glsl_get_array_element(type)));
|
||||||
unsigned start = 4 * location + var->data.location_frac;
|
unsigned start = 4 * location + var->data.location_frac;
|
||||||
unsigned end = start + glsl_get_length(type);
|
unsigned end = start + glsl_get_length(type);
|
||||||
var_size = end / 4 - location;
|
var_size = driver_size = end / 4 - location;
|
||||||
last_partial = end % 4 != 0;
|
last_partial = end % 4 != 0;
|
||||||
} else {
|
} else {
|
||||||
/* Compact variables bypass the normal varying compacting pass,
|
/* Compact variables bypass the normal varying compacting pass,
|
||||||
@@ -1139,7 +1140,20 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
|
|||||||
location++;
|
location++;
|
||||||
last_partial = false;
|
last_partial = false;
|
||||||
}
|
}
|
||||||
var_size = glsl_count_attribute_slots(type, false);
|
|
||||||
|
/* per-view variables have an extra array dimension, which is ignored
|
||||||
|
* when counting user-facing slots (var->data.location), but *not*
|
||||||
|
* with driver slots (var->data.driver_location). That is, each user
|
||||||
|
* slot maps to multiple driver slots.
|
||||||
|
*/
|
||||||
|
driver_size = glsl_count_attribute_slots(type, false);
|
||||||
|
if (var->data.per_view) {
|
||||||
|
assert(glsl_type_is_array(type));
|
||||||
|
var_size =
|
||||||
|
glsl_count_attribute_slots(glsl_get_array_element(type), false);
|
||||||
|
} else {
|
||||||
|
var_size = driver_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Builtins don't allow component packing so we only need to worry about
|
/* Builtins don't allow component packing so we only need to worry about
|
||||||
@@ -1163,6 +1177,8 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
|
|||||||
* we may have already have processed this location.
|
* we may have already have processed this location.
|
||||||
*/
|
*/
|
||||||
if (processed) {
|
if (processed) {
|
||||||
|
/* TODO handle overlapping per-view variables */
|
||||||
|
assert(!var->data.per_view);
|
||||||
unsigned driver_location = assigned_locations[var->data.location];
|
unsigned driver_location = assigned_locations[var->data.location];
|
||||||
var->data.driver_location = driver_location;
|
var->data.driver_location = driver_location;
|
||||||
|
|
||||||
@@ -1193,7 +1209,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var->data.driver_location = location;
|
var->data.driver_location = location;
|
||||||
location += var_size;
|
location += driver_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_partial)
|
if (last_partial)
|
||||||
|
Reference in New Issue
Block a user