diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index f8646b6..253e152 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -50,6 +50,10 @@ class Module { const std::string& name, const std::vector& interfaces = {}); + /// Declare an execution mode for an entry point. + void AddExecutionMode(Id entry_point, spv::ExecutionMode mode, + const std::vector& literals = {}); + /** * Adds an instruction to module's code * @param op Instruction to insert into code. Types and constants must not @@ -619,7 +623,7 @@ class Module { spv::MemoryModel memory_model{spv::MemoryModel::GLSL450}; std::vector> entry_points; - std::vector> execution_mode; + std::vector> execution_modes; std::vector> debug; std::vector> annotations; std::vector> declarations; diff --git a/src/sirit.cpp b/src/sirit.cpp index 89df604..e03fcdf 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -49,7 +49,7 @@ std::vector Module::Assemble() const { memory_model_ref.Write(stream); WriteSet(stream, entry_points); - // TODO write execution mode + WriteSet(stream, execution_modes); WriteSet(stream, debug); WriteSet(stream, annotations); WriteSet(stream, declarations); @@ -80,6 +80,15 @@ void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, entry_points.push_back(std::move(op)); } +void Module::AddExecutionMode(Id entry_point, spv::ExecutionMode mode, + const std::vector& literals) { + auto op{std::make_unique(spv::Op::OpExecutionMode)}; + op->Add(entry_point); + op->Add(static_cast(mode)); + op->Add(literals); + execution_modes.push_back(std::move(op)); +} + Id Module::Emit(Id op) { code.push_back(op); return op;