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-11-01 04:02:45 +01:00
|
|
|
#include "op.h"
|
2018-10-28 17:44:12 +01:00
|
|
|
#include "sirit/sirit.h"
|
|
|
|
|
#include <cassert>
|
2018-08-27 00:35:48 +02:00
|
|
|
|
|
|
|
|
namespace Sirit {
|
|
|
|
|
|
2018-11-01 02:20:49 +01:00
|
|
|
Id Module::OpConstantTrue(Id result_type) {
|
2018-11-01 04:02:45 +01:00
|
|
|
return AddDeclaration(
|
|
|
|
|
std::make_unique<Op>(spv::Op::OpConstantTrue, bound, result_type));
|
2018-08-27 00:35:48 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-01 02:20:49 +01:00
|
|
|
Id Module::OpConstantFalse(Id result_type) {
|
2018-11-01 04:02:45 +01:00
|
|
|
return AddDeclaration(
|
|
|
|
|
std::make_unique<Op>(spv::Op::OpConstantFalse, bound, result_type));
|
2018-08-27 00:35:48 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-01 02:20:49 +01:00
|
|
|
Id Module::OpConstant(Id result_type, const Literal& literal) {
|
2018-11-01 04:02:45 +01:00
|
|
|
auto op{std::make_unique<Op>(spv::Op::OpConstant, bound, result_type)};
|
2018-08-27 05:29:40 +02:00
|
|
|
op->Add(literal);
|
2018-11-01 04:02:45 +01:00
|
|
|
return AddDeclaration(std::move(op));
|
2018-08-27 05:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-01 02:20:49 +01:00
|
|
|
Id Module::OpConstantComposite(Id result_type,
|
2018-11-01 04:02:45 +01:00
|
|
|
const std::vector<Id>& constituents) {
|
|
|
|
|
auto op{
|
|
|
|
|
std::make_unique<Op>(spv::Op::OpConstantComposite, bound, result_type)};
|
2018-08-27 05:38:25 +02:00
|
|
|
op->Add(constituents);
|
2018-11-01 04:02:45 +01:00
|
|
|
return AddDeclaration(std::move(op));
|
2018-08-27 05:38:25 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-01 02:20:49 +01:00
|
|
|
Id Module::OpConstantSampler(Id result_type,
|
2018-11-01 04:02:45 +01:00
|
|
|
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-11-01 04:02:45 +01:00
|
|
|
auto op{
|
|
|
|
|
std::make_unique<Op>(spv::Op::OpConstantSampler, bound, result_type)};
|
|
|
|
|
op->Add(static_cast<u32>(addressing_mode));
|
2018-08-28 09:41:42 +02:00
|
|
|
op->Add(normalized ? 1 : 0);
|
2018-11-01 04:02:45 +01:00
|
|
|
op->Add(static_cast<u32>(filter_mode));
|
|
|
|
|
return AddDeclaration(std::move(op));
|
2018-08-28 09:41:42 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-01 02:20:49 +01:00
|
|
|
Id Module::OpConstantNull(Id result_type) {
|
2018-11-01 04:02:45 +01:00
|
|
|
return AddDeclaration(
|
|
|
|
|
std::make_unique<Op>(spv::Op::OpConstantNull, bound, result_type));
|
2018-08-28 09:46:18 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-27 00:35:48 +02:00
|
|
|
} // namespace Sirit
|