summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRhys Perry <pendingchaos02@gmail.com>2019-11-14 15:31:52 +0000
committerDylan Baker <dylan@pnwbakers.com>2019-12-03 10:46:09 -0800
commitf9e8f6bad81a235fd93fe537e94f745ae679a629 (patch)
tree33441e8bbdf3bead723c9e178946ab7968cf4f7c
parentf7d100caad4ca170f9d2dacf02bf5e8d7cffe918 (diff)
downloadmesa-f9e8f6bad81a235fd93fe537e94f745ae679a629.tar.gz
mesa-f9e8f6bad81a235fd93fe537e94f745ae679a629.tar.bz2
mesa-f9e8f6bad81a235fd93fe537e94f745ae679a629.zip
nir/lower_io_to_vector: don't create arrays when not needed
Some backends require that there are no array varyings. If there were no arrays in the input shader, the pass shouldn't have to create new ones. Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2103 Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2167 Fixes: bcd14756eec ('nir/lower_io_to_vector: add flat mode') Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com> (cherry picked from commit 5404b7aaa36fad18df19e12abcc8af69014e74c2)
-rw-r--r--src/compiler/nir/nir_lower_io_to_vector.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_lower_io_to_vector.c b/src/compiler/nir/nir_lower_io_to_vector.c
index 0ef40216da6..82c4bdf8749 100644
--- a/src/compiler/nir/nir_lower_io_to_vector.c
+++ b/src/compiler/nir/nir_lower_io_to_vector.c
@@ -184,7 +184,10 @@ get_flat_type(const nir_shader *shader, nir_variable *old_vars[MAX_SLOTS][4],
if (num_vars <= 1)
return NULL;
- return glsl_array_type(glsl_vector_type(base, 4), slots, 0);
+ if (slots == 1)
+ return glsl_vector_type(base, 4);
+ else
+ return glsl_array_type(glsl_vector_type(base, 4), slots, 0);
}
static bool
@@ -340,6 +343,9 @@ build_array_deref_of_new_var_flat(nir_shader *shader,
deref = nir_build_deref_array(b, deref, index);
}
+ if (!glsl_type_is_array(deref->type))
+ return deref;
+
bool vs_in = shader->info.stage == MESA_SHADER_VERTEX &&
new_var->data.mode == nir_var_shader_in;
return nir_build_deref_array(