[Mesa-dev] [PATCH 2/3] st: Sweep NIR after linking phase to free held memory

Danylo Piliaiev danylo.piliaiev at gmail.com
Tue Jul 10 08:51:45 UTC 2018


After optimization passes and many trasfromations most of memory
NIR holds is a garbage which was being freed only after shader deletion.
Freeing it at the end of linking will save memory which would be useful
in case there are a lot of complex shaders being compiled.
The common case for this issue is 32bit game running under Wine.

The cost of the optimization is around ~3-5% of compilation speed
with complex shaders.

Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 1985fe1d53..ae2c49960c 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -773,6 +773,8 @@ st_link_nir(struct gl_context *ctx,
          _mesa_reference_program(ctx, &shader->Program, NULL);
          return false;
       }
+
+      nir_sweep(shader->Program->nir);
    }
 
    return true;
-- 
2.17.1



More information about the mesa-dev mailing list