r600/sfn: make sure the memory pool is released after shader translation
authorGert Wollny <gert.wollny@collabora.com>
Sun, 24 Jul 2022 11:37:31 +0000 (13:37 +0200)
committerMarge Bot <emma+marge@anholt.net>
Sun, 24 Jul 2022 18:39:13 +0000 (18:39 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17729>

src/gallium/drivers/r600/sfn/sfn_nir.cpp
src/gallium/drivers/r600/sfn/sfn_shader_vs.h
src/gallium/drivers/r600/sfn/sfn_valuefactory.h

index 8c87884..1dfb532 100644 (file)
@@ -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  &&
index 41751b8..571f32a 100644 (file)
@@ -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;
 };
 
 
index 89a9bcf..74ee1a5 100644 (file)
@@ -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;