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
e2156222
Commit
e2156222
authored
Jun 11, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Add option to print disassembly in standard form using SPIRV-Tools.
parent
6d61684f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
2 deletions
+40
-2
CMakeLists.txt
SPIRV/CMakeLists.txt
+1
-0
disassemble.cpp
SPIRV/disassemble.cpp
+21
-0
disassemble.h
SPIRV/disassemble.h
+4
-0
CMakeLists.txt
StandAlone/CMakeLists.txt
+1
-0
StandAlone.cpp
StandAlone/StandAlone.cpp
+13
-2
No files found.
SPIRV/CMakeLists.txt
View file @
e2156222
...
@@ -60,6 +60,7 @@ if(ENABLE_OPT)
...
@@ -60,6 +60,7 @@ if(ENABLE_OPT)
PRIVATE
${
spirv-tools_SOURCE_DIR
}
/source
PRIVATE
${
spirv-tools_SOURCE_DIR
}
/source
)
)
target_link_libraries
(
SPIRV glslang SPIRV-Tools-opt
)
target_link_libraries
(
SPIRV glslang SPIRV-Tools-opt
)
target_include_directories
(
SPIRV PUBLIC ../External
)
else
()
else
()
target_link_libraries
(
SPIRV glslang
)
target_link_libraries
(
SPIRV glslang
)
endif
(
ENABLE_OPT
)
endif
(
ENABLE_OPT
)
...
...
SPIRV/disassemble.cpp
View file @
e2156222
...
@@ -716,4 +716,25 @@ void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
...
@@ -716,4 +716,25 @@ void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
SpirvStream
.
processInstructions
();
SpirvStream
.
processInstructions
();
}
}
#if ENABLE_OPT
#include "spirv-tools/source/disassemble.h"
// Use the SPIRV-Tools disassembler to print SPIR-V.
void
SpirvToolsDisassemble
(
std
::
ostream
&
out
,
const
std
::
vector
<
unsigned
int
>&
spirv
)
{
spv_context
context
=
spvContextCreate
(
SPV_ENV_UNIVERSAL_1_3
);
spv_text
text
;
spv_diagnostic
diagnostic
=
nullptr
;
spvBinaryToText
(
context
,
&
spirv
.
front
(),
spirv
.
size
(),
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES
|
SPV_BINARY_TO_TEXT_OPTION_INDENT
,
&
text
,
&
diagnostic
);
if
(
diagnostic
==
nullptr
)
out
<<
text
->
str
;
else
spvDiagnosticPrint
(
diagnostic
);
}
#endif
};
// end namespace spv
};
// end namespace spv
SPIRV/disassemble.h
View file @
e2156222
...
@@ -45,8 +45,12 @@
...
@@ -45,8 +45,12 @@
namespace
spv
{
namespace
spv
{
// disassemble with glslang custom disassembler
void
Disassemble
(
std
::
ostream
&
out
,
const
std
::
vector
<
unsigned
int
>&
);
void
Disassemble
(
std
::
ostream
&
out
,
const
std
::
vector
<
unsigned
int
>&
);
// disassemble with SPIRV-Tools disassembler
void
SpirvToolsDisassemble
(
std
::
ostream
&
out
,
const
std
::
vector
<
unsigned
int
>&
stream
);
};
// end namespace spv
};
// end namespace spv
#endif // disassembler_H
#endif // disassembler_H
StandAlone/CMakeLists.txt
View file @
e2156222
...
@@ -33,6 +33,7 @@ endif(WIN32)
...
@@ -33,6 +33,7 @@ endif(WIN32)
target_link_libraries
(
glslangValidator
${
LIBRARIES
}
)
target_link_libraries
(
glslangValidator
${
LIBRARIES
}
)
target_link_libraries
(
spirv-remap
${
LIBRARIES
}
)
target_link_libraries
(
spirv-remap
${
LIBRARIES
}
)
target_include_directories
(
glslangValidator PUBLIC ../External
)
if
(
WIN32
)
if
(
WIN32
)
source_group
(
"Source"
FILES
${
SOURCES
}
)
source_group
(
"Source"
FILES
${
SOURCES
}
)
...
...
StandAlone/StandAlone.cpp
100644 → 100755
View file @
e2156222
...
@@ -102,6 +102,7 @@ enum TOptions {
...
@@ -102,6 +102,7 @@ enum TOptions {
EOptionDumpBareVersion
=
(
1
<<
31
),
EOptionDumpBareVersion
=
(
1
<<
31
),
};
};
bool
targetHlslFunctionality1
=
false
;
bool
targetHlslFunctionality1
=
false
;
bool
SpvToolsDisassembler
=
false
;
//
//
// Return codes from main/exit().
// Return codes from main/exit().
...
@@ -506,6 +507,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
...
@@ -506,6 +507,8 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
sourceEntryPointName
=
argv
[
1
];
sourceEntryPointName
=
argv
[
1
];
bumpArg
();
bumpArg
();
break
;
break
;
}
else
if
(
lowerword
==
"spirv-dis"
)
{
SpvToolsDisassembler
=
true
;
}
else
if
(
lowerword
==
"stdin"
)
{
}
else
if
(
lowerword
==
"stdin"
)
{
Options
|=
EOptionStdin
;
Options
|=
EOptionStdin
;
shaderStageName
=
argv
[
1
];
shaderStageName
=
argv
[
1
];
...
@@ -982,14 +985,20 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
...
@@ -982,14 +985,20 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
}
else
{
}
else
{
glslang
::
OutputSpvBin
(
spirv
,
GetBinaryName
((
EShLanguage
)
stage
));
glslang
::
OutputSpvBin
(
spirv
,
GetBinaryName
((
EShLanguage
)
stage
));
}
}
if
(
Options
&
EOptionHumanReadableSpv
)
{
#if ENABLE_OPT
if
(
SpvToolsDisassembler
)
spv
::
SpirvToolsDisassemble
(
std
::
cout
,
spirv
);
#else
if
(
SpvToolsDisassembler
)
printf
(
"SPIRV-Tools is not enabled; use -H for human readable SPIR-V
\n
"
);
#endif
if
(
!
SpvToolsDisassembler
&&
(
Options
&
EOptionHumanReadableSpv
))
spv
::
Disassemble
(
std
::
cout
,
spirv
);
spv
::
Disassemble
(
std
::
cout
,
spirv
);
}
}
}
}
}
}
}
}
}
}
}
// Free everything up, program has to go before the shaders
// Free everything up, program has to go before the shaders
// because it might have merged stuff from the shaders, and
// because it might have merged stuff from the shaders, and
...
@@ -1405,6 +1414,8 @@ void usage()
...
@@ -1405,6 +1414,8 @@ void usage()
" --shift-UBO-binding [stage] [num set]... per-descriptor-set shift values
\n
"
" --shift-UBO-binding [stage] [num set]... per-descriptor-set shift values
\n
"
" --shift-cbuffer-binding [stage] num synonym for --shift-UBO-binding
\n
"
" --shift-cbuffer-binding [stage] num synonym for --shift-UBO-binding
\n
"
" --shift-cbuffer-binding [stage] [num set]... per-descriptor-set shift values
\n
"
" --shift-cbuffer-binding [stage] [num set]... per-descriptor-set shift values
\n
"
" --spirv-dis output standard form disassembly; works only
\n
"
" when a SPIR-V generation option is also used
\n
"
" --sub [stage] num synonym for --shift-UBO-binding
\n
"
" --sub [stage] num synonym for --shift-UBO-binding
\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
"
...
...
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