Merge pull request #1034 from KhronosGroup/module-processes
SPV reflection: Add OpModuleProcessed for compile options.
This commit is contained in:
@@ -881,11 +881,30 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
|
||||
spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage());
|
||||
|
||||
builder.clearAccessChain();
|
||||
builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()), glslangIntermediate->getVersion());
|
||||
builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()),
|
||||
glslangIntermediate->getVersion());
|
||||
|
||||
if (options.generateDebugInfo) {
|
||||
builder.setSourceFile(glslangIntermediate->getSourceFile());
|
||||
builder.setSourceText(glslangIntermediate->getSourceText());
|
||||
builder.setEmitOpLines();
|
||||
builder.setSourceFile(glslangIntermediate->getSourceFile());
|
||||
|
||||
// Set the source shader's text. If for SPV version 1.0, include
|
||||
// a preamble in comments stating the OpModuleProcessed instructions.
|
||||
// Otherwise, emit those as actual instructions.
|
||||
std::string text;
|
||||
const std::vector<std::string>& processes = glslangIntermediate->getProcesses();
|
||||
for (int p = 0; p < (int)processes.size(); ++p) {
|
||||
if (glslangIntermediate->getSpv().spv < 0x00010100) {
|
||||
text.append("// OpModuleProcessed ");
|
||||
text.append(processes[p]);
|
||||
text.append("\n");
|
||||
} else
|
||||
builder.addModuleProcessed(processes[p]);
|
||||
}
|
||||
if (glslangIntermediate->getSpv().spv < 0x00010100 && (int)processes.size() > 0)
|
||||
text.append("#line 1\n");
|
||||
text.append(glslangIntermediate->getSourceText());
|
||||
builder.setSourceText(text);
|
||||
}
|
||||
stdBuiltins = builder.import("GLSL.std.450");
|
||||
builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
|
||||
|
||||
@@ -2430,6 +2430,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
|
||||
|
||||
// Debug instructions
|
||||
dumpInstructions(out, strings);
|
||||
dumpModuleProcesses(out);
|
||||
dumpSourceInstructions(out);
|
||||
for (int e = 0; e < (int)sourceExtensions.size(); ++e) {
|
||||
Instruction sourceExtInst(0, 0, OpSourceExtension);
|
||||
@@ -2637,4 +2638,15 @@ void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector
|
||||
}
|
||||
}
|
||||
|
||||
void Builder::dumpModuleProcesses(std::vector<unsigned int>& out) const
|
||||
{
|
||||
for (int i = 0; i < (int)moduleProcesses.size(); ++i) {
|
||||
// TODO: switch this out for the 1.1 headers
|
||||
const spv::Op OpModuleProcessed = (spv::Op)330;
|
||||
Instruction moduleProcessed(OpModuleProcessed);
|
||||
moduleProcessed.addStringOperand(moduleProcesses[i]);
|
||||
moduleProcessed.dump(out);
|
||||
}
|
||||
}
|
||||
|
||||
}; // end spv namespace
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
}
|
||||
void setSourceText(const std::string& text) { sourceText = text; }
|
||||
void addSourceExtension(const char* ext) { sourceExtensions.push_back(ext); }
|
||||
void addModuleProcessed(const std::string& p) { moduleProcesses.push_back(p.c_str()); }
|
||||
void setEmitOpLines() { emitOpLines = true; }
|
||||
void addExtension(const char* ext) { extensions.insert(ext); }
|
||||
Id import(const char*);
|
||||
@@ -582,6 +583,7 @@ public:
|
||||
void createSelectionMerge(Block* mergeBlock, unsigned int control);
|
||||
void dumpSourceInstructions(std::vector<unsigned int>&) const;
|
||||
void dumpInstructions(std::vector<unsigned int>&, const std::vector<std::unique_ptr<Instruction> >&) const;
|
||||
void dumpModuleProcesses(std::vector<unsigned int>&) const;
|
||||
|
||||
SourceLanguage source;
|
||||
int sourceVersion;
|
||||
@@ -591,6 +593,7 @@ public:
|
||||
bool emitOpLines;
|
||||
std::set<std::string> extensions;
|
||||
std::vector<const char*> sourceExtensions;
|
||||
std::vector<const char*> moduleProcesses;
|
||||
AddressingModel addressModel;
|
||||
MemoryModel memoryModel;
|
||||
std::set<spv::Capability> capabilities;
|
||||
|
||||
Reference in New Issue
Block a user