summaryrefslogtreecommitdiff
path: root/src/panfrost/midgard
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-10-15 08:45:24 -0400
committerMarge Bot <eric+marge@anholt.net>2020-10-23 14:48:23 +0000
commit86b2b4eb768bcee6664790a66fc5508002e34424 (patch)
tree6fde1cb2f716047df30b5b207c7237f600d298bd /src/panfrost/midgard
parentf0421099efcece38d866fc749663c61fa880f2cb (diff)
panfrost: Move nir_undef_to_zero to common util/
Will use for Bifrost as well. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7206>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r--src/panfrost/midgard/compiler.h2
-rw-r--r--src/panfrost/midgard/meson.build1
-rw-r--r--src/panfrost/midgard/nir_undef_to_zero.c87
3 files changed, 0 insertions, 90 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index 5a93eb325bd..74a3532ab3c 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -659,8 +659,6 @@ void emit_binary_bundle(
struct util_dynarray *emission,
int next_tag);
-bool
-nir_undef_to_zero(nir_shader *shader);
bool nir_fuse_io_16(nir_shader *shader);
bool midgard_nir_lod_errata(nir_shader *shader);
diff --git a/src/panfrost/midgard/meson.build b/src/panfrost/midgard/meson.build
index 3d78b13d257..80bb0a91388 100644
--- a/src/panfrost/midgard/meson.build
+++ b/src/panfrost/midgard/meson.build
@@ -38,7 +38,6 @@ libpanfrost_midgard_files = files(
'midgard_opt_dce.c',
'midgard_opt_perspective.c',
'midgard_errata_lod.c',
- 'nir_undef_to_zero.c',
'nir_fuse_io_16.c',
)
diff --git a/src/panfrost/midgard/nir_undef_to_zero.c b/src/panfrost/midgard/nir_undef_to_zero.c
deleted file mode 100644
index ed0bb5402ce..00000000000
--- a/src/panfrost/midgard/nir_undef_to_zero.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2019 Collabora, Ltd.
- *
- * 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.
- *
- * Authors (Collabora):
- * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
- */
-
-/**
- * @file
- *
- * Flushes undefined SSA values to a zero vector fo the appropriate component
- * count, to avoid undefined behaviour in the resulting shader. Not required
- * for conformance as use of uninitialized variables is explicitly left
- * undefined by the spec. Works around buggy apps, however.
- *
- * Call immediately after nir_opt_undef. If called before, larger optimization
- * opportunities from the former pass will be missed. If called outside of an
- * optimization loop, constant propagation and algebraic optimizations won't be
- * able to kick in to reduce stuff consuming the zero.
- */
-
-#include "compiler/nir/nir.h"
-#include "compiler/nir/nir_builder.h"
-
-bool nir_undef_to_zero(nir_shader *shader);
-
-bool
-nir_undef_to_zero(nir_shader *shader)
-{
- bool progress = false;
-
- nir_foreach_function(function, shader) {
- if (!function->impl) continue;
-
- nir_builder b;
- nir_builder_init(&b, function->impl);
-
- nir_foreach_block(block, function->impl) {
- nir_foreach_instr_safe(instr, block) {
- if (instr->type != nir_instr_type_ssa_undef) continue;
-
- nir_ssa_undef_instr *und = nir_instr_as_ssa_undef(instr);
-
- /* Get the required size */
- unsigned c = und->def.num_components;
- unsigned s = und->def.bit_size;
-
- nir_const_value v[NIR_MAX_VEC_COMPONENTS];
- memset(v, 0, sizeof(v));
-
- b.cursor = nir_before_instr(instr);
- nir_ssa_def *zero = nir_build_imm(&b, c, s, v);
- nir_src zerosrc = nir_src_for_ssa(zero);
-
- nir_ssa_def_rewrite_uses(&und->def, zerosrc);
-
- progress |= true;
- }
- }
-
- nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance);
-
- }
-
- return progress;
-}
-
-