aboutsummaryrefslogtreecommitdiff
path: root/externals/sirit/src/instructions/constant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'externals/sirit/src/instructions/constant.cpp')
-rw-r--r--externals/sirit/src/instructions/constant.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/externals/sirit/src/instructions/constant.cpp b/externals/sirit/src/instructions/constant.cpp
new file mode 100644
index 0000000000..612049c4f8
--- /dev/null
+++ b/externals/sirit/src/instructions/constant.cpp
@@ -0,0 +1,48 @@
+/* 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 <cassert>
+
+#include "sirit/sirit.h"
+
+#include "stream.h"
+
+namespace Sirit {
+
+Id Module::ConstantTrue(Id result_type) {
+ declarations->Reserve(3);
+ return *declarations << OpId{spv::Op::OpConstantTrue, result_type} << EndOp{};
+}
+
+Id Module::ConstantFalse(Id result_type) {
+ declarations->Reserve(3);
+ return *declarations << OpId{spv::Op::OpConstantFalse, result_type} << EndOp{};
+}
+
+Id Module::Constant(Id result_type, const Literal& literal) {
+ declarations->Reserve(3 + 2);
+ return *declarations << OpId{spv::Op::OpConstant, result_type} << literal << EndOp{};
+}
+
+Id Module::ConstantComposite(Id result_type, std::span<const Id> constituents) {
+ declarations->Reserve(3 + constituents.size());
+ return *declarations << OpId{spv::Op::OpConstantComposite, result_type} << constituents
+ << EndOp{};
+}
+
+Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode,
+ bool normalized, spv::SamplerFilterMode filter_mode) {
+ declarations->Reserve(6);
+ return *declarations << OpId{spv::Op::OpConstantSampler, result_type} << addressing_mode
+ << normalized << filter_mode << EndOp{};
+}
+
+Id Module::ConstantNull(Id result_type) {
+ declarations->Reserve(3);
+ return *declarations << OpId{spv::Op::OpConstantNull, result_type} << EndOp{};
+}
+
+} // namespace Sirit