Add --no-link option
Adds the --no-link option which outputs the compiled shader binaries without linking them. This is a first step towards allowing users to create SPIR-v binary, non-executable libraries. When using the --no-link option, all functions are decorated with the Export linkage attribute.
This commit is contained in:
parent
a4aceb57de
commit
4c57db1595
24 changed files with 1671 additions and 1454 deletions
|
|
@ -248,36 +248,58 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (options().compileOnly)
|
||||
shader.setCompileOnly();
|
||||
|
||||
bool success = compile(
|
||||
&shader, code, entryPointName, controls, nullptr, &shaderName);
|
||||
|
||||
glslang::TProgram program;
|
||||
program.addShader(&shader);
|
||||
success &= program.link(controls);
|
||||
if (success)
|
||||
program.mapIO();
|
||||
spv::SpvBuildLogger logger;
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
spv::SpvBuildLogger logger;
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
if (!options().compileOnly) {
|
||||
program.addShader(&shader);
|
||||
success &= program.link(controls);
|
||||
if (success)
|
||||
program.mapIO();
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
options().disableOptimizer = !enableOptimizer;
|
||||
options().generateDebugInfo = enableDebug;
|
||||
options().emitNonSemanticShaderDebugInfo = enableNonSemanticShaderDebugInfo;
|
||||
options().emitNonSemanticShaderDebugSource = enableNonSemanticShaderDebugInfo;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage), spirv_binary, &logger, &options());
|
||||
} else {
|
||||
return {{
|
||||
{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},
|
||||
},
|
||||
program.getInfoLog(),
|
||||
program.getInfoDebugLog(),
|
||||
true,
|
||||
"",
|
||||
""};
|
||||
}
|
||||
} else {
|
||||
options().disableOptimizer = !enableOptimizer;
|
||||
options().generateDebugInfo = enableDebug;
|
||||
options().emitNonSemanticShaderDebugInfo = enableNonSemanticShaderDebugInfo;
|
||||
options().emitNonSemanticShaderDebugSource = enableNonSemanticShaderDebugInfo;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger, &options());
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
spv::Parameterize();
|
||||
spv::Disassemble(disassembly_stream, spirv_binary);
|
||||
bool validation_result = !options().validate || logger.getAllMessages().empty();
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(),
|
||||
validation_result, logger.getAllMessages(), disassembly_stream.str()};
|
||||
} else {
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
|
||||
glslang::GlslangToSpv(*shader.getIntermediate(), spirv_binary, &logger, &options());
|
||||
}
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
spv::Parameterize();
|
||||
spv::Disassemble(disassembly_stream, spirv_binary);
|
||||
bool validation_result = !options().validate || logger.getAllMessages().empty();
|
||||
return {{
|
||||
{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},
|
||||
},
|
||||
program.getInfoLog(),
|
||||
program.getInfoDebugLog(),
|
||||
validation_result,
|
||||
logger.getAllMessages(),
|
||||
disassembly_stream.str()};
|
||||
}
|
||||
|
||||
// Compiles and links the given source |code| of the given shader
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue