Commit 8842c8f4 by Ben Clayton

SpirvShader: 2-way imported extensions lookup

The `extensions` map of ID -> extension has been renamed to `extensionsByID`. The `extensionsImported` is a new set containing the list of extension names that have been imported. This set can be efficiently queried to determine whether a particular extension is in use. Bug: b/145351270 Change-Id: I74bbfb2e5b95862c5381037f259262a9d45b6624 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40092Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent c25e4d35
......@@ -442,7 +442,8 @@ SpirvShader::SpirvShader(
UNSUPPORTED("SPIR-V Extension: %s", name);
break;
}
extensions.emplace(id, ext);
extensionsByID.emplace(id, ext);
extensionsImported.emplace(ext.name);
break;
}
case spv::OpName:
......
......@@ -748,7 +748,8 @@ private:
HandleMap<Object> defs;
HandleMap<Function> functions;
std::unordered_map<StringID, String> strings;
HandleMap<Extension> extensions;
HandleMap<Extension> extensionsByID;
std::unordered_set<Extension::Name> extensionsImported;
Function::ID entryPoint;
const bool robustBufferAccess = true;
......@@ -1031,8 +1032,8 @@ private:
Extension const &getExtension(Extension::ID id) const
{
auto it = extensions.find(id);
ASSERT_MSG(it != extensions.end(), "Unknown extension %d", id.value());
auto it = extensionsByID.find(id);
ASSERT_MSG(it != extensionsByID.end(), "Unknown extension %d", id.value());
return it->second;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment