[lunarglass] r1086 committed - SPV: add -A option to dump human readable SPV. From David Neto <dneto...

11 views
Skip to first unread message

lunar...@googlecode.com

unread,
May 29, 2015, 1:20:58 PM5/29/15
to lunargla...@googlegroups.com
Revision: 1086
Author: jo...@lunarg.com
Date: Fri May 29 17:20:42 2015 UTC
Log: SPV: add -A option to dump human readable SPV. From David Neto
<dn...@google.com>.

https://code.google.com/p/lunarglass/source/detail?r=1086

Modified:
/trunk/Standalone/main.cpp

=======================================
--- /trunk/Standalone/main.cpp Mon May 11 01:14:44 2015 UTC
+++ /trunk/Standalone/main.cpp Fri May 29 17:20:42 2015 UTC
@@ -37,6 +37,9 @@
// glslang includes
#include "glslang/Include/ShHandle.h"
#include "glslang/Public/ShaderLang.h"
+#include "SPIRV/doc.h"
+#include "SPIRV/disassemble.h"
+#include "SPIRV/GLSL450Lib.h"
#include "SPIRV/GlslangToSpv.h"

// glslang StandAlone include
@@ -50,6 +53,7 @@
#include "OptionParse.h"
#include "Backends/GLSL/GlslManager.h"

+#include <iostream>
#include <string.h>

#ifdef _WIN32
@@ -78,6 +82,11 @@

ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };

+// An array of names used for printing SPIR-V human-readable assembly.
+// It's accessed implicitly by spv::disassemble.
+const char* GlslStd450DebugNames[GLSL_STD_450::Count];
+
+
namespace {

//
@@ -113,6 +122,7 @@
EOptionFilterInactive = 0x2000,
EOptionDumpIndexShader = 0x4000,
EOptionUseSpv = 0x8000,
+ EOptionHumanReadableSpv = 0x10000,
};

int Options = 0; // the non-manager options
@@ -254,6 +264,7 @@
if (advanced) {
printf("Developer options:\n"
" -a dump LunarGLASS Top IR and Bottom IR\n"
+ " -A dump SPIR-V human readable assembly. Requires -V.\n"
" -i intermediate tree (glslang AST) is printed out\n"
" -m memory leak mode\n"
" -u dump index shader\n\n");
@@ -353,6 +364,9 @@
case 'w':
Options |= EOptionSuppressWarnings;
break;
+ case 'A':
+ Options |= EOptionHumanReadableSpv;
+ break;
case 'z':
usage(true);
return EFailUsage;
@@ -620,6 +634,12 @@
if (Options & EOptionUseSpv) {
std::vector<unsigned int> spirv;
glslang::GlslangToSpv(*intermediate, spirv);
+ if (Options & EOptionHumanReadableSpv) {
+ std::cerr << "SPIR-V:" << std::endl;
+ spv::Parameterize();
+ GLSL_STD_450::GetDebugNames(GlslStd450DebugNames);
+ spv::Disassemble(std::cerr, spirv);
+ }
gla::SpvToTop(spirv, manager);
} else
TranslateGlslangToTop(*intermediate, manager);
Reply all
Reply to author
Forward
0 new messages