[Mesa-dev] [PATCH 3/3] intel/nir: Enable nir_opt_move_discards_to_top

Jason Ekstrand jason at jlekstrand.net
Wed Jul 4 06:13:09 UTC 2018


According to RenderDoc, this shaves about 15% off of one of the render
passes in the Skyrim SE frame I've been analyzing on my KBL laptop and
about 8% off the whole frame.  It's a bit noisy and hard to tell with
just the DXVK HUD but there appears to be a small FPS bump in-game as
well.
---
 src/intel/compiler/brw_compiler.c | 3 ++-
 src/intel/compiler/brw_nir.c      | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_compiler.c b/src/intel/compiler/brw_compiler.c
index 6480dbefbf6..86bd4c6bac6 100644
--- a/src/intel/compiler/brw_compiler.c
+++ b/src/intel/compiler/brw_compiler.c
@@ -46,7 +46,8 @@
    .native_integers = true,                                                   \
    .use_interpolated_input_intrinsics = true,                                 \
    .vertex_id_zero_based = true,                                              \
-   .lower_base_vertex = true
+   .lower_base_vertex = true,                                                 \
+   .derivatives_safe_after_discard = true
 
 #define COMMON_SCALAR_OPTIONS                                                 \
    .lower_pack_half_2x16 = true,                                              \
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index f4aee3d41ee..decf7e3f57b 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -664,6 +664,9 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)
 
    nir = brw_nir_optimize(nir, compiler, is_scalar);
 
+   if (nir->info.stage == MESA_SHADER_FRAGMENT)
+      OPT(nir_opt_move_discards_to_top);
+
    /* This needs to be run after the first optimization pass but before we
     * lower indirect derefs away
     */
-- 
2.17.1



More information about the mesa-dev mailing list