mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 20:10:06 +00:00
Deprecate InitializeDll functions
These were only used for TThreadPool, which now uses `thread_local`.
This commit is contained in:
parent
a3845240ae
commit
abf92c80b9
@ -32,134 +32,6 @@
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#define SH_EXPORTING
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "InitializeDll.h"
|
||||
#include "../glslang/Include/InitializeGlobals.h"
|
||||
#include "../glslang/Public/ShaderLang.h"
|
||||
#include "../glslang/Include/PoolAlloc.h"
|
||||
|
||||
namespace glslang {
|
||||
|
||||
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||
|
||||
// Per-process initialization.
|
||||
// Needs to be called at least once before parsing, etc. is done.
|
||||
// Will also do thread initialization for the calling thread; other
|
||||
// threads will need to do that explicitly.
|
||||
bool InitProcess()
|
||||
{
|
||||
glslang::GetGlobalLock();
|
||||
|
||||
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
|
||||
//
|
||||
// Function is re-entrant.
|
||||
//
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return true;
|
||||
}
|
||||
|
||||
ThreadInitializeIndex = OS_AllocTLSIndex();
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! InitializePoolIndex()) {
|
||||
assert(0 && "InitProcess(): Failed to initialize global pool");
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! InitThread()) {
|
||||
assert(0 && "InitProcess(): Failed to initialize thread");
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return false;
|
||||
}
|
||||
|
||||
glslang::ReleaseGlobalLock();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Per-thread scoped initialization.
|
||||
// Must be called at least once by each new thread sharing the
|
||||
// symbol tables, etc., needed to parse.
|
||||
bool InitThread()
|
||||
{
|
||||
//
|
||||
// This function is re-entrant
|
||||
//
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
|
||||
assert(0 && "InitThread(): Process hasn't been initalised.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
|
||||
return true;
|
||||
|
||||
if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
|
||||
assert(0 && "InitThread(): Unable to set init flag.");
|
||||
return false;
|
||||
}
|
||||
|
||||
glslang::SetThreadPoolAllocator(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Not necessary to call this: InitThread() is reentrant, and the need
|
||||
// to do per thread tear down has been removed.
|
||||
//
|
||||
// This is kept, with memory management removed, to satisfy any exiting
|
||||
// calls to it that rely on it.
|
||||
bool DetachThread()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
return true;
|
||||
|
||||
//
|
||||
// Function is re-entrant and this thread may not have been initialized.
|
||||
//
|
||||
if (OS_GetTLSValue(ThreadInitializeIndex) != 0) {
|
||||
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) {
|
||||
assert(0 && "DetachThread(): Unable to clear init flag.");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Not necessary to call this: InitProcess() is reentrant.
|
||||
//
|
||||
// This is kept, with memory management removed, to satisfy any exiting
|
||||
// calls to it that rely on it.
|
||||
//
|
||||
// Users of glslang should call shFinalize() or glslang::FinalizeProcess() for
|
||||
// process-scoped memory tear down.
|
||||
bool DetachProcess()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
|
||||
return true;
|
||||
|
||||
success = DetachThread();
|
||||
|
||||
OS_FreeTLSIndex(ThreadInitializeIndex);
|
||||
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
} // end namespace glslang
|
||||
|
@ -38,10 +38,10 @@
|
||||
|
||||
namespace glslang {
|
||||
|
||||
bool InitProcess();
|
||||
bool InitThread();
|
||||
bool DetachThread(); // not called from standalone, perhaps other tools rely on parts of it
|
||||
bool DetachProcess(); // not called from standalone, perhaps other tools rely on parts of it
|
||||
inline bool InitProcess() { return true; } // DEPRECATED
|
||||
inline bool InitThread() { return true; } // DEPRECATED
|
||||
inline bool DetachThread() { return true; } // DEPRECATED
|
||||
inline bool DetachProcess() { return true; } // DEPRECATED
|
||||
|
||||
} // end namespace glslang
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user