summaryrefslogtreecommitdiff
path: root/thirdparty/glslang/SPIRV/SPVRemapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/glslang/SPIRV/SPVRemapper.cpp')
-rw-r--r--thirdparty/glslang/SPIRV/SPVRemapper.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/thirdparty/glslang/SPIRV/SPVRemapper.cpp b/thirdparty/glslang/SPIRV/SPVRemapper.cpp
index fdfbeb90cd..6aca8cbcf0 100644
--- a/thirdparty/glslang/SPIRV/SPVRemapper.cpp
+++ b/thirdparty/glslang/SPIRV/SPVRemapper.cpp
@@ -160,15 +160,29 @@ namespace spv {
}
// Is this an opcode we should remove when using --strip?
- bool spirvbin_t::isStripOp(spv::Op opCode) const
+ bool spirvbin_t::isStripOp(spv::Op opCode, unsigned start) const
{
switch (opCode) {
case spv::OpSource:
case spv::OpSourceExtension:
case spv::OpName:
case spv::OpMemberName:
- case spv::OpLine: return true;
- default: return false;
+ case spv::OpLine :
+ {
+ const std::string name = literalString(start + 2);
+
+ std::vector<std::string>::const_iterator it;
+ for (it = stripWhiteList.begin(); it < stripWhiteList.end(); it++)
+ {
+ if (name.find(*it) != std::string::npos) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ default :
+ return false;
}
}
@@ -372,7 +386,7 @@ namespace spv {
process(
[&](spv::Op opCode, unsigned start) {
// remember opcodes we want to strip later
- if (isStripOp(opCode))
+ if (isStripOp(opCode, start))
stripInst(start);
return true;
},
@@ -1494,13 +1508,24 @@ namespace spv {
}
// remap from a memory image
- void spirvbin_t::remap(std::vector<std::uint32_t>& in_spv, std::uint32_t opts)
+ void spirvbin_t::remap(std::vector<std::uint32_t>& in_spv, const std::vector<std::string>& whiteListStrings,
+ std::uint32_t opts)
{
+ stripWhiteList = whiteListStrings;
spv.swap(in_spv);
remap(opts);
spv.swap(in_spv);
}
+ // remap from a memory image - legacy interface without white list
+ void spirvbin_t::remap(std::vector<std::uint32_t>& in_spv, std::uint32_t opts)
+ {
+ stripWhiteList.clear();
+ spv.swap(in_spv);
+ remap(opts);
+ spv.swap(in_spv);
+ }
+
} // namespace SPV
#endif // defined (use_cpp11)