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
e2c15b4f
Commit
e2c15b4f
authored
Nov 16, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memory: Reference count number of clients, to support multiple independent clients in same process.
Addresses 2nd item in #976.
parent
b63f4a38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
StandAlone.cpp
StandAlone/StandAlone.cpp
+9
-6
ShaderLang.cpp
glslang/MachineIndependent/ShaderLang.cpp
+16
-0
No files found.
StandAlone/StandAlone.cpp
View file @
e2c15b4f
...
...
@@ -1074,21 +1074,24 @@ int singleMain()
if
(
Options
&
EOptionLinkProgram
||
Options
&
EOptionOutputPreprocessed
)
{
glslang
::
InitializeProcess
();
glslang
::
InitializeProcess
();
// also test reference counting of users
glslang
::
InitializeProcess
();
// also test reference counting of users
glslang
::
FinalizeProcess
();
// also test reference counting of users
glslang
::
FinalizeProcess
();
// also test reference counting of users
CompileAndLinkShaderFiles
(
workList
);
glslang
::
FinalizeProcess
();
}
else
{
ShInitialize
();
ShInitialize
();
// also test reference counting of users
ShFinalize
();
// also test reference counting of users
bool
printShaderNames
=
workList
.
size
()
>
1
;
if
(
Options
&
EOptionMultiThreaded
)
{
if
(
Options
&
EOptionMultiThreaded
)
{
std
::
array
<
std
::
thread
,
16
>
threads
;
for
(
unsigned
int
t
=
0
;
t
<
threads
.
size
();
++
t
)
{
for
(
unsigned
int
t
=
0
;
t
<
threads
.
size
();
++
t
)
{
threads
[
t
]
=
std
::
thread
(
CompileShaders
,
std
::
ref
(
workList
));
if
(
threads
[
t
].
get_id
()
==
std
::
thread
::
id
())
{
if
(
threads
[
t
].
get_id
()
==
std
::
thread
::
id
())
{
fprintf
(
stderr
,
"Failed to create thread
\n
"
);
return
EFailThreadCreate
;
}
...
...
glslang/MachineIndependent/ShaderLang.cpp
View file @
e2c15b4f
...
...
@@ -69,6 +69,10 @@
namespace
{
// anonymous namespace for file-local functions and symbols
// Total number of successful initializers of glslang: a refcount
// Shared global; access should be protected by a global mutex/critical section.
int
NumberOfClients
=
0
;
using
namespace
glslang
;
// Create a language specific version of parseables.
...
...
@@ -1193,6 +1197,10 @@ int ShInitialize()
if
(
!
InitProcess
())
return
0
;
glslang
::
GetGlobalLock
();
++
NumberOfClients
;
glslang
::
ReleaseGlobalLock
();
if
(
PerProcessGPA
==
nullptr
)
PerProcessGPA
=
new
TPoolAllocator
();
...
...
@@ -1259,6 +1267,14 @@ void ShDestruct(ShHandle handle)
//
int
__fastcall
ShFinalize
()
{
glslang
::
GetGlobalLock
();
--
NumberOfClients
;
assert
(
NumberOfClients
>=
0
);
bool
finalize
=
NumberOfClients
==
0
;
glslang
::
ReleaseGlobalLock
();
if
(
!
finalize
)
return
1
;
for
(
int
version
=
0
;
version
<
VersionCount
;
++
version
)
{
for
(
int
spvVersion
=
0
;
spvVersion
<
SpvVersionCount
;
++
spvVersion
)
{
for
(
int
p
=
0
;
p
<
ProfileCount
;
++
p
)
{
...
...
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