SPV: Add OpSource shader source code and file name.

This commit is contained in:
John Kessenich
2017-05-31 17:11:16 -06:00
parent 136b1e2d5d
commit 121853f4df
12 changed files with 243 additions and 22 deletions

View File

@@ -91,6 +91,7 @@ enum TOptions {
EOptionHlslOffsets = (1 << 23),
EOptionHlslIoMapping = (1 << 24),
EOptionAutoMapLocations = (1 << 25),
EOptionDebug = (1 << 26),
};
//
@@ -448,6 +449,9 @@ void ProcessArguments(std::vector<std::unique_ptr<glslang::TWorkItem>>& workItem
} else
Error("no <entry-point> provided for -e");
break;
case 'g':
Options |= EOptionDebug;
break;
case 'h':
usage();
break;
@@ -539,6 +543,8 @@ void SetMessageOptions(EShMessages& messages)
messages = (EShMessages)(messages | EShMsgKeepUncalled);
if (Options & EOptionHlslOffsets)
messages = (EShMessages)(messages | EShMsgHlslOffsets);
if (Options & EOptionDebug)
messages = (EShMessages)(messages | EShMsgDebugInfo);
}
//
@@ -722,7 +728,10 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
std::vector<unsigned int> spirv;
std::string warningsErrors;
spv::SpvBuildLogger logger;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage), spirv, &logger);
glslang::SpvOptions spvOptions;
if (Options & EOptionDebug)
spvOptions.generateDebugInfo = true;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage), spirv, &logger, &spvOptions);
// Dump the spv to a file or stdout, etc., but only if not doing
// memory/perf testing, as it's not internal to programmatic use.
@@ -1031,6 +1040,7 @@ void usage()
" (default is ES version 100)\n"
" -D input is HLSL\n"
" -e specify entry-point name\n"
" -g generate debug information\n"
" -h print this usage message\n"
" -i intermediate tree (glslang AST) is printed out\n"
" -l link all input files together to form a single module\n"