From e7971b445177d3a4b793def9c1479479371312c2 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Tue, 4 Dec 2018 21:30:32 -0300 Subject: [PATCH] Add OpExecutionMode --- include/sirit/sirit.h | 6 +++++- src/sirit.cpp | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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;