diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-26 12:14:11 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-30 16:06:09 -0700 |
commit | 20237166b60a9fe525c906a3efd1046d2853c40a (patch) | |
tree | 3cc8de81f2d776401ae8d77e26dba4cc73af4ea8 | |
parent | 0b225f1892a677d9b735782c9d6aac4ee5d33c56 (diff) |
pan/midgard: Use shared psiz clamp pass
We already had a perfectly cromulent pass for this, but one landed in
common NIR code so let's switch and lighten our tree.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/meson.build | 1 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c | 75 | ||||
-rw-r--r-- | src/panfrost/midgard/compiler.h | 5 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_compile.c | 2 |
4 files changed, 1 insertions, 82 deletions
diff --git a/src/gallium/drivers/panfrost/meson.build b/src/gallium/drivers/panfrost/meson.build index 8d4facec982..c188274236b 100644 --- a/src/gallium/drivers/panfrost/meson.build +++ b/src/gallium/drivers/panfrost/meson.build @@ -29,7 +29,6 @@ files_panfrost = files( 'nir/nir_undef_to_zero.c', 'nir/nir_lower_blend.c', 'nir/nir_lower_framebuffer.c', - 'nir/nir_clamp_psiz.c', 'pan_context.c', 'pan_afbc.c', diff --git a/src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c b/src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c deleted file mode 100644 index 249a400a19e..00000000000 --- a/src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c +++ /dev/null @@ -1,75 +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. - */ - -/** - * @file - * - * Clamps writes to VARYING_SLOT_PSIZ to a given limit. - */ - -#include "compiler/nir/nir.h" -#include "compiler/nir/nir_builder.h" - -void -nir_clamp_psiz(nir_shader *shader, float min_size, float max_size); - -void -nir_clamp_psiz(nir_shader *shader, float min_size, float max_size) -{ - nir_foreach_function(func, shader) { - nir_foreach_block(block, func->impl) { - nir_foreach_instr_safe(instr, block) { - if (instr->type != nir_instr_type_intrinsic) - continue; - - nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); - if (intr->intrinsic != nir_intrinsic_store_deref) - continue; - - nir_variable *var = nir_intrinsic_get_var(intr, 0); - if (var->data.location != VARYING_SLOT_PSIZ) - continue; - - nir_builder b; - nir_builder_init(&b, func->impl); - b.cursor = nir_before_instr(instr); - - nir_ssa_def *in_size = nir_ssa_for_src(&b, intr->src[1], - intr->num_components); - - nir_ssa_def *clamped = - nir_fmin(&b, - nir_fmax(&b, in_size, nir_imm_float(&b, min_size)), - nir_imm_float(&b, max_size)); - - nir_instr_rewrite_src(instr, &intr->src[1], - nir_src_for_ssa(clamped)); - - } - } - - nir_metadata_preserve(func->impl, nir_metadata_block_index | - nir_metadata_dominance); - } -} - diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index 97795b25cb9..b202a92aeea 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -635,14 +635,9 @@ void emit_binary_bundle( struct util_dynarray *emission, int next_tag); -/* NIR stuff. TODO: Move? Share? Something? */ - bool nir_undef_to_zero(nir_shader *shader); -void -nir_clamp_psiz(nir_shader *shader, float min_size, float max_size); - /* Optimizations */ bool midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block); diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index eec3e8d56ed..79f33e8006e 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -2525,7 +2525,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga if (ctx->stage == MESA_SHADER_VERTEX) { NIR_PASS_V(nir, nir_lower_viewport_transform); - NIR_PASS_V(nir, nir_clamp_psiz, 1.0, 1024.0); + NIR_PASS_V(nir, nir_lower_point_size, 1.0, 1024.0); } NIR_PASS_V(nir, nir_lower_var_copies); |