1 /* This file is part of the sirit project.
2 * Copyright (c) 2019 sirit
3 * This software may be used and distributed according to the terms of the
4 * 3-Clause BSD License
5 */
6
7 #include <cassert>
8 #include "op.h"
9 #include "sirit/sirit.h"
10
11 namespace Sirit {
12
ConstantTrue(Id result_type)13 Id Module::ConstantTrue(Id result_type) {
14 return AddDeclaration(std::make_unique<Op>(spv::Op::OpConstantTrue, bound, result_type));
15 }
16
ConstantFalse(Id result_type)17 Id Module::ConstantFalse(Id result_type) {
18 return AddDeclaration(std::make_unique<Op>(spv::Op::OpConstantFalse, bound, result_type));
19 }
20
Constant(Id result_type,const Literal & literal)21 Id Module::Constant(Id result_type, const Literal& literal) {
22 auto op{std::make_unique<Op>(spv::Op::OpConstant, bound, result_type)};
23 op->Add(literal);
24 return AddDeclaration(std::move(op));
25 }
26
ConstantComposite(Id result_type,const std::vector<Id> & constituents)27 Id Module::ConstantComposite(Id result_type, const std::vector<Id>& constituents) {
28 auto op{std::make_unique<Op>(spv::Op::OpConstantComposite, bound, result_type)};
29 op->Add(constituents);
30 return AddDeclaration(std::move(op));
31 }
32
ConstantSampler(Id result_type,spv::SamplerAddressingMode addressing_mode,bool normalized,spv::SamplerFilterMode filter_mode)33 Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode,
34 bool normalized, spv::SamplerFilterMode filter_mode) {
35 auto op{std::make_unique<Op>(spv::Op::OpConstantSampler, bound, result_type)};
36 op->Add(static_cast<u32>(addressing_mode));
37 op->Add(normalized ? 1 : 0);
38 op->Add(static_cast<u32>(filter_mode));
39 return AddDeclaration(std::move(op));
40 }
41
ConstantNull(Id result_type)42 Id Module::ConstantNull(Id result_type) {
43 return AddDeclaration(std::make_unique<Op>(spv::Op::OpConstantNull, bound, result_type));
44 }
45
46 } // namespace Sirit
47