Mesa (main): r600/sfn: make sure the memory pool is released after shader translation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jul 24 18:45:34 UTC 2022


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

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Sun Jul 24 13:37:31 2022 +0200

r600/sfn: make sure the memory pool is released after shader translation

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17729>

---

 src/gallium/drivers/r600/sfn/sfn_nir.cpp        | 10 ++++++++++
 src/gallium/drivers/r600/sfn/sfn_shader_vs.h    |  6 +++++-
 src/gallium/drivers/r600/sfn/sfn_valuefactory.h |  3 ++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
index 8c878849b21..1dfb532d9d2 100644
--- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
@@ -628,10 +628,20 @@ bool r600_lower_to_scalar_instr_filter(const nir_instr *instr, const void *)
    }
 }
 
+
+class MallocPoolRelease {
+public:
+   ~MallocPoolRelease() {
+      r600::release_pool();
+   }
+};
+
 int r600_shader_from_nir(struct r600_context *rctx,
                          struct r600_pipe_shader *pipeshader,
                          r600_shader_key *key)
 {
+   MallocPoolRelease pool_release;
+
    struct r600_pipe_shader_selector *sel = pipeshader->selector;
 
    bool lower_64bit = (rctx->b.gfx_level < CAYMAN  &&
diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_vs.h b/src/gallium/drivers/r600/sfn/sfn_shader_vs.h
index 41751b887e1..571f32a6a33 100644
--- a/src/gallium/drivers/r600/sfn/sfn_shader_vs.h
+++ b/src/gallium/drivers/r600/sfn/sfn_shader_vs.h
@@ -120,7 +120,11 @@ private:
 
    const pipe_stream_output_info *m_so_info {nullptr};
 
-   std::unordered_map<int, RegisterVec4 *> m_output_registers;
+   template <typename Key, typename T>
+   using unordered_map_alloc = std::unordered_map<Key, T, std::hash<Key>, std::equal_to<Key>,
+   Allocator<std::pair<const Key, T>>>;
+
+   unordered_map_alloc<int, RegisterVec4 *> m_output_registers;
 };
 
 
diff --git a/src/gallium/drivers/r600/sfn/sfn_valuefactory.h b/src/gallium/drivers/r600/sfn/sfn_valuefactory.h
index 89a9bcf7a78..74ee1a5496e 100644
--- a/src/gallium/drivers/r600/sfn/sfn_valuefactory.h
+++ b/src/gallium/drivers/r600/sfn/sfn_valuefactory.h
@@ -37,6 +37,7 @@
 #include <cassert>
 #include <ostream>
 #include <unordered_map>
+#include <list>
 
 struct r600_shader;
 
@@ -282,7 +283,7 @@ private:
     using ROValueMap = unordered_reg_map_alloc<RegisterKey, PVirtualValue>;
 
     RegisterMap m_registers;
-    std::vector<PRegister> m_pinned_registers;
+    std::list<PRegister, Allocator<PRegister>> m_pinned_registers;
     ROValueMap m_values;
     unordered_map_alloc<uint32_t, PLiteralVirtualValue> m_literal_values;
     unordered_map_alloc<uint32_t, InlineConstant::Pointer> m_inline_constants;



More information about the mesa-commit mailing list