2020-12-28 19:15:37 +04:00
|
|
|
/* 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>
|
2021-07-10 01:54:15 +04:00
|
|
|
|
2020-12-28 19:15:37 +04:00
|
|
|
#include "sirit/sirit.h"
|
|
|
|
|
2021-07-10 01:54:15 +04:00
|
|
|
#include "stream.h"
|
|
|
|
|
2020-12-28 19:15:37 +04:00
|
|
|
namespace Sirit {
|
|
|
|
|
|
|
|
Id Module::ConstantTrue(Id result_type) {
|
2021-07-10 01:54:15 +04:00
|
|
|
declarations->Reserve(3);
|
|
|
|
return *declarations << OpId{spv::Op::OpConstantTrue, result_type} << EndOp{};
|
2020-12-28 19:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Id Module::ConstantFalse(Id result_type) {
|
2021-07-10 01:54:15 +04:00
|
|
|
declarations->Reserve(3);
|
|
|
|
return *declarations << OpId{spv::Op::OpConstantFalse, result_type} << EndOp{};
|
2020-12-28 19:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Id Module::Constant(Id result_type, const Literal& literal) {
|
2021-07-10 01:54:15 +04:00
|
|
|
declarations->Reserve(3 + 2);
|
|
|
|
return *declarations << OpId{spv::Op::OpConstant, result_type} << literal << EndOp{};
|
2020-12-28 19:15:37 +04:00
|
|
|
}
|
|
|
|
|
2021-07-10 01:54:15 +04:00
|
|
|
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{};
|
2020-12-28 19:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode,
|
|
|
|
bool normalized, spv::SamplerFilterMode filter_mode) {
|
2021-07-10 01:54:15 +04:00
|
|
|
declarations->Reserve(6);
|
|
|
|
return *declarations << OpId{spv::Op::OpConstantSampler, result_type} << addressing_mode
|
|
|
|
<< normalized << filter_mode << EndOp{};
|
2020-12-28 19:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Id Module::ConstantNull(Id result_type) {
|
2021-07-10 01:54:15 +04:00
|
|
|
declarations->Reserve(3);
|
|
|
|
return *declarations << OpId{spv::Op::OpConstantNull, result_type} << EndOp{};
|
2020-12-28 19:15:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Sirit
|