SPV: Turn off the default validation done by the SPIRV-Tools optimizer.

Also use the glslang namespace qualifier consistently and validate after
legalization, not before. (But most tests don't legalize.)
This commit is contained in:
John Kessenich
2018-08-30 16:56:59 -06:00
parent a4dfede4cc
commit 4e11b615db
2 changed files with 11 additions and 11 deletions

View File

@@ -6962,7 +6962,7 @@ void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName,
if (out.fail())
printf("ERROR: Failed to open file: %s\n", baseName);
out << "\t// " <<
glslang::GetSpirvGeneratorVersion() << "." << GLSLANG_MINOR_VERSION << "." << GLSLANG_PATCH_LEVEL <<
GetSpirvGeneratorVersion() << "." << GLSLANG_MINOR_VERSION << "." << GLSLANG_PATCH_LEVEL <<
std::endl;
if (varName != nullptr) {
out << "\t #pragma once" << std::endl;
@@ -6989,13 +6989,13 @@ void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName,
//
// Set up the glslang traversal
//
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv, SpvOptions* options)
void GlslangToSpv(const TIntermediate& intermediate, std::vector<unsigned int>& spirv, SpvOptions* options)
{
spv::SpvBuildLogger logger;
GlslangToSpv(intermediate, spirv, &logger, options);
}
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
void GlslangToSpv(const TIntermediate& intermediate, std::vector<unsigned int>& spirv,
spv::SpvBuildLogger* logger, SpvOptions* options)
{
TIntermNode* root = intermediate.getTreeRoot();
@@ -7003,11 +7003,11 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
if (root == 0)
return;
glslang::SpvOptions defaultOptions;
SpvOptions defaultOptions;
if (options == nullptr)
options = &defaultOptions;
glslang::GetThreadPoolAllocator().push();
GetThreadPoolAllocator().push();
TGlslangToSpvTraverser it(intermediate.getSpv().spv, &intermediate, logger, *options);
root->traverse(&it);
@@ -7015,20 +7015,20 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
it.dumpSpv(spirv);
#if ENABLE_OPT
if (options->validate)
SpirvToolsValidate(intermediate, spirv, logger);
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
// eg. forward and remove memory writes of opaque types.
if ((intermediate.getSource() == EShSourceHlsl || options->optimizeSize) && !options->disableOptimizer)
SpirvToolsLegalize(intermediate, spirv, logger, options);
if (options->validate)
SpirvToolsValidate(intermediate, spirv, logger);
if (options->disassemble)
glslang::SpirvToolsDisassemble(std::cout, spirv);
SpirvToolsDisassemble(std::cout, spirv);
#endif
glslang::GetThreadPoolAllocator().pop();
GetThreadPoolAllocator().pop();
}
}; // end namespace glslang

View File

@@ -180,7 +180,7 @@ void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector<
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass());
optimizer.RegisterPass(spvtools::CreateCFGCleanupPass());
optimizer.Run(spirv.data(), spirv.size(), &spirv);
optimizer.Run(spirv.data(), spirv.size(), &spirv, spvtools::ValidatorOptions(), true);
}
#endif