diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index eded07e..4119a5f 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,9 @@ class Module { */ std::vector Assemble() const; + /// Adds a SPIR-V extension. + void AddExtension(const std::string& extension_name); + /// Adds a module capability. void AddCapability(spv::Capability capability); @@ -620,6 +624,7 @@ class Module { std::uint32_t bound{1}; + std::set extensions; std::set capabilities; std::unique_ptr glsl_std_450; std::set> ext_inst_import; diff --git a/src/sirit.cpp b/src/sirit.cpp index e03fcdf..9112a80 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -38,10 +38,16 @@ std::vector Module::Assemble() const { op.Add(static_cast(capability)); op.Write(stream); } + + for (const auto& extension_name : extensions) { + Op op(spv::Op::OpExtension); + op.Add(extension_name); + op.Write(stream); + } + if (glsl_std_450) { glsl_std_450->Write(stream); } - // TODO write ext inst imports Op memory_model_ref{spv::Op::OpMemoryModel}; memory_model_ref.Add(static_cast(addressing_model)); @@ -59,6 +65,10 @@ std::vector Module::Assemble() const { return bytes; } +void Module::AddExtension(const std::string& extension_name) { + extensions.insert(extension_name); +} + void Module::AddCapability(spv::Capability capability) { capabilities.insert(capability); }