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
0a6fb854
Commit
0a6fb854
authored
Aug 09, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Infrastructure: Make shared symbol-table cache complete, delete work around.
Fixes issue #370 and replaces PR #371.
parent
0b521448
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
53 deletions
+42
-53
revision.h
glslang/Include/revision.h
+2
-2
ShaderLang.cpp
glslang/MachineIndependent/ShaderLang.cpp
+39
-16
Initializer.h
gtests/Initializer.h
+1
-33
TestFixture.h
gtests/TestFixture.h
+0
-2
No files found.
glslang/Include/revision.h
View file @
0a6fb854
...
...
@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "SPIRV99.139
4
"
#define GLSLANG_DATE "0
8
-Aug-2016"
#define GLSLANG_REVISION "SPIRV99.139
6
"
#define GLSLANG_DATE "0
9
-Aug-2016"
glslang/MachineIndependent/ShaderLang.cpp
View file @
0a6fb854
...
...
@@ -146,6 +146,23 @@ int MapProfileToIndex(EProfile profile)
return
index
;
}
const
int
SourceCount
=
2
;
int
MapSourceToIndex
(
EShSource
source
)
{
int
index
=
0
;
switch
(
source
)
{
case
EShSourceGlsl
:
index
=
0
;
break
;
case
EShSourceHlsl
:
index
=
1
;
break
;
default:
break
;
}
assert
(
index
<
SourceCount
);
return
index
;
}
// only one of these needed for non-ES; ES needs 2 for different precision defaults of built-ins
enum
EPrecisionClass
{
EPcGeneral
,
...
...
@@ -161,8 +178,8 @@ enum EPrecisionClass {
// Each has a different set of built-ins, and we want to preserve that from
// compile to compile.
//
TSymbolTable
*
CommonSymbolTable
[
VersionCount
][
SpvVersionCount
][
ProfileCount
][
EPcCount
]
=
{};
TSymbolTable
*
SharedSymbolTables
[
VersionCount
][
SpvVersionCount
][
ProfileCount
][
EShLangCount
]
=
{};
TSymbolTable
*
CommonSymbolTable
[
VersionCount
][
SpvVersionCount
][
ProfileCount
][
SourceCount
][
EPcCount
]
=
{};
TSymbolTable
*
SharedSymbolTables
[
VersionCount
][
SpvVersionCount
][
ProfileCount
][
SourceCount
][
EShLangCount
]
=
{};
TPoolAllocator
*
PerProcessGPA
=
0
;
...
...
@@ -305,7 +322,8 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
int
versionIndex
=
MapVersionToIndex
(
version
);
int
spvVersionIndex
=
MapSpvVersionToIndex
(
spvVersion
);
int
profileIndex
=
MapProfileToIndex
(
profile
);
if
(
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
EPcGeneral
])
{
int
sourceIndex
=
MapSourceToIndex
(
source
);
if
(
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
sourceIndex
][
EPcGeneral
])
{
glslang
::
ReleaseGlobalLock
();
return
;
...
...
@@ -333,18 +351,18 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
// Copy the local symbol tables from the new pool to the global tables using the process-global pool
for
(
int
precClass
=
0
;
precClass
<
EPcCount
;
++
precClass
)
{
if
(
!
commonTable
[
precClass
]
->
isEmpty
())
{
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
precClass
]
=
new
TSymbolTable
;
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
precClass
]
->
copyTable
(
*
commonTable
[
precClass
]);
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
precClass
]
->
readOnly
();
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
sourceIndex
][
precClass
]
=
new
TSymbolTable
;
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
sourceIndex
][
precClass
]
->
copyTable
(
*
commonTable
[
precClass
]);
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
sourceIndex
][
precClass
]
->
readOnly
();
}
}
for
(
int
stage
=
0
;
stage
<
EShLangCount
;
++
stage
)
{
if
(
!
stageTables
[
stage
]
->
isEmpty
())
{
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
stage
]
=
new
TSymbolTable
;
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
stage
]
->
adoptLevels
(
*
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
CommonIndex
(
profile
,
(
EShLanguage
)
stage
)]);
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
stage
]
->
copyTable
(
*
stageTables
[
stage
]);
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
stage
]
->
readOnly
();
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
s
ourceIndex
][
s
tage
]
=
new
TSymbolTable
;
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
s
ourceIndex
][
s
tage
]
->
adoptLevels
(
*
CommonSymbolTable
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
sourceIndex
][
CommonIndex
(
profile
,
(
EShLanguage
)
stage
)]);
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
s
ourceIndex
][
s
tage
]
->
copyTable
(
*
stageTables
[
stage
]);
SharedSymbolTables
[
versionIndex
][
spvVersionIndex
][
profileIndex
][
s
ourceIndex
][
s
tage
]
->
readOnly
();
}
}
...
...
@@ -656,6 +674,7 @@ bool ProcessDeferred(
TSymbolTable
*
cachedTable
=
SharedSymbolTables
[
MapVersionToIndex
(
version
)]
[
MapSpvVersionToIndex
(
spvVersion
)]
[
MapProfileToIndex
(
profile
)]
[
MapSourceToIndex
(
source
)]
[
compiler
->
getLanguage
()];
// Dynamically allocate the symbol table so we can control when it is deallocated WRT the pool.
...
...
@@ -1092,9 +1111,11 @@ int __fastcall ShFinalize()
for
(
int
version
=
0
;
version
<
VersionCount
;
++
version
)
{
for
(
int
spvVersion
=
0
;
spvVersion
<
SpvVersionCount
;
++
spvVersion
)
{
for
(
int
p
=
0
;
p
<
ProfileCount
;
++
p
)
{
for
(
int
lang
=
0
;
lang
<
EShLangCount
;
++
lang
)
{
delete
SharedSymbolTables
[
version
][
spvVersion
][
p
][
lang
];
SharedSymbolTables
[
version
][
spvVersion
][
p
][
lang
]
=
0
;
for
(
int
source
=
0
;
source
<
SourceCount
;
++
source
)
{
for
(
int
stage
=
0
;
stage
<
EShLangCount
;
++
stage
)
{
delete
SharedSymbolTables
[
version
][
spvVersion
][
p
][
source
][
stage
];
SharedSymbolTables
[
version
][
spvVersion
][
p
][
source
][
stage
]
=
0
;
}
}
}
}
...
...
@@ -1103,9 +1124,11 @@ int __fastcall ShFinalize()
for
(
int
version
=
0
;
version
<
VersionCount
;
++
version
)
{
for
(
int
spvVersion
=
0
;
spvVersion
<
SpvVersionCount
;
++
spvVersion
)
{
for
(
int
p
=
0
;
p
<
ProfileCount
;
++
p
)
{
for
(
int
source
=
0
;
source
<
SourceCount
;
++
source
)
{
for
(
int
pc
=
0
;
pc
<
EPcCount
;
++
pc
)
{
delete
CommonSymbolTable
[
version
][
spvVersion
][
p
][
pc
];
CommonSymbolTable
[
version
][
spvVersion
][
p
][
pc
]
=
0
;
delete
CommonSymbolTable
[
version
][
spvVersion
][
p
][
source
][
pc
];
CommonSymbolTable
[
version
][
spvVersion
][
p
][
source
][
pc
]
=
0
;
}
}
}
}
...
...
gtests/Initializer.h
View file @
0a6fb854
...
...
@@ -40,46 +40,14 @@
namespace
glslangtest
{
// Initializes glslang on creation, and destroys it on completion.
// And provides .Acquire() as a way to reinitialize glslang if semantics change.
// This object is expected to be a singleton, so that internal glslang state
// can be correctly handled.
//
// TODO(antiagainst): It's a known bug that some of the internal states need to
// be reset if semantics change:
// https://github.com/KhronosGroup/glslang/issues/166
// Therefore, the following mechanism is needed. Remove this once the above bug
// gets fixed.
class
GlslangInitializer
{
public
:
GlslangInitializer
()
:
lastMessages
(
EShMsgCascadingErrors
)
{
glslang
::
InitializeProcess
();
}
GlslangInitializer
()
{
glslang
::
InitializeProcess
();
}
~
GlslangInitializer
()
{
glslang
::
FinalizeProcess
();
}
// A token indicates that the glslang is reinitialized (if necessary) to the
// required semantics. And that won't change until the token is destroyed.
class
InitializationToken
{
};
// Re-initializes glsl state iff the previous messages and the current
// messages are incompatible. We assume external synchronization, i.e.
// there is at most one acquired token at any one time.
InitializationToken
acquire
(
EShMessages
new_messages
)
{
if
((
lastMessages
^
new_messages
)
&
(
EShMsgVulkanRules
|
EShMsgSpvRules
|
EShMsgReadHlsl
))
{
glslang
::
FinalizeProcess
();
glslang
::
InitializeProcess
();
}
lastMessages
=
new_messages
;
return
InitializationToken
();
}
private
:
EShMessages
lastMessages
;
};
}
// namespace glslangtest
...
...
gtests/TestFixture.h
View file @
0a6fb854
...
...
@@ -179,8 +179,6 @@ public:
shader
->
setStringsWithLengths
(
&
shaderStrings
,
&
shaderLengths
,
1
);
if
(
!
entryPointName
.
empty
())
shader
->
setEntryPoint
(
entryPointName
.
c_str
());
// Reinitialize glslang if the semantics change.
GlobalTestSettings
.
initializer
->
acquire
(
controls
);
return
shader
->
parse
(
(
resources
?
resources
:
&
glslang
::
DefaultTBuiltInResource
),
defaultVersion
,
isForwardCompatible
,
controls
);
...
...
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