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:
parent
a4dfede4cc
commit
4e11b615db
2 changed files with 11 additions and 11 deletions
|
|
@ -6962,7 +6962,7 @@ void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName,
|
||||||
if (out.fail())
|
if (out.fail())
|
||||||
printf("ERROR: Failed to open file: %s\n", baseName);
|
printf("ERROR: Failed to open file: %s\n", baseName);
|
||||||
out << "\t// " <<
|
out << "\t// " <<
|
||||||
glslang::GetSpirvGeneratorVersion() << "." << GLSLANG_MINOR_VERSION << "." << GLSLANG_PATCH_LEVEL <<
|
GetSpirvGeneratorVersion() << "." << GLSLANG_MINOR_VERSION << "." << GLSLANG_PATCH_LEVEL <<
|
||||||
std::endl;
|
std::endl;
|
||||||
if (varName != nullptr) {
|
if (varName != nullptr) {
|
||||||
out << "\t #pragma once" << std::endl;
|
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
|
// 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;
|
spv::SpvBuildLogger logger;
|
||||||
GlslangToSpv(intermediate, spirv, &logger, options);
|
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)
|
spv::SpvBuildLogger* logger, SpvOptions* options)
|
||||||
{
|
{
|
||||||
TIntermNode* root = intermediate.getTreeRoot();
|
TIntermNode* root = intermediate.getTreeRoot();
|
||||||
|
|
@ -7003,11 +7003,11 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
|
||||||
if (root == 0)
|
if (root == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glslang::SpvOptions defaultOptions;
|
SpvOptions defaultOptions;
|
||||||
if (options == nullptr)
|
if (options == nullptr)
|
||||||
options = &defaultOptions;
|
options = &defaultOptions;
|
||||||
|
|
||||||
glslang::GetThreadPoolAllocator().push();
|
GetThreadPoolAllocator().push();
|
||||||
|
|
||||||
TGlslangToSpvTraverser it(intermediate.getSpv().spv, &intermediate, logger, *options);
|
TGlslangToSpvTraverser it(intermediate.getSpv().spv, &intermediate, logger, *options);
|
||||||
root->traverse(&it);
|
root->traverse(&it);
|
||||||
|
|
@ -7015,20 +7015,20 @@ void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsign
|
||||||
it.dumpSpv(spirv);
|
it.dumpSpv(spirv);
|
||||||
|
|
||||||
#if ENABLE_OPT
|
#if ENABLE_OPT
|
||||||
if (options->validate)
|
|
||||||
SpirvToolsValidate(intermediate, spirv, logger);
|
|
||||||
|
|
||||||
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
|
// If from HLSL, run spirv-opt to "legalize" the SPIR-V for Vulkan
|
||||||
// eg. forward and remove memory writes of opaque types.
|
// eg. forward and remove memory writes of opaque types.
|
||||||
if ((intermediate.getSource() == EShSourceHlsl || options->optimizeSize) && !options->disableOptimizer)
|
if ((intermediate.getSource() == EShSourceHlsl || options->optimizeSize) && !options->disableOptimizer)
|
||||||
SpirvToolsLegalize(intermediate, spirv, logger, options);
|
SpirvToolsLegalize(intermediate, spirv, logger, options);
|
||||||
|
|
||||||
|
if (options->validate)
|
||||||
|
SpirvToolsValidate(intermediate, spirv, logger);
|
||||||
|
|
||||||
if (options->disassemble)
|
if (options->disassemble)
|
||||||
glslang::SpirvToolsDisassemble(std::cout, spirv);
|
SpirvToolsDisassemble(std::cout, spirv);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glslang::GetThreadPoolAllocator().pop();
|
GetThreadPoolAllocator().pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end namespace glslang
|
}; // end namespace glslang
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector<
|
||||||
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass());
|
optimizer.RegisterPass(spvtools::CreateAggressiveDCEPass());
|
||||||
optimizer.RegisterPass(spvtools::CreateCFGCleanupPass());
|
optimizer.RegisterPass(spvtools::CreateCFGCleanupPass());
|
||||||
|
|
||||||
optimizer.Run(spirv.data(), spirv.size(), &spirv);
|
optimizer.Run(spirv.data(), spirv.size(), &spirv, spvtools::ValidatorOptions(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue