Mesa (main): glsl/nir: free GLSL IR right after we convert to NIR

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 24 01:34:34 UTC 2022


Module: Mesa
Branch: main
Commit: 6eec8fcbfa6e90431d47919479debf76fb04b8b0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6eec8fcbfa6e90431d47919479debf76fb04b8b0

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Wed Feb 16 14:41:45 2022 +1100

glsl/nir: free GLSL IR right after we convert to NIR

Gives us memory back faster which is useful for pathalogical CTS
tests.

The GLSL IR was previously used after converting to NIR for things
like building the GL resource list but we have had a NIR version
for this for some time and I don't believe there are any other
use cases left for keeping the old IR hanging around this long.

Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15127>

---

 src/compiler/glsl/glsl_to_nir.cpp         | 4 ++++
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 43abb35812f..bbc0aa93ad6 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -224,6 +224,10 @@ glsl_to_nir(const struct gl_constants *consts,
    v2.run(sh->ir);
    visit_exec_list(sh->ir, &v1);
 
+   /* The GLSL IR won't be needed anymore. */
+   ralloc_free(sh->ir);
+   sh->ir = NULL;
+
    nir_validate_shader(shader, "after glsl to nir, before function inline");
 
    /* We have to lower away local constant initializers right before we
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 6b27e61b10e..a15f6605e90 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -855,10 +855,6 @@ st_link_nir(struct gl_context *ctx,
 
       st_release_variants(st, prog);
       st_finalize_program(st, prog);
-
-      /* The GLSL IR won't be needed anymore. */
-      ralloc_free(shader->ir);
-      shader->ir = NULL;
    }
 
    return true;



More information about the mesa-commit mailing list