diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 1a0def9..71f8699 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -920,6 +920,15 @@ public: Id OpImageQuerySamples(Id result_type, Id image); private: + struct HashOp { + std::size_t operator()(const std::unique_ptr& op) const noexcept; + }; + + struct EqualOp { + bool operator()(const std::unique_ptr& lhs, const std::unique_ptr& rhs) const + noexcept; + }; + Id AddCode(std::unique_ptr op); Id AddCode(spv::Op opcode, std::optional id = {}); @@ -945,7 +954,7 @@ private: std::vector> execution_modes; std::vector> debug; std::vector> annotations; - std::unordered_set> declarations; + std::unordered_set, HashOp, EqualOp> declarations; std::vector sorted_declarations; std::vector global_variables; diff --git a/src/sirit.cpp b/src/sirit.cpp index 50135e3..f65e9a5 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -20,6 +20,15 @@ static void WriteSet(Stream& stream, const T& set) { } } +std::size_t Module::HashOp::operator()(const std::unique_ptr& op) const noexcept { + return op->Hash(); +} + +bool Module::EqualOp::operator()(const std::unique_ptr& lhs, + const std::unique_ptr& rhs) const noexcept { + return *lhs == *rhs; +} + Module::Module(u32 version) : version(version) {} Module::~Module() = default;