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
e7df8e0b
Commit
e7df8e0b
authored
Aug 22, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Non-functional: Rationalize some existing use of SPIRV-Tools.
parent
1323bf8e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
28 deletions
+44
-28
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+35
-26
disassemble.cpp
SPIRV/disassemble.cpp
+8
-1
localintermediate.h
glslang/MachineIndependent/localintermediate.h
+1
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
e7df8e0b
...
@@ -3219,7 +3219,7 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
...
@@ -3219,7 +3219,7 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
// adjusting this late means inconsistencies with earlier code, which for reflection is an issue
// adjusting this late means inconsistencies with earlier code, which for reflection is an issue
// Until reflection is brought in sync with these adjustments, don't apply to $Global,
// Until reflection is brought in sync with these adjustments, don't apply to $Global,
// which is the most likely to rely on reflection, and least likely to rely implicit layouts
// which is the most likely to rely on reflection, and least likely to rely implicit layouts
if
(
glslangIntermediate
->
usingHlslO
F
fsets
()
&&
if
(
glslangIntermediate
->
usingHlslO
f
fsets
()
&&
!
memberType
.
isArray
()
&&
memberType
.
isVector
()
&&
structType
.
getTypeName
().
compare
(
"$Global"
)
!=
0
)
{
!
memberType
.
isArray
()
&&
memberType
.
isVector
()
&&
structType
.
getTypeName
().
compare
(
"$Global"
)
!=
0
)
{
int
dummySize
;
int
dummySize
;
int
componentAlignment
=
glslangIntermediate
->
getBaseAlignmentScalar
(
memberType
,
dummySize
);
int
componentAlignment
=
glslangIntermediate
->
getBaseAlignmentScalar
(
memberType
,
dummySize
);
...
@@ -7003,31 +7003,12 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
...
@@ -7003,31 +7003,12 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
GlslangToSpv
(
intermediate
,
spirv
,
&
logger
,
options
);
GlslangToSpv
(
intermediate
,
spirv
,
&
logger
,
options
);
}
}
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
spv
::
SpvBuildLogger
*
logger
,
SpvOptions
*
options
)
{
TIntermNode
*
root
=
intermediate
.
getTreeRoot
();
if
(
root
==
0
)
return
;
glslang
::
SpvOptions
defaultOptions
;
if
(
options
==
nullptr
)
options
=
&
defaultOptions
;
glslang
::
GetThreadPoolAllocator
().
push
();
TGlslangToSpvTraverser
it
(
intermediate
.
getSpv
().
spv
,
&
intermediate
,
logger
,
*
options
);
root
->
traverse
(
&
it
);
it
.
finishSpv
();
it
.
dumpSpv
(
spirv
);
#if ENABLE_OPT
#if ENABLE_OPT
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types
.
// Apply the SPIRV-Tools validator to generated SPIR-V
.
if
((
intermediate
.
getSource
()
==
EShSourceHlsl
||
void
SpirvToolsLegalize
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
options
->
optimizeSize
)
&&
spv
::
SpvBuildLogger
*
logger
,
const
SpvOptions
*
options
)
!
options
->
disableOptimizer
)
{
{
spv_target_env
target_env
=
SPV_ENV_UNIVERSAL_1_2
;
spv_target_env
target_env
=
SPV_ENV_UNIVERSAL_1_2
;
spvtools
::
Optimizer
optimizer
(
target_env
);
spvtools
::
Optimizer
optimizer
(
target_env
);
...
@@ -7091,8 +7072,36 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
...
@@ -7091,8 +7072,36 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
optimizer
.
RegisterPass
(
CreateAggressiveDCEPass
());
optimizer
.
RegisterPass
(
CreateAggressiveDCEPass
());
optimizer
.
RegisterPass
(
CreateCFGCleanupPass
());
optimizer
.
RegisterPass
(
CreateCFGCleanupPass
());
if
(
!
optimizer
.
Run
(
spirv
.
data
(),
spirv
.
size
(),
&
spirv
))
optimizer
.
Run
(
spirv
.
data
(),
spirv
.
size
(),
&
spirv
);
}
#endif
void
GlslangToSpv
(
const
glslang
::
TIntermediate
&
intermediate
,
std
::
vector
<
unsigned
int
>&
spirv
,
spv
::
SpvBuildLogger
*
logger
,
SpvOptions
*
options
)
{
TIntermNode
*
root
=
intermediate
.
getTreeRoot
();
if
(
root
==
0
)
return
;
return
;
glslang
::
SpvOptions
defaultOptions
;
if
(
options
==
nullptr
)
options
=
&
defaultOptions
;
glslang
::
GetThreadPoolAllocator
().
push
();
TGlslangToSpvTraverser
it
(
intermediate
.
getSpv
().
spv
,
&
intermediate
,
logger
,
*
options
);
root
->
traverse
(
&
it
);
it
.
finishSpv
();
it
.
dumpSpv
(
spirv
);
#if ENABLE_OPT
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types.
if
((
intermediate
.
getSource
()
==
EShSourceHlsl
||
options
->
optimizeSize
)
&&
!
options
->
disableOptimizer
)
{
SpirvToolsLegalize
(
intermediate
,
spirv
,
logger
,
options
);
}
}
#endif
#endif
...
...
SPIRV/disassemble.cpp
View file @
e7df8e0b
...
@@ -723,16 +723,23 @@ void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
...
@@ -723,16 +723,23 @@ void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
// Use the SPIRV-Tools disassembler to print SPIR-V.
// Use the SPIRV-Tools disassembler to print SPIR-V.
void
SpirvToolsDisassemble
(
std
::
ostream
&
out
,
const
std
::
vector
<
unsigned
int
>&
spirv
)
void
SpirvToolsDisassemble
(
std
::
ostream
&
out
,
const
std
::
vector
<
unsigned
int
>&
spirv
)
{
{
// disassemble
spv_context
context
=
spvContextCreate
(
SPV_ENV_UNIVERSAL_1_3
);
spv_context
context
=
spvContextCreate
(
SPV_ENV_UNIVERSAL_1_3
);
spv_text
text
;
spv_text
text
;
spv_diagnostic
diagnostic
=
nullptr
;
spv_diagnostic
diagnostic
=
nullptr
;
spvBinaryToText
(
context
,
&
spirv
.
front
(),
spirv
.
size
(),
spvBinaryToText
(
context
,
spirv
.
data
(),
spirv
.
size
(),
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES
|
SPV_BINARY_TO_TEXT_OPTION_INDENT
,
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES
|
SPV_BINARY_TO_TEXT_OPTION_INDENT
,
&
text
,
&
diagnostic
);
&
text
,
&
diagnostic
);
// dump
if
(
diagnostic
==
nullptr
)
if
(
diagnostic
==
nullptr
)
out
<<
text
->
str
;
out
<<
text
->
str
;
else
else
spvDiagnosticPrint
(
diagnostic
);
spvDiagnosticPrint
(
diagnostic
);
// teardown
spvDiagnosticDestroy
(
diagnostic
);
spvContextDestroy
(
context
);
}
}
#endif
#endif
...
...
glslang/MachineIndependent/localintermediate.h
View file @
e7df8e0b
...
@@ -349,7 +349,7 @@ public:
...
@@ -349,7 +349,7 @@ public:
if
(
hlslOffsets
)
if
(
hlslOffsets
)
processes
.
addProcess
(
"hlsl-offsets"
);
processes
.
addProcess
(
"hlsl-offsets"
);
}
}
bool
usingHlslO
F
fsets
()
const
{
return
hlslOffsets
;
}
bool
usingHlslO
f
fsets
()
const
{
return
hlslOffsets
;
}
void
setUseStorageBuffer
()
void
setUseStorageBuffer
()
{
{
useStorageBuffer
=
true
;
useStorageBuffer
=
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