Add option to glslangValidator to inject preamble
This commit is contained in:
parent
1aefd184a6
commit
893145ead2
4 changed files with 84 additions and 4 deletions
|
|
@ -258,6 +258,17 @@ public:
|
|||
text.append("\n");
|
||||
}
|
||||
|
||||
void addText(std::string preambleText)
|
||||
{
|
||||
fixLine(preambleText);
|
||||
|
||||
Processes.push_back("preamble-text");
|
||||
Processes.back().append(preambleText);
|
||||
|
||||
text.append(preambleText);
|
||||
text.append("\n");
|
||||
}
|
||||
|
||||
protected:
|
||||
void fixLine(std::string& line)
|
||||
{
|
||||
|
|
@ -727,6 +738,13 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
|||
} else if (lowerword == "no-storage-format" || // synonyms
|
||||
lowerword == "nsf") {
|
||||
Options |= EOptionNoStorageFormat;
|
||||
} else if (lowerword == "preamble-text" ||
|
||||
lowerword == "p") {
|
||||
if (argc > 1)
|
||||
UserPreamble.addText(argv[1]);
|
||||
else
|
||||
Error("expects <text>", argv[0]);
|
||||
bumpArg();
|
||||
} else if (lowerword == "relaxed-errors") {
|
||||
Options |= EOptionRelaxedErrors;
|
||||
} else if (lowerword == "reflect-strict-array-suffix") {
|
||||
|
|
@ -926,6 +944,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
|
|||
else
|
||||
Error("unknown -O option");
|
||||
break;
|
||||
case 'P':
|
||||
UserPreamble.addText(getStringOperand("-P<text>"));
|
||||
break;
|
||||
case 'R':
|
||||
VulkanRulesRelaxed = true;
|
||||
break;
|
||||
|
|
@ -1832,7 +1853,7 @@ void CompileFile(const char* fileName, ShHandle compiler)
|
|||
SetMessageOptions(messages);
|
||||
|
||||
if (UserPreamble.isSet())
|
||||
Error("-D and -U options require -l (linking)\n");
|
||||
Error("-D, -U and -P options require -l (linking)\n");
|
||||
|
||||
for (int i = 0; i < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++i) {
|
||||
for (int j = 0; j < ((Options & EOptionMemoryLeakMode) ? 100 : 1); ++j) {
|
||||
|
|
@ -1902,6 +1923,8 @@ void usage()
|
|||
" is searched first, followed by left-to-right order of -I\n"
|
||||
" -Od disables optimization; may cause illegal SPIR-V for HLSL\n"
|
||||
" -Os optimizes SPIR-V to minimize size\n"
|
||||
" -P<text> | --preamble-text <text> | --P <text>\n"
|
||||
" inject custom preamble text\n"
|
||||
" -R use relaxed verification rules for generating Vulkan SPIR-V,\n"
|
||||
" allowing the use of default uniforms, atomic_uints, and\n"
|
||||
" gl_VertexID and gl_InstanceID keywords.\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue