Free memory associated with SPIR-V generation.
[platform/upstream/glslang.git] / glslang / MachineIndependent / Intermediate.cpp
index 2e9fa85..4d60dcd 100644 (file)
@@ -1613,7 +1613,13 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
 void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
 {
     assert(!pragmaTable);
-    pragmaTable = new TPragmaTable();
+
+    // We allocate this with the thread-pool allocator because the destructors
+    // for TIntermNode's are never called. When TIntermNodes are no longer
+    // needed, the pool allocator destroys all memory at once without
+    // destruction.
+    void* memory = GetThreadPoolAllocator().allocate(sizeof(TPragmaTable));
+    pragmaTable = new(memory) TPragmaTable();
     *pragmaTable = pTable;
 }