1
0
Fork 0
mirror of https://git.suyu.dev/suyu/sirit.git synced 2024-12-22 20:22:02 +00:00

Add OpExtension

This commit is contained in:
ReinUsesLisp 2019-03-08 21:09:11 -03:00
parent 2b0a59d890
commit b23716087a
2 changed files with 16 additions and 1 deletions

View file

@ -11,6 +11,7 @@
#include <optional> #include <optional>
#include <set> #include <set>
#include <spirv/unified1/spirv.hpp11> #include <spirv/unified1/spirv.hpp11>
#include <string>
#include <variant> #include <variant>
#include <vector> #include <vector>
@ -38,6 +39,9 @@ class Module {
*/ */
std::vector<std::uint8_t> Assemble() const; std::vector<std::uint8_t> Assemble() const;
/// Adds a SPIR-V extension.
void AddExtension(const std::string& extension_name);
/// Adds a module capability. /// Adds a module capability.
void AddCapability(spv::Capability capability); void AddCapability(spv::Capability capability);
@ -620,6 +624,7 @@ class Module {
std::uint32_t bound{1}; std::uint32_t bound{1};
std::set<std::string> extensions;
std::set<spv::Capability> capabilities; std::set<spv::Capability> capabilities;
std::unique_ptr<Op> glsl_std_450; std::unique_ptr<Op> glsl_std_450;
std::set<std::unique_ptr<Op>> ext_inst_import; std::set<std::unique_ptr<Op>> ext_inst_import;

View file

@ -38,10 +38,16 @@ std::vector<u8> Module::Assemble() const {
op.Add(static_cast<u32>(capability)); op.Add(static_cast<u32>(capability));
op.Write(stream); 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) { if (glsl_std_450) {
glsl_std_450->Write(stream); glsl_std_450->Write(stream);
} }
// TODO write ext inst imports
Op memory_model_ref{spv::Op::OpMemoryModel}; Op memory_model_ref{spv::Op::OpMemoryModel};
memory_model_ref.Add(static_cast<u32>(addressing_model)); memory_model_ref.Add(static_cast<u32>(addressing_model));
@ -59,6 +65,10 @@ std::vector<u8> Module::Assemble() const {
return bytes; return bytes;
} }
void Module::AddExtension(const std::string& extension_name) {
extensions.insert(extension_name);
}
void Module::AddCapability(spv::Capability capability) { void Module::AddCapability(spv::Capability capability) {
capabilities.insert(capability); capabilities.insert(capability);
} }