summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-05-18 00:08:36 -0700
committerJuan A. Suarez Romero <[email protected]>2019-05-21 09:04:42 +0000
commitab75e1e289e3ea2eb33ece21987012f6900620d5 (patch)
treec6276cc4e7798f339f67140008845db45d36fcf6
parent2153c3ae8e96a86b6aa437dece56231ea55b6ba5 (diff)
nir: Fix clone of nir_variable state slots
When num_state_slots is 0, don't create the array. This was triggering the following assert when running vkcube with NIR_TEST_CLONE=1 vkcube: ../src/compiler/nir/nir_split_per_member_structs.c:66: split_variable: Assertion `var->state_slots == NULL' failed. Fixes: 9fbd390dd4b "nir: Add support for cloning shaders" Reviewed-by: Jason Ekstrand <[email protected]> (cherry picked from commit 005cc9ae37ca45960d87389dc9eace5ed29d1b99)
-rw-r--r--src/compiler/nir/nir_clone.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index eec10a1b847..f4000321575 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -151,9 +151,11 @@ nir_variable_clone(const nir_variable *var, nir_shader *shader)
nvar->name = ralloc_strdup(nvar, var->name);
nvar->data = var->data;
nvar->num_state_slots = var->num_state_slots;
- nvar->state_slots = ralloc_array(nvar, nir_state_slot, var->num_state_slots);
- memcpy(nvar->state_slots, var->state_slots,
- var->num_state_slots * sizeof(nir_state_slot));
+ if (var->num_state_slots) {
+ nvar->state_slots = ralloc_array(nvar, nir_state_slot, var->num_state_slots);
+ memcpy(nvar->state_slots, var->state_slots,
+ var->num_state_slots * sizeof(nir_state_slot));
+ }
if (var->constant_initializer) {
nvar->constant_initializer =
nir_constant_clone(var->constant_initializer, nvar);