Updated command-line options, adding -o for saving binaries, -G for OpenGL SPIR-V validation, -v etc.

Old uses should still work as they did before.
Also encapsulated use of these flags during parsing, for the parse context.
Added SPIR-V version to -v.
This commit is contained in:
John Kessenich
2015-07-12 19:28:10 -06:00
parent b329715caf
commit 68d78fd31e
11 changed files with 159 additions and 97 deletions

View File

@@ -2543,13 +2543,18 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TType& glslangT
namespace glslang {
void GetSpirvVersion(std::string& version)
{
char buf[10];
snprintf(buf, "0.%d", spv::Version);
version = buf;
}
// Write SPIR-V out to a binary file
void OutputSpv(const std::vector<unsigned int>& spirv, const char* baseName)
{
std::ofstream out;
std::string fileName(baseName);
fileName.append(".spv");
out.open(fileName.c_str(), std::ios::binary | std::ios::out);
out.open(baseName, std::ios::binary | std::ios::out);
for (int i = 0; i < (int)spirv.size(); ++i) {
unsigned int word = spirv[i];
out.write((const char*)&word, 4);

View File

@@ -36,6 +36,7 @@
namespace glslang {
void GetSpirvVersion(std::string&);
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv);
void OutputSpv(const std::vector<unsigned int>& spirv, const char* baseName);