anv/pipeline: Convert lower_multiview to deref instructions
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 3 Apr 2018 00:46:36 +0000 (17:46 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 23 Jun 2018 03:54:00 +0000 (20:54 -0700)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/vulkan/anv_nir_lower_multiview.c

index 6822595728c658e584d652895dcc6def81aba971..bde7aade50f964f9285a55ca7dd1fdc06a393251 100644 (file)
@@ -134,18 +134,11 @@ build_view_index(struct lower_multiview_state *state)
          if (b->shader->info.stage == MESA_SHADER_FRAGMENT)
             idx_var->data.interpolation = INTERP_MODE_FLAT;
 
-         if (glsl_type_is_array(type)) {
-            nir_deref_var *deref = nir_deref_var_create(b->shader, idx_var);
-            nir_deref_array *arr = nir_deref_array_create(b->shader);
-            arr->deref.type = glsl_int_type();
-            arr->deref_array_type = nir_deref_array_type_direct;
-            arr->base_offset = 0;
-            deref->deref.child = &arr->deref;
-
-            state->view_index = nir_load_deref_var(b, deref);
-         } else {
-            state->view_index = nir_load_var(b, idx_var);
-         }
+         nir_deref_instr *deref = nir_build_deref_var(b, idx_var);
+         if (glsl_type_is_array(type))
+            deref = nir_build_deref_array(b, deref, nir_imm_int(b, 0));
+
+         state->view_index = nir_load_deref(b, deref);
       }
    }