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
c340425b
Commit
c340425b
authored
Aug 23, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Add option for controling when the SPIRV-Tools validator is used.
parent
717c80a9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
7 deletions
+20
-7
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+2
-1
SpvTools.h
SPIRV/SpvTools.h
+2
-1
StandAlone.cpp
StandAlone/StandAlone.cpp
+5
-0
runtests
Test/runtests
+3
-3
Link.FromFile.Vk.cpp
gtests/Link.FromFile.Vk.cpp
+1
-0
TestFixture.h
gtests/TestFixture.h
+7
-2
No files found.
SPIRV/GlslangToSpv.cpp
View file @
c340425b
...
@@ -7015,7 +7015,8 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
...
@@ -7015,7 +7015,8 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
it
.
dumpSpv
(
spirv
);
it
.
dumpSpv
(
spirv
);
#if ENABLE_OPT
#if ENABLE_OPT
SpirvToolsValidate
(
intermediate
,
spirv
,
logger
);
if
(
options
->
validate
)
SpirvToolsValidate
(
intermediate
,
spirv
,
logger
);
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types.
// eg. forward and remove memory writes of opaque types.
...
...
SPIRV/SpvTools.h
View file @
c340425b
...
@@ -51,11 +51,12 @@ namespace glslang {
...
@@ -51,11 +51,12 @@ namespace glslang {
struct
SpvOptions
{
struct
SpvOptions
{
SpvOptions
()
:
generateDebugInfo
(
false
),
disableOptimizer
(
true
),
SpvOptions
()
:
generateDebugInfo
(
false
),
disableOptimizer
(
true
),
optimizeSize
(
false
),
disassemble
(
false
)
{
}
optimizeSize
(
false
),
disassemble
(
false
)
,
validate
(
false
)
{
}
bool
generateDebugInfo
;
bool
generateDebugInfo
;
bool
disableOptimizer
;
bool
disableOptimizer
;
bool
optimizeSize
;
bool
optimizeSize
;
bool
disassemble
;
bool
disassemble
;
bool
validate
;
};
};
#if ENABLE_OPT
#if ENABLE_OPT
...
...
StandAlone/StandAlone.cpp
View file @
c340425b
...
@@ -103,6 +103,7 @@ enum TOptions {
...
@@ -103,6 +103,7 @@ enum TOptions {
};
};
bool
targetHlslFunctionality1
=
false
;
bool
targetHlslFunctionality1
=
false
;
bool
SpvToolsDisassembler
=
false
;
bool
SpvToolsDisassembler
=
false
;
bool
SpvToolsValidate
=
false
;
//
//
// Return codes from main/exit().
// Return codes from main/exit().
...
@@ -514,6 +515,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -514,6 +515,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
break
;
break
;
}
else
if
(
lowerword
==
"spirv-dis"
)
{
}
else
if
(
lowerword
==
"spirv-dis"
)
{
SpvToolsDisassembler
=
true
;
SpvToolsDisassembler
=
true
;
}
else
if
(
lowerword
==
"spirv-val"
)
{
SpvToolsValidate
=
true
;
}
else
if
(
lowerword
==
"stdin"
)
{
}
else
if
(
lowerword
==
"stdin"
)
{
Options
|=
EOptionStdin
;
Options
|=
EOptionStdin
;
shaderStageName
=
argv
[
1
];
shaderStageName
=
argv
[
1
];
...
@@ -979,6 +982,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
...
@@ -979,6 +982,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
spvOptions
.
disableOptimizer
=
(
Options
&
EOptionOptimizeDisable
)
!=
0
;
spvOptions
.
disableOptimizer
=
(
Options
&
EOptionOptimizeDisable
)
!=
0
;
spvOptions
.
optimizeSize
=
(
Options
&
EOptionOptimizeSize
)
!=
0
;
spvOptions
.
optimizeSize
=
(
Options
&
EOptionOptimizeSize
)
!=
0
;
spvOptions
.
disassemble
=
SpvToolsDisassembler
;
spvOptions
.
disassemble
=
SpvToolsDisassembler
;
spvOptions
.
validate
=
SpvToolsValidate
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
((
EShLanguage
)
stage
),
spirv
,
&
logger
,
&
spvOptions
);
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
((
EShLanguage
)
stage
),
spirv
,
&
logger
,
&
spvOptions
);
// Dump the spv to a file or stdout, etc., but only if not doing
// Dump the spv to a file or stdout, etc., but only if not doing
...
@@ -1421,6 +1425,7 @@ void usage()
...
@@ -1421,6 +1425,7 @@ void usage()
" --shift-cbuffer-binding | --scb synonyms for --shift-UBO-binding
\n
"
" --shift-cbuffer-binding | --scb synonyms for --shift-UBO-binding
\n
"
" --spirv-dis output standard-form disassembly; works only
\n
"
" --spirv-dis output standard-form disassembly; works only
\n
"
" when a SPIR-V generation option is also used
\n
"
" when a SPIR-V generation option is also used
\n
"
" --spirv-val execute the SPIRV-Tools validator
\n
"
" --source-entrypoint <name> the given shader source function is
\n
"
" --source-entrypoint <name> the given shader source function is
\n
"
" renamed to be the <name> given in -e
\n
"
" renamed to be the <name> given in -e
\n
"
" --sep synonym for --source-entrypoint
\n
"
" --sep synonym for --source-entrypoint
\n
"
...
...
Test/runtests
View file @
c340425b
...
@@ -130,13 +130,13 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out $TARGETDIR/spv.looseUniformNoLoc
...
@@ -130,13 +130,13 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out $TARGETDIR/spv.looseUniformNoLoc
# Testing debug information
# Testing debug information
#
#
echo
Testing SPV Debug Information
echo
Testing SPV Debug Information
$EXE
-g
--relaxed-errors
--suppress-warnings
--aml
--amb
--hlsl-offsets
--nsf
\
$EXE
-g
--relaxed-errors
--suppress-warnings
--aml
--amb
--hlsl-offsets
--nsf
--spirv-val
\
-G
-H
spv.debugInfo.frag
--rsb
frag 3
>
$TARGETDIR
/spv.debugInfo.frag.out
-G
-H
spv.debugInfo.frag
--rsb
frag 3
>
$TARGETDIR
/spv.debugInfo.frag.out
diff
-b
$BASEDIR
/spv.debugInfo.frag.out
$TARGETDIR
/spv.debugInfo.frag.out
||
HASERROR
=
1
diff
-b
$BASEDIR
/spv.debugInfo.frag.out
$TARGETDIR
/spv.debugInfo.frag.out
||
HASERROR
=
1
$EXE
-g
-Od
--target-env
vulkan1.1
--relaxed-errors
--suppress-warnings
--aml
--hlsl-offsets
--nsf
\
$EXE
-g
-Od
--target-env
vulkan1.1
--relaxed-errors
--suppress-warnings
--aml
--hlsl-offsets
--nsf
--spirv-val
\
-G
-H
spv.debugInfo.frag
--rsb
frag 3
>
$TARGETDIR
/spv.debugInfo.1.1.frag.out
-G
-H
spv.debugInfo.frag
--rsb
frag 3
>
$TARGETDIR
/spv.debugInfo.1.1.frag.out
diff
-b
$BASEDIR
/spv.debugInfo.1.1.frag.out
$TARGETDIR
/spv.debugInfo.1.1.frag.out
||
HASERROR
=
1
diff
-b
$BASEDIR
/spv.debugInfo.1.1.frag.out
$TARGETDIR
/spv.debugInfo.1.1.frag.out
||
HASERROR
=
1
$EXE
-g
-D
-Od
-e
newMain
-g
--amb
--aml
--fua
--hlsl-iomap
--nsf
--sib
1
--ssb
2
--sbb
3
--stb
4
--suavb
5
--sub
6
\
$EXE
-g
-D
-Od
-e
newMain
-g
--amb
--aml
--fua
--hlsl-iomap
--nsf
--s
pirv-val
--s
ib
1
--ssb
2
--sbb
3
--stb
4
--suavb
5
--sub
6
\
--sep
origMain
-H
-Od
spv.hlslDebugInfo.vert
--rsb
vert t0 0 0
>
$TARGETDIR
/spv.hlslDebugInfo.frag.out
--sep
origMain
-H
-Od
spv.hlslDebugInfo.vert
--rsb
vert t0 0 0
>
$TARGETDIR
/spv.hlslDebugInfo.frag.out
diff
-b
$BASEDIR
/spv.hlslDebugInfo.frag.out
$TARGETDIR
/spv.hlslDebugInfo.frag.out
||
HASERROR
=
1
diff
-b
$BASEDIR
/spv.hlslDebugInfo.frag.out
$TARGETDIR
/spv.hlslDebugInfo.frag.out
||
HASERROR
=
1
...
...
gtests/Link.FromFile.Vk.cpp
View file @
c340425b
...
@@ -79,6 +79,7 @@ TEST_P(LinkTestVulkan, FromFile)
...
@@ -79,6 +79,7 @@ TEST_P(LinkTestVulkan, FromFile)
std
::
vector
<
uint32_t
>
spirv_binary
;
std
::
vector
<
uint32_t
>
spirv_binary
;
glslang
::
SpvOptions
options
;
glslang
::
SpvOptions
options
;
options
.
disableOptimizer
=
true
;
options
.
disableOptimizer
=
true
;
options
.
validate
=
true
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
shaders
.
front
()
->
getStage
()),
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
shaders
.
front
()
->
getStage
()),
spirv_binary
,
&
logger
,
&
options
);
spirv_binary
,
&
logger
,
&
options
);
...
...
gtests/TestFixture.h
View file @
c340425b
...
@@ -243,6 +243,7 @@ public:
...
@@ -243,6 +243,7 @@ public:
std
::
vector
<
uint32_t
>
spirv_binary
;
std
::
vector
<
uint32_t
>
spirv_binary
;
glslang
::
SpvOptions
options
;
glslang
::
SpvOptions
options
;
options
.
disableOptimizer
=
!
enableOptimizer
;
options
.
disableOptimizer
=
!
enableOptimizer
;
options
.
validate
=
true
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
spirv_binary
,
&
logger
,
&
options
);
spirv_binary
,
&
logger
,
&
options
);
...
@@ -298,8 +299,10 @@ public:
...
@@ -298,8 +299,10 @@ public:
if
(
success
&&
(
controls
&
EShMsgSpvRules
))
{
if
(
success
&&
(
controls
&
EShMsgSpvRules
))
{
std
::
vector
<
uint32_t
>
spirv_binary
;
std
::
vector
<
uint32_t
>
spirv_binary
;
glslang
::
SpvOptions
options
;
options
.
validate
=
true
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
spirv_binary
,
&
logger
);
spirv_binary
,
&
logger
,
&
options
);
std
::
ostringstream
disassembly_stream
;
std
::
ostringstream
disassembly_stream
;
spv
::
Parameterize
();
spv
::
Parameterize
();
...
@@ -338,8 +341,10 @@ public:
...
@@ -338,8 +341,10 @@ public:
if
(
success
&&
(
controls
&
EShMsgSpvRules
))
{
if
(
success
&&
(
controls
&
EShMsgSpvRules
))
{
std
::
vector
<
uint32_t
>
spirv_binary
;
std
::
vector
<
uint32_t
>
spirv_binary
;
glslang
::
SpvOptions
options
;
options
.
validate
=
true
;
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
glslang
::
GlslangToSpv
(
*
program
.
getIntermediate
(
stage
),
spirv_binary
,
&
logger
);
spirv_binary
,
&
logger
,
&
options
);
spv
::
spirvbin_t
(
0
/*verbosity*/
).
remap
(
spirv_binary
,
remapOptions
);
spv
::
spirvbin_t
(
0
/*verbosity*/
).
remap
(
spirv_binary
,
remapOptions
);
...
...
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