sirit/src/insts/constant.cpp

52 lines
1.7 KiB
C++
Raw Normal View History

2018-08-27 00:35:48 +02:00
/* This file is part of the sirit project.
* Copyright (c) 2018 ReinUsesLisp
* This software may be used and distributed according to the terms of the GNU
2018-08-27 04:28:39 +02:00
* Lesser General Public License version 2.1 or any later version.
2018-08-27 00:35:48 +02:00
*/
2018-08-28 09:05:47 +02:00
#include "insts.h"
#include "sirit/sirit.h"
#include <cassert>
2018-08-27 00:35:48 +02:00
namespace Sirit {
Ref Module::OpConstantTrue(Ref result_type) {
2018-08-27 00:35:48 +02:00
return AddDeclaration(new Op(spv::Op::OpConstantTrue, bound, result_type));
}
Ref Module::OpConstantFalse(Ref result_type) {
2018-08-27 00:35:48 +02:00
return AddDeclaration(new Op(spv::Op::OpConstantFalse, bound, result_type));
}
Ref Module::OpConstant(Ref result_type, const Literal& literal) {
2018-10-23 10:05:40 +02:00
auto op{new Op(spv::Op::OpConstant, bound, result_type)};
2018-08-27 05:29:40 +02:00
op->Add(literal);
return AddDeclaration(op);
}
Ref Module::OpConstantComposite(Ref result_type,
const std::vector<Ref>& constituents) {
2018-10-23 10:05:40 +02:00
auto op{new Op(spv::Op::OpConstantComposite, bound, result_type)};
2018-08-27 05:38:25 +02:00
op->Add(constituents);
return AddDeclaration(op);
}
Ref Module::OpConstantSampler(Ref result_type,
spv::SamplerAddressingMode addressing_mode,
bool normalized,
spv::SamplerFilterMode filter_mode) {
2018-08-28 09:41:42 +02:00
AddCapability(spv::Capability::LiteralSampler);
AddCapability(spv::Capability::Kernel);
2018-10-23 10:05:40 +02:00
auto op{new Op(spv::Op::OpConstantSampler, bound, result_type)};
2018-08-28 09:41:42 +02:00
AddEnum(op, addressing_mode);
op->Add(normalized ? 1 : 0);
AddEnum(op, filter_mode);
return AddDeclaration(op);
}
Ref Module::OpConstantNull(Ref result_type) {
2018-08-28 09:46:18 +02:00
return AddDeclaration(new Op(spv::Op::OpConstantNull, bound, result_type));
}
2018-08-27 00:35:48 +02:00
} // namespace Sirit