Merge pull request #314 from mre4ce/master
Added -x option to save SPIR-V as 32-bit hexadecimal numbers to a text file.
This commit is contained in:
@@ -49,8 +49,10 @@ namespace spv {
|
||||
#include "../glslang/MachineIndependent/localintermediate.h"
|
||||
#include "../glslang/MachineIndependent/SymbolTable.h"
|
||||
#include "../glslang/Include/Common.h"
|
||||
#include "../glslang/Include/revision.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
@@ -4448,7 +4450,7 @@ void GetSpirvVersion(std::string& version)
|
||||
}
|
||||
|
||||
// Write SPIR-V out to a binary file
|
||||
void OutputSpv(const std::vector<unsigned int>& spirv, const char* baseName)
|
||||
void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
|
||||
{
|
||||
std::ofstream out;
|
||||
out.open(baseName, std::ios::binary | std::ios::out);
|
||||
@@ -4459,6 +4461,27 @@ void OutputSpv(const std::vector<unsigned int>& spirv, const char* baseName)
|
||||
out.close();
|
||||
}
|
||||
|
||||
// Write SPIR-V out to a text file with 32-bit hexadecimal words
|
||||
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName)
|
||||
{
|
||||
std::ofstream out;
|
||||
out.open(baseName, std::ios::binary | std::ios::out);
|
||||
out << "\t// " GLSLANG_REVISION " " GLSLANG_DATE << std::endl;
|
||||
const int WORDS_PER_LINE = 8;
|
||||
for (int i = 0; i < (int)spirv.size(); i += WORDS_PER_LINE) {
|
||||
out << "\t";
|
||||
for (int j = 0; j < WORDS_PER_LINE && i + j < (int)spirv.size(); ++j) {
|
||||
const unsigned int word = spirv[i + j];
|
||||
out << "0x" << std::hex << std::setw(8) << std::setfill('0') << word;
|
||||
if (i + j + 1 < (int)spirv.size()) {
|
||||
out << ",";
|
||||
}
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
|
||||
//
|
||||
// Set up the glslang traversal
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user