summaryrefslogtreecommitdiff
path: root/spirv_parser.cpp
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2019-01-10 14:04:01 +0100
committerHans-Kristian Arntzen <post@arntzen-software.no>2019-01-10 14:04:01 +0100
commitb629878f45ae4eead5dcccdc20e3eb52c25ba4fd (patch)
tree900b1c485506c314bda5464b60fdb4e6463ba2ff /spirv_parser.cpp
parentd92de00cc182a436f4c0340247bde088eee2c921 (diff)
downloadSPIRV-Cross-b629878f45ae4eead5dcccdc20e3eb52c25ba4fd.tar.gz
SPIRV-Cross-b629878f45ae4eead5dcccdc20e3eb52c25ba4fd.tar.bz2
SPIRV-Cross-b629878f45ae4eead5dcccdc20e3eb52c25ba4fd.zip
Make meta a hashmap.
A flat array was consuming way too much memory and was far too slow to initialize properly with a very large ID bound (8 million IDs, showed up as #1 hotspot in perf). Meta struct does not have to be in-order as we never iterate over it in a meaningful way, so using a hashmap here is reasonable. Very few IDs should need decorations or meta-data, so this should also be a quite decent memory save. For the pathological case, a 6x uplift was observed.
Diffstat (limited to 'spirv_parser.cpp')
-rw-r--r--spirv_parser.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/spirv_parser.cpp b/spirv_parser.cpp
index 205305dd..2f76144e 100644
--- a/spirv_parser.cpp
+++ b/spirv_parser.cpp
@@ -1063,8 +1063,11 @@ bool Parser::types_are_logically_equivalent(const SPIRType &a, const SPIRType &b
bool Parser::variable_storage_is_aliased(const SPIRVariable &v) const
{
auto &type = get<SPIRType>(v.basetype);
+
+ auto *type_meta = ir.find_meta(type.self);
+
bool ssbo = v.storage == StorageClassStorageBuffer ||
- ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock);
+ (type_meta && type_meta->decoration.decoration_flags.get(DecorationBufferBlock));
bool image = type.basetype == SPIRType::Image;
bool counter = type.basetype == SPIRType::AtomicCounter;