nir: Delete lower_io_types
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 27 Mar 2018 14:37:18 +0000 (07:37 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 23 Jun 2018 03:54:00 +0000 (20:54 -0700)
It's only used by the ir3 stand-alone compiler and Rob said we could
delete it.

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/compiler/Makefile.sources
src/compiler/nir/meson.build
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_io_types.c [deleted file]
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c

index 21d84bd7d51bb63e9ce7f832cbc3b76d91269f33..0fcbc5c5c5b612e76b4d9feda511fb6a8e4ad3da 100644 (file)
@@ -244,7 +244,6 @@ NIR_FILES = \
        nir/nir_lower_io_arrays_to_elements.c \
        nir/nir_lower_io_to_temporaries.c \
        nir/nir_lower_io_to_scalar.c \
-       nir/nir_lower_io_types.c \
        nir/nir_lower_packing.c \
        nir/nir_lower_passthrough_edgeflags.c \
        nir/nir_lower_patch_vertices.c \
index d5df696a4a800ca857a4f53d74c365a8bf50a286..eb7fb7b121ea2006f84fc6c992536e9174d655b1 100644 (file)
@@ -128,7 +128,6 @@ files_libnir = files(
   'nir_lower_io_arrays_to_elements.c',
   'nir_lower_io_to_temporaries.c',
   'nir_lower_io_to_scalar.c',
-  'nir_lower_io_types.c',
   'nir_lower_packing.c',
   'nir_lower_passthrough_edgeflags.c',
   'nir_lower_patch_vertices.c',
index 376ed5f1d175d7426fe9b31aa592d498625893c8..6f2f65848f278799a4339b63b5f68c9d16043c65 100644 (file)
@@ -2740,7 +2740,6 @@ nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr *instr);
 
 bool nir_is_per_vertex_io(const nir_variable *var, gl_shader_stage stage);
 
-void nir_lower_io_types(nir_shader *shader);
 bool nir_lower_regs_to_ssa_impl(nir_function_impl *impl);
 bool nir_lower_regs_to_ssa(nir_shader *shader);
 bool nir_lower_vars_to_ssa(nir_shader *shader);
diff --git a/src/compiler/nir/nir_lower_io_types.c b/src/compiler/nir/nir_lower_io_types.c
deleted file mode 100644 (file)
index bbdbcda..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright © 2016 Red Hat
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "nir.h"
-#include "nir_builder.h"
-
-/* Lower complex (struct/array/mat) input and output vars to primitive types
- * (vec4) for linking.  All indirect input/output access should already be
- * lowered (ie. nir_lower_io_to_temporaries).
- */
-
-struct lower_io_types_state {
-   nir_shader *shader;
-   struct exec_list new_ins;
-   struct exec_list new_outs;
-};
-
-static nir_variable *
-get_new_var(struct lower_io_types_state *state, nir_variable *var,
-            const struct glsl_type *deref_type, unsigned off)
-{
-   struct exec_list *list;
-
-   if (var->data.mode == nir_var_shader_in) {
-      list = &state->new_ins;
-   } else {
-      assert(var->data.mode == nir_var_shader_out);
-      list = &state->new_outs;
-   }
-
-   nir_foreach_variable(nvar, list) {
-      if (nvar->data.location == (var->data.location + off))
-         return nvar;
-   }
-
-   /* doesn't already exist, so we need to create a new one: */
-   /* TODO figure out if we need to fixup interpolation mode for int vs float
-    * components of a struct, etc..
-    */
-   nir_variable *nvar = nir_variable_create(state->shader, var->data.mode,
-                                            deref_type, NULL);
-
-   nvar->name = ralloc_asprintf(nvar, "%s@%u", var->name, off);
-   nvar->data = var->data;
-   nvar->data.location += off;
-
-   /* nir_variable_create is too clever for its own good: */
-   exec_node_remove(&nvar->node);
-   exec_node_self_link(&nvar->node);      /* no delinit() :-( */
-
-   exec_list_push_tail(list, &nvar->node);
-
-   /* remove existing var from input/output list: */
-   exec_node_remove(&var->node);
-   exec_node_self_link(&var->node);
-
-   return nvar;
-}
-
-static unsigned
-get_deref_offset(struct lower_io_types_state *state, nir_deref *tail, bool vs_in)
-{
-   unsigned offset = 0;
-
-   while (tail->child != NULL) {
-      const struct glsl_type *parent_type = tail->type;
-      tail = tail->child;
-
-      if (tail->deref_type == nir_deref_type_array) {
-         nir_deref_array *deref_array = nir_deref_as_array(tail);
-
-         /* indirect inputs/outputs should already be lowered! */
-         assert(deref_array->deref_array_type == nir_deref_array_type_direct);
-
-         unsigned size = glsl_count_attribute_slots(tail->type, vs_in);
-
-         offset += size * deref_array->base_offset;
-      } else if (tail->deref_type == nir_deref_type_struct) {
-         nir_deref_struct *deref_struct = nir_deref_as_struct(tail);
-
-         for (unsigned i = 0; i < deref_struct->index; i++) {
-            const struct glsl_type *ft = glsl_get_struct_field(parent_type, i);
-            offset += glsl_count_attribute_slots(ft, vs_in);
-         }
-      }
-   }
-
-   return offset;
-}
-
-static bool
-lower_io_types_block(struct lower_io_types_state *state, nir_block *block)
-{
-   nir_foreach_instr(instr, block) {
-      if (instr->type != nir_instr_type_intrinsic)
-         continue;
-
-      nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
-
-      if ((intr->intrinsic != nir_intrinsic_load_var) &&
-          (intr->intrinsic != nir_intrinsic_store_var))
-         continue;
-
-      nir_variable *var = intr->variables[0]->var;
-
-      if ((var->data.mode != nir_var_shader_in) &&
-          (var->data.mode != nir_var_shader_out))
-         continue;
-
-      bool vs_in = (state->shader->info.stage == MESA_SHADER_VERTEX) &&
-                   (var->data.mode == nir_var_shader_in);
-      if (glsl_count_attribute_slots(var->type, vs_in) == 1)
-         continue;
-
-      unsigned off = get_deref_offset(state, &intr->variables[0]->deref, vs_in);
-      const struct glsl_type *deref_type =
-         nir_deref_tail(&intr->variables[0]->deref)->type;
-      nir_variable *nvar = get_new_var(state, var, deref_type, off);
-
-      /* and then re-write the load/store_var deref: */
-      intr->variables[0] = nir_deref_var_create(intr, nvar);
-   }
-
-   return true;
-}
-
-static void
-lower_io_types_impl(nir_function_impl *impl, struct lower_io_types_state *state)
-{
-   nir_foreach_block(block, impl) {
-      lower_io_types_block(state, block);
-   }
-
-   nir_metadata_preserve(impl, nir_metadata_block_index |
-                               nir_metadata_dominance);
-}
-
-
-void
-nir_lower_io_types(nir_shader *shader)
-{
-   struct lower_io_types_state state;
-
-   nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
-
-   state.shader = shader;
-   exec_list_make_empty(&state.new_ins);
-   exec_list_make_empty(&state.new_outs);
-
-   nir_foreach_function(function, shader) {
-      if (function->impl)
-         lower_io_types_impl(function->impl, &state);
-   }
-
-   /* move new in/out vars to shader's lists: */
-   exec_list_append(&shader->inputs, &state.new_ins);
-   exec_list_append(&shader->outputs, &state.new_outs);
-}
index ab2fbf618bfba7f653a08a7c74c447b6f2c7a318..8ec91c7fbb2679d44099f0e1c5319b8a03b6cb26 100644 (file)
@@ -127,7 +127,6 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 
        NIR_PASS_V(nir, nir_split_var_copies);
        NIR_PASS_V(nir, nir_lower_var_copies);
-       NIR_PASS_V(nir, nir_lower_io_types);
 
        switch (stage) {
        case MESA_SHADER_VERTEX: