KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
3.05k stars 837 forks source link

Make POOL_ALLOCATOR_NEW_DELETE optional #3123

Open crazydef opened 1 year ago

crazydef commented 1 year ago

Without an easy way to disable this macro/these operators, it's very hard to provide a custom memory manager to glslang.

It would be nice if this could be disabled with a build switch.

ncesario-lunarg commented 1 year ago

I have proposed removing this macro in https://github.com/KhronosGroup/glslang/pull/3387 in an attempt to make the usage of the pool allocator more obvious in the code.

arcady-lunarg commented 9 months ago

The thread pool allocator is used for allocation correctness because of the way the compiler works: while processing a compilation unit, a densely-interlinked object graph is allocated and used to keep track of variables, expressions, types, etc and then when compilation is done it's all deallocated with a single pop() call. In the end the pool allocator delegates to the global operator new[] and operator delete[] for managing the underlying memory.