Mesa (master): nir: Count i/o slots correctly for per-view variables
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Sep 29 10:48:47 UTC 2020
Module: Mesa
Branch: master
Commit: df955ce6b6ac6baa7ae4df21fe3267f0e4bfc7be
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=df955ce6b6ac6baa7ae4df21fe3267f0e4bfc7be
Author: Connor Abbott <cwabbott0 at gmail.com>
Date: Fri Aug 21 13:34:20 2020 +0200
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 at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6514>
---
src/compiler/nir/nir_linking_helpers.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index f46d3c81264..2159e7c6886 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -1098,7 +1098,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
bool last_partial = false;
nir_foreach_variable_in_list(var, &io_vars) {
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));
type = glsl_get_array_element(type);
}
@@ -1112,7 +1112,7 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
else
base = VARYING_SLOT_VAR0;
- unsigned var_size;
+ unsigned var_size, driver_size;
if (var->data.compact) {
/* If we are inside a partial compact,
* 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 */
+ assert(!var->data.per_view);
assert(glsl_type_is_array(type));
assert(glsl_type_is_scalar(glsl_get_array_element(type)));
unsigned start = 4 * location + var->data.location_frac;
unsigned end = start + glsl_get_length(type);
- var_size = end / 4 - location;
+ var_size = driver_size = end / 4 - location;
last_partial = end % 4 != 0;
} else {
/* 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++;
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
@@ -1163,6 +1177,8 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
* we may have already have processed this location.
*/
if (processed) {
+ /* TODO handle overlapping per-view variables */
+ assert(!var->data.per_view);
unsigned driver_location = assigned_locations[var->data.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;
- location += var_size;
+ location += driver_size;
}
if (last_partial)
More information about the mesa-commit
mailing list