From 12f40a80324d7c154f19f25c448a5ce27d38cd18 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 9 Dec 2019 21:44:36 -0300 Subject: [PATCH] Add OpMemoryBarrier --- include/sirit/sirit.h | 5 +++++ src/CMakeLists.txt | 1 + src/instructions/barrier.cpp | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/instructions/barrier.cpp diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index aa6b976..a6d267d 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -364,6 +364,11 @@ public: /// Finish the current primitive and start a new one. No vertex is emitted. Id OpEndPrimitive(); + // Barrier + + /// Control the order that memory accesses are observed. + Id OpMemoryBarrier(Id scope, Id semantics); + // Logical /// Result is true if any component of Vector is true, otherwise result is false. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1a632a..1bcb6e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,7 @@ add_library(sirit instructions/extension.cpp instructions/image.cpp instructions/group.cpp + instructions/barrier.cpp ) target_compile_options(sirit PRIVATE ${SIRIT_CXX_FLAGS}) diff --git a/src/instructions/barrier.cpp b/src/instructions/barrier.cpp new file mode 100644 index 0000000..8f91c8a --- /dev/null +++ b/src/instructions/barrier.cpp @@ -0,0 +1,20 @@ +/* This file is part of the sirit project. + * Copyright (c) 2019 sirit + * This software may be used and distributed according to the terms of the + * 3-Clause BSD License + */ + +#include +#include "op.h" +#include "sirit/sirit.h" + +namespace Sirit { + +Id Module::OpMemoryBarrier(Id scope, Id semantics) { + auto op = std::make_unique(spv::Op::OpMemoryBarrier); + op->Add(scope); + op->Add(semantics); + return AddCode(std::move(op)); +} + +} // namespace Sirit