Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
928b7b26
Unverified
Commit
928b7b26
authored
Aug 03, 2020
by
John Kessenich
Committed by
GitHub
Aug 03, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2361 from ben-clayton/revert-thread-local
Revert changes that migrate to `thread_local`.
parents
7ab45646
2a440648
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
161 additions
and
35 deletions
+161
-35
CMakeLists.txt
CMakeLists.txt
+5
-11
CMakeLists.txt
OGLCompilersDLL/CMakeLists.txt
+0
-1
InitializeDll.cpp
OGLCompilersDLL/InitializeDll.cpp
+128
-0
InitializeDll.h
OGLCompilersDLL/InitializeDll.h
+4
-4
CMakeLists.txt
SPIRV/CMakeLists.txt
+5
-4
CMakeLists.txt
glslang/CMakeLists.txt
+1
-3
InitializeGlobals.h
glslang/Include/InitializeGlobals.h
+1
-1
PoolAlloc.cpp
glslang/MachineIndependent/PoolAlloc.cpp
+17
-11
No files found.
CMakeLists.txt
View file @
928b7b26
...
@@ -279,23 +279,17 @@ function(glslang_add_build_info_dependency target)
...
@@ -279,23 +279,17 @@ function(glslang_add_build_info_dependency target)
add_dependencies
(
${
target
}
glslang-build-info
)
add_dependencies
(
${
target
}
glslang-build-info
)
endfunction
()
endfunction
()
# glslang_default_to_hidden_visibility() makes the symbol visibility hidden by
# default for <target>.
function
(
glslang_default_to_hidden_visibility target
)
if
(
NOT WIN32
)
target_compile_options
(
${
target
}
PRIVATE
"-fvisibility=hidden"
)
endif
()
endfunction
()
# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by
# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by
# default for <target>, and sets the GLSLANG_IS_SHARED_LIBRARY define, and
# default for <target> when building shared libraries, and sets the
# GLSLANG_EXPORTING to 1 when specifically building <target>.
# GLSLANG_IS_SHARED_LIBRARY define, and GLSLANG_EXPORTING to 1 when specifically
# building <target>.
function
(
glslang_only_export_explicit_symbols target
)
function
(
glslang_only_export_explicit_symbols target
)
glslang_default_to_hidden_visibility
(
${
target
}
)
if
(
BUILD_SHARED_LIBS
)
if
(
BUILD_SHARED_LIBS
)
target_compile_definitions
(
${
target
}
PUBLIC
"GLSLANG_IS_SHARED_LIBRARY=1"
)
target_compile_definitions
(
${
target
}
PUBLIC
"GLSLANG_IS_SHARED_LIBRARY=1"
)
if
(
WIN32
)
if
(
WIN32
)
target_compile_definitions
(
${
target
}
PRIVATE
"GLSLANG_EXPORTING=1"
)
target_compile_definitions
(
${
target
}
PRIVATE
"GLSLANG_EXPORTING=1"
)
else
()
target_compile_options
(
${
target
}
PRIVATE
"-fvisibility=hidden"
)
endif
()
endif
()
endif
()
endif
()
endfunction
()
endfunction
()
...
...
OGLCompilersDLL/CMakeLists.txt
View file @
928b7b26
...
@@ -36,7 +36,6 @@ set(SOURCES InitializeDll.cpp InitializeDll.h)
...
@@ -36,7 +36,6 @@ set(SOURCES InitializeDll.cpp InitializeDll.h)
add_library
(
OGLCompiler STATIC
${
SOURCES
}
)
add_library
(
OGLCompiler STATIC
${
SOURCES
}
)
set_property
(
TARGET OGLCompiler PROPERTY FOLDER glslang
)
set_property
(
TARGET OGLCompiler PROPERTY FOLDER glslang
)
set_property
(
TARGET OGLCompiler PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET OGLCompiler PROPERTY POSITION_INDEPENDENT_CODE ON
)
glslang_default_to_hidden_visibility
(
OGLCompiler
)
if
(
WIN32
)
if
(
WIN32
)
source_group
(
"Source"
FILES
${
SOURCES
}
)
source_group
(
"Source"
FILES
${
SOURCES
}
)
...
...
OGLCompilersDLL/InitializeDll.cpp
View file @
928b7b26
...
@@ -32,6 +32,134 @@
...
@@ -32,6 +32,134 @@
// POSSIBILITY OF SUCH DAMAGE.
// 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
{
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
}
// end namespace glslang
OGLCompilersDLL/InitializeDll.h
View file @
928b7b26
...
@@ -38,10 +38,10 @@
...
@@ -38,10 +38,10 @@
namespace
glslang
{
namespace
glslang
{
inline
bool
InitProcess
()
{
return
true
;
}
// DEPRECATED
bool
InitProcess
();
inline
bool
InitThread
()
{
return
true
;
}
// DEPRECATED
bool
InitThread
();
inline
bool
DetachThread
()
{
return
true
;
}
// DEPRECATED
bool
DetachThread
();
// not called from standalone, perhaps other tools rely on parts of it
inline
bool
DetachProcess
()
{
return
true
;
}
// DEPRECATED
bool
DetachProcess
();
// not called from standalone, perhaps other tools rely on parts of it
}
// end namespace glslang
}
// end namespace glslang
...
...
SPIRV/CMakeLists.txt
View file @
928b7b26
...
@@ -43,7 +43,8 @@ set(SOURCES
...
@@ -43,7 +43,8 @@ set(SOURCES
CInterface/spirv_c_interface.cpp
)
CInterface/spirv_c_interface.cpp
)
set
(
SPVREMAP_SOURCES
set
(
SPVREMAP_SOURCES
SPVRemapper.cpp
)
SPVRemapper.cpp
doc.cpp
)
set
(
HEADERS
set
(
HEADERS
bitutils.h
bitutils.h
...
@@ -68,7 +69,6 @@ set(SPVREMAP_HEADERS
...
@@ -68,7 +69,6 @@ set(SPVREMAP_HEADERS
doc.h
)
doc.h
)
add_library
(
SPIRV
${
LIB_TYPE
}
${
SOURCES
}
${
HEADERS
}
)
add_library
(
SPIRV
${
LIB_TYPE
}
${
SOURCES
}
${
HEADERS
}
)
target_link_libraries
(
SPIRV PRIVATE MachineIndependent
)
set_property
(
TARGET SPIRV PROPERTY FOLDER glslang
)
set_property
(
TARGET SPIRV PROPERTY FOLDER glslang
)
set_property
(
TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON
)
target_include_directories
(
SPIRV PUBLIC
target_include_directories
(
SPIRV PUBLIC
...
@@ -79,7 +79,6 @@ glslang_add_build_info_dependency(SPIRV)
...
@@ -79,7 +79,6 @@ glslang_add_build_info_dependency(SPIRV)
if
(
ENABLE_SPVREMAPPER
)
if
(
ENABLE_SPVREMAPPER
)
add_library
(
SPVRemapper
${
LIB_TYPE
}
${
SPVREMAP_SOURCES
}
${
SPVREMAP_HEADERS
}
)
add_library
(
SPVRemapper
${
LIB_TYPE
}
${
SPVREMAP_SOURCES
}
${
SPVREMAP_HEADERS
}
)
target_link_libraries
(
SPVRemapper PRIVATE SPIRV
)
set_property
(
TARGET SPVRemapper PROPERTY FOLDER glslang
)
set_property
(
TARGET SPVRemapper PROPERTY FOLDER glslang
)
set_property
(
TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON
)
endif
()
endif
()
...
@@ -96,10 +95,12 @@ if(ENABLE_OPT)
...
@@ -96,10 +95,12 @@ if(ENABLE_OPT)
PRIVATE
${
spirv-tools_SOURCE_DIR
}
/include
PRIVATE
${
spirv-tools_SOURCE_DIR
}
/include
PRIVATE
${
spirv-tools_SOURCE_DIR
}
/source
PRIVATE
${
spirv-tools_SOURCE_DIR
}
/source
)
)
target_link_libraries
(
SPIRV PRIVATE SPIRV-Tools-opt
)
target_link_libraries
(
SPIRV PRIVATE
MachineIndependent
SPIRV-Tools-opt
)
target_include_directories
(
SPIRV PUBLIC
target_include_directories
(
SPIRV PUBLIC
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/../External>
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/../External>
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
/External>
)
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
/External>
)
else
()
target_link_libraries
(
SPIRV PRIVATE MachineIndependent
)
endif
(
ENABLE_OPT
)
endif
(
ENABLE_OPT
)
if
(
WIN32
)
if
(
WIN32
)
...
...
glslang/CMakeLists.txt
View file @
928b7b26
...
@@ -52,7 +52,6 @@ add_library(GenericCodeGen STATIC
...
@@ -52,7 +52,6 @@ add_library(GenericCodeGen STATIC
GenericCodeGen/Link.cpp
)
GenericCodeGen/Link.cpp
)
set_property
(
TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET GenericCodeGen PROPERTY FOLDER glslang
)
set_property
(
TARGET GenericCodeGen PROPERTY FOLDER glslang
)
glslang_default_to_hidden_visibility
(
GenericCodeGen
)
################################################################################
################################################################################
# MachineIndependent
# MachineIndependent
...
@@ -134,7 +133,6 @@ endif(ENABLE_HLSL)
...
@@ -134,7 +133,6 @@ endif(ENABLE_HLSL)
add_library
(
MachineIndependent STATIC
${
MACHINEINDEPENDENT_SOURCES
}
${
MACHINEINDEPENDENT_HEADERS
}
)
add_library
(
MachineIndependent STATIC
${
MACHINEINDEPENDENT_SOURCES
}
${
MACHINEINDEPENDENT_HEADERS
}
)
set_property
(
TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET MachineIndependent PROPERTY FOLDER glslang
)
set_property
(
TARGET MachineIndependent PROPERTY FOLDER glslang
)
glslang_only_export_explicit_symbols
(
MachineIndependent
)
glslang_add_build_info_dependency
(
MachineIndependent
)
glslang_add_build_info_dependency
(
MachineIndependent
)
...
@@ -170,7 +168,7 @@ set_target_properties(glslang PROPERTIES
...
@@ -170,7 +168,7 @@ set_target_properties(glslang PROPERTIES
POSITION_INDEPENDENT_CODE ON
POSITION_INDEPENDENT_CODE ON
VERSION
"
${
GLSLANG_VERSION
}
"
VERSION
"
${
GLSLANG_VERSION
}
"
SOVERSION
"
${
GLSLANG_VERSION_MAJOR
}
"
)
SOVERSION
"
${
GLSLANG_VERSION_MAJOR
}
"
)
target_link_libraries
(
glslang PRIVATE OGLCompiler MachineIndependent
)
target_link_libraries
(
glslang PRIVATE OGLCompiler
OSDependent
MachineIndependent
)
target_include_directories
(
glslang PUBLIC
target_include_directories
(
glslang PUBLIC
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/..>
$<BUILD_INTERFACE:
${
CMAKE_CURRENT_SOURCE_DIR
}
/..>
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
>
)
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
>
)
...
...
glslang/Include/InitializeGlobals.h
View file @
928b7b26
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
namespace
glslang
{
namespace
glslang
{
inline
bool
InitializePoolIndex
()
{
return
true
;
}
// DEPRECATED: No need to call
bool
InitializePoolIndex
();
}
// end namespace glslang
}
// end namespace glslang
...
...
glslang/MachineIndependent/PoolAlloc.cpp
View file @
928b7b26
...
@@ -35,28 +35,34 @@
...
@@ -35,28 +35,34 @@
#include "../Include/Common.h"
#include "../Include/Common.h"
#include "../Include/PoolAlloc.h"
#include "../Include/PoolAlloc.h"
namespace
glslang
{
#include "../Include/InitializeGlobals.h"
#include "../OSDependent/osinclude.h"
namespace
{
namespace
glslang
{
thread_local
TPoolAllocator
*
threadPoolAllocator
=
nullptr
;
TPoolAllocator
*
GetDefaultThreadPoolAllocator
()
// Process-wide TLS index
{
OS_TLSIndex
PoolIndex
;
thread_local
TPoolAllocator
defaultAllocator
;
return
&
defaultAllocator
;
}
}
// anonymous namespace
// Return the thread-specific current pool.
// Return the thread-specific current pool.
TPoolAllocator
&
GetThreadPoolAllocator
()
TPoolAllocator
&
GetThreadPoolAllocator
()
{
{
return
*
(
threadPoolAllocator
?
threadPoolAllocator
:
GetDefaultThreadPoolAllocator
(
));
return
*
static_cast
<
TPoolAllocator
*>
(
OS_GetTLSValue
(
PoolIndex
));
}
}
// Set the thread-specific current pool.
// Set the thread-specific current pool.
void
SetThreadPoolAllocator
(
TPoolAllocator
*
poolAllocator
)
void
SetThreadPoolAllocator
(
TPoolAllocator
*
poolAllocator
)
{
{
threadPoolAllocator
=
poolAllocator
;
OS_SetTLSValue
(
PoolIndex
,
poolAllocator
);
}
// Process-wide set up of the TLS pool storage.
bool
InitializePoolIndex
()
{
// Allocate a TLS index.
if
((
PoolIndex
=
OS_AllocTLSIndex
())
==
OS_INVALID_TLS_INDEX
)
return
false
;
return
true
;
}
}
//
//
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment