allow renaming of shader entry point when creating SPIR-V

Use "--source-entrypoint name" on the command line, or the
TShader::setSourceEntryPoint(char*) API.

When the name given to the above interfaces is detected in the
shader source, it will be renamed to the entry point name supplied
to the -e option or the TShader::setEntryPoint() method.
This commit is contained in:
steve-lunarg
2016-10-31 15:13:43 -06:00
parent 8ce6e2ba49
commit f1e0c87127
9 changed files with 199 additions and 10 deletions

View File

@@ -160,6 +160,7 @@ int Options = 0;
const char* ExecutableName = nullptr;
const char* binaryFileName = nullptr;
const char* entryPointName = nullptr;
const char* sourceEntryPointName = nullptr;
const char* shaderStageName = nullptr;
std::array<unsigned int, EShLangCount> baseSamplerBinding;
@@ -300,6 +301,15 @@ void ProcessArguments(int argc, char* argv[])
} else if (lowerword == "no-storage-format" || // synonyms
lowerword == "nsf") {
Options |= EOptionNoStorageFormat;
} else if (lowerword == "source-entrypoint" || // synonyms
lowerword == "sep") {
sourceEntryPointName = argv[1];
if (argc > 0) {
argc--;
argv++;
} else
Error("no <entry-point> provided for --source-entrypoint");
break;
} else {
usage();
}
@@ -547,6 +557,8 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
shader->setStringsWithLengthsAndNames(compUnit.text, NULL, compUnit.fileNameList, 1);
if (entryPointName) // HLSL todo: this needs to be tracked per compUnits
shader->setEntryPoint(entryPointName);
if (sourceEntryPointName)
shader->setSourceEntryPoint(sourceEntryPointName);
shader->setShiftSamplerBinding(baseSamplerBinding[compUnit.stage]);
shader->setShiftTextureBinding(baseTextureBinding[compUnit.stage]);
@@ -963,6 +975,9 @@ void usage()
"\n"
" --no-storage-format use Unknown image format\n"
" --nsf synonym for --no-storage-format\n"
"\n"
" --source-entrypoint name the given shader source function is renamed to be the entry point given in -e\n"
" --sep synonym for --source-entrypoint\n"
);
exit(EFailUsage);