Add Op* prefix to instructions that have to be emited

This commit is contained in:
ReinUsesLisp 2018-10-31 21:22:00 -03:00
parent ba3a3a74d7
commit a08aeec982
15 changed files with 149 additions and 144 deletions

View file

@ -68,154 +68,154 @@ class Module {
// Types
/// Returns type void.
Ref TypeVoid();
Ref OpTypeVoid();
/// Returns type bool.
Ref TypeBool();
Ref OpTypeBool();
/// Returns type integer.
Ref TypeInt(int width, bool is_signed);
Ref OpTypeInt(int width, bool is_signed);
/// Returns type float.
Ref TypeFloat(int width);
Ref OpTypeFloat(int width);
/// Returns type vector.
Ref TypeVector(Ref component_type, int component_count);
Ref OpTypeVector(Ref component_type, int component_count);
/// Returns type matrix.
Ref TypeMatrix(Ref column_type, int column_count);
Ref OpTypeMatrix(Ref column_type, int column_count);
/// Returns type image.
Ref TypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed,
bool ms, int sampled, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier = {});
Ref OpTypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed,
bool ms, int sampled, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier = {});
/// Returns type sampler.
Ref TypeSampler();
Ref OpTypeSampler();
/// Returns type sampled image.
Ref TypeSampledImage(Ref image_type);
Ref OpTypeSampledImage(Ref image_type);
/// Returns type array.
Ref TypeArray(Ref element_type, Ref length);
Ref OpTypeArray(Ref element_type, Ref length);
/// Returns type runtime array.
Ref TypeRuntimeArray(Ref element_type);
Ref OpTypeRuntimeArray(Ref element_type);
/// Returns type struct.
Ref TypeStruct(const std::vector<Ref>& members = {});
Ref OpTypeStruct(const std::vector<Ref>& members = {});
/// Returns type opaque.
Ref TypeOpaque(const std::string& name);
Ref OpTypeOpaque(const std::string& name);
/// Returns type pointer.
Ref TypePointer(spv::StorageClass storage_class, Ref type);
Ref OpTypePointer(spv::StorageClass storage_class, Ref type);
/// Returns type function.
Ref TypeFunction(Ref return_type, const std::vector<Ref>& arguments = {});
Ref OpTypeFunction(Ref return_type, const std::vector<Ref>& arguments = {});
/// Returns type event.
Ref TypeEvent();
Ref OpTypeEvent();
/// Returns type device event.
Ref TypeDeviceEvent();
Ref OpTypeDeviceEvent();
/// Returns type reserve id.
Ref TypeReserveId();
Ref OpTypeReserveId();
/// Returns type queue.
Ref TypeQueue();
Ref OpTypeQueue();
/// Returns type pipe.
Ref TypePipe(spv::AccessQualifier access_qualifier);
Ref OpTypePipe(spv::AccessQualifier access_qualifier);
// Constant
/// Returns a true scalar constant.
Ref ConstantTrue(Ref result_type);
Ref OpConstantTrue(Ref result_type);
/// Returns a false scalar constant.
Ref ConstantFalse(Ref result_type);
Ref OpConstantFalse(Ref result_type);
/// Returns a numeric scalar constant.
Ref Constant(Ref result_type, const Literal& literal);
Ref OpConstant(Ref result_type, const Literal& literal);
/// Returns a numeric scalar constant.
Ref ConstantComposite(Ref result_type,
const std::vector<Ref>& constituents);
Ref OpConstantComposite(Ref result_type,
const std::vector<Ref>& constituents);
/// Returns a sampler constant.
Ref ConstantSampler(Ref result_type,
spv::SamplerAddressingMode addressing_mode,
bool normalized, spv::SamplerFilterMode filter_mode);
Ref OpConstantSampler(Ref result_type,
spv::SamplerAddressingMode addressing_mode,
bool normalized, spv::SamplerFilterMode filter_mode);
/// Returns a null constant value.
Ref ConstantNull(Ref result_type);
Ref OpConstantNull(Ref result_type);
// Function
/// Declares a function.
Ref Function(Ref result_type, spv::FunctionControlMask function_control,
Ref function_type);
Ref OpFunction(Ref result_type, spv::FunctionControlMask function_control,
Ref function_type);
/// Ends a function.
Ref FunctionEnd();
Ref OpFunctionEnd();
// Flow
/// Declare a structured loop.
Ref LoopMerge(Ref merge_block, Ref continue_target,
spv::LoopControlMask loop_control,
const std::vector<Ref>& literals = {});
Ref OpLoopMerge(Ref merge_block, Ref continue_target,
spv::LoopControlMask loop_control,
const std::vector<Ref>& literals = {});
/// Declare a structured selection.
Ref SelectionMerge(Ref merge_block,
spv::SelectionControlMask selection_control);
Ref OpSelectionMerge(Ref merge_block,
spv::SelectionControlMask selection_control);
/// The block label instruction: Any reference to a block is through this
/// ref.
Ref Label();
Ref OpLabel();
/// Unconditional jump to label.
Ref Branch(Ref target_label);
Ref OpBranch(Ref target_label);
/// If condition is true branch to true_label, otherwise branch to
/// false_label.
Ref BranchConditional(Ref condition, Ref true_label, Ref false_label,
std::uint32_t true_weight = 0,
std::uint32_t false_weight = 0);
Ref OpBranchConditional(Ref condition, Ref true_label, Ref false_label,
std::uint32_t true_weight = 0,
std::uint32_t false_weight = 0);
/// Returns with no value from a function with void return type.
Ref Return();
Ref OpReturn();
// Debug
/// Assign a name string to a reference.
/// @return target
Ref Name(Ref target, const std::string& name);
Ref OpName(Ref target, const std::string& name);
// Memory
/// Allocate an object in memory, resulting in a copy to it.
Ref Variable(Ref result_type, spv::StorageClass storage_class,
Ref initializer = nullptr);
Ref OpVariable(Ref result_type, spv::StorageClass storage_class,
Ref initializer = nullptr);
/// Load through a pointer.
Ref Load(Ref result_type, Ref pointer,
std::optional<spv::MemoryAccessMask> memory_access = {});
Ref OpLoad(Ref result_type, Ref pointer,
std::optional<spv::MemoryAccessMask> memory_access = {});
/// Store through a pointer.
Ref Store(Ref pointer, Ref object,
std::optional<spv::MemoryAccessMask> memory_access = {});
Ref OpStore(Ref pointer, Ref object,
std::optional<spv::MemoryAccessMask> memory_access = {});
/// Create a pointer into a composite object that can be used with OpLoad
/// and OpStore.
Ref AccessChain(Ref result_type, Ref base,
const std::vector<Ref>& indexes = {});
Ref OpAccessChain(Ref result_type, Ref base,
const std::vector<Ref>& indexes = {});
/// Make a copy of a composite object, while modifying one part of it.
Ref CompositeInsert(Ref result_type, Ref object, Ref composite,
const std::vector<Literal>& indexes = {});
Ref OpCompositeInsert(Ref result_type, Ref object, Ref composite,
const std::vector<Literal>& indexes = {});
// Annotation
@ -230,7 +230,7 @@ class Module {
// Misc
/// Make an intermediate object whose value is undefined.
Ref Undef(Ref result_type);
Ref OpUndef(Ref result_type);
private:
Ref AddCode(Op* op);

View file

@ -7,10 +7,10 @@ add_library(sirit
stream.h
operand.cpp
operand.h
literal-number.cpp
literal-number.h
literal-string.cpp
literal-string.h
literal_number.cpp
literal_number.h
literal_string.cpp
literal_string.h
common_types.h
insts.h
insts/type.cpp

View file

@ -10,31 +10,31 @@
namespace Sirit {
Ref Module::ConstantTrue(Ref result_type) {
Ref Module::OpConstantTrue(Ref result_type) {
return AddDeclaration(new Op(spv::Op::OpConstantTrue, bound, result_type));
}
Ref Module::ConstantFalse(Ref result_type) {
Ref Module::OpConstantFalse(Ref result_type) {
return AddDeclaration(new Op(spv::Op::OpConstantFalse, bound, result_type));
}
Ref Module::Constant(Ref result_type, const Literal& literal) {
Ref Module::OpConstant(Ref result_type, const Literal& literal) {
auto op{new Op(spv::Op::OpConstant, bound, result_type)};
op->Add(literal);
return AddDeclaration(op);
}
Ref Module::ConstantComposite(Ref result_type,
const std::vector<Ref>& constituents) {
Ref Module::OpConstantComposite(Ref result_type,
const std::vector<Ref>& constituents) {
auto op{new Op(spv::Op::OpConstantComposite, bound, result_type)};
op->Add(constituents);
return AddDeclaration(op);
}
Ref Module::ConstantSampler(Ref result_type,
spv::SamplerAddressingMode addressing_mode,
bool normalized,
spv::SamplerFilterMode filter_mode) {
Ref Module::OpConstantSampler(Ref result_type,
spv::SamplerAddressingMode addressing_mode,
bool normalized,
spv::SamplerFilterMode filter_mode) {
AddCapability(spv::Capability::LiteralSampler);
AddCapability(spv::Capability::Kernel);
auto op{new Op(spv::Op::OpConstantSampler, bound, result_type)};
@ -44,7 +44,7 @@ Ref Module::ConstantSampler(Ref result_type,
return AddDeclaration(op);
}
Ref Module::ConstantNull(Ref result_type) {
Ref Module::OpConstantNull(Ref result_type) {
return AddDeclaration(new Op(spv::Op::OpConstantNull, bound, result_type));
}

View file

@ -9,7 +9,7 @@
namespace Sirit {
Ref Module::Name(Ref target, const std::string& name) {
Ref Module::OpName(Ref target, const std::string& name) {
auto op{new Op(spv::Op::OpName)};
op->Add(target);
op->Add(name);

View file

@ -9,9 +9,9 @@
namespace Sirit {
Ref Module::LoopMerge(Ref merge_block, Ref continue_target,
spv::LoopControlMask loop_control,
const std::vector<Ref>& literals) {
Ref Module::OpLoopMerge(Ref merge_block, Ref continue_target,
spv::LoopControlMask loop_control,
const std::vector<Ref>& literals) {
auto op{new Op(spv::Op::OpLoopMerge)};
op->Add(merge_block);
op->Add(continue_target);
@ -20,25 +20,25 @@ Ref Module::LoopMerge(Ref merge_block, Ref continue_target,
return AddCode(op);
}
Ref Module::SelectionMerge(Ref merge_block,
spv::SelectionControlMask selection_control) {
Ref Module::OpSelectionMerge(Ref merge_block,
spv::SelectionControlMask selection_control) {
auto op{new Op(spv::Op::OpSelectionMerge)};
op->Add(merge_block);
AddEnum(op, selection_control);
return AddCode(op);
}
Ref Module::Label() { return AddCode(spv::Op::OpLabel, bound++); }
Ref Module::OpLabel() { return AddCode(spv::Op::OpLabel, bound++); }
Ref Module::Branch(Ref target_label) {
Ref Module::OpBranch(Ref target_label) {
auto op{new Op(spv::Op::OpBranch)};
op->Add(target_label);
return AddCode(op);
}
Ref Module::BranchConditional(Ref condition, Ref true_label, Ref false_label,
std::uint32_t true_weight,
std::uint32_t false_weight) {
Ref Module::OpBranchConditional(Ref condition, Ref true_label, Ref false_label,
std::uint32_t true_weight,
std::uint32_t false_weight) {
auto op{new Op(spv::Op::OpBranchConditional)};
op->Add(condition);
op->Add(true_label);
@ -50,6 +50,6 @@ Ref Module::BranchConditional(Ref condition, Ref true_label, Ref false_label,
return AddCode(op);
}
Ref Module::Return() { return AddCode(spv::Op::OpReturn); }
Ref Module::OpReturn() { return AddCode(spv::Op::OpReturn); }
} // namespace Sirit

View file

@ -9,14 +9,15 @@
namespace Sirit {
Ref Module::Function(Ref result_type, spv::FunctionControlMask function_control,
Ref function_type) {
Ref Module::OpFunction(Ref result_type,
spv::FunctionControlMask function_control,
Ref function_type) {
auto op{new Op{spv::Op::OpFunction, bound++, result_type}};
op->Add(static_cast<u32>(function_control));
op->Add(function_type);
return AddCode(op);
}
Ref Module::FunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); }
Ref Module::OpFunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); }
} // namespace Sirit

View file

@ -10,8 +10,8 @@
namespace Sirit {
Ref Module::Variable(Ref result_type, spv::StorageClass storage_class,
Ref initializer) {
Ref Module::OpVariable(Ref result_type, spv::StorageClass storage_class,
Ref initializer) {
auto op{new Op(spv::Op::OpVariable, bound++, result_type)};
AddEnum(op, storage_class);
if (initializer) {
@ -20,8 +20,8 @@ Ref Module::Variable(Ref result_type, spv::StorageClass storage_class,
return AddCode(op);
}
Ref Module::Load(Ref result_type, Ref pointer,
std::optional<spv::MemoryAccessMask> memory_access) {
Ref Module::OpLoad(Ref result_type, Ref pointer,
std::optional<spv::MemoryAccessMask> memory_access) {
auto op{new Op(spv::Op::OpLoad, bound++, result_type)};
op->Add(pointer);
if (memory_access) {
@ -30,8 +30,8 @@ Ref Module::Load(Ref result_type, Ref pointer,
return AddCode(op);
}
Ref Module::Store(Ref pointer, Ref object,
std::optional<spv::MemoryAccessMask> memory_access) {
Ref Module::OpStore(Ref pointer, Ref object,
std::optional<spv::MemoryAccessMask> memory_access) {
auto op{new Op(spv::Op::OpStore)};
op->Add(pointer);
op->Add(object);
@ -41,8 +41,8 @@ Ref Module::Store(Ref pointer, Ref object,
return AddCode(op);
}
Ref Module::AccessChain(Ref result_type, Ref base,
const std::vector<Ref>& indexes) {
Ref Module::OpAccessChain(Ref result_type, Ref base,
const std::vector<Ref>& indexes) {
assert(indexes.size() > 0);
auto op{new Op(spv::Op::OpAccessChain, bound++, result_type)};
op->Add(base);
@ -50,8 +50,8 @@ Ref Module::AccessChain(Ref result_type, Ref base,
return AddCode(op);
}
Ref Module::CompositeInsert(Ref result_type, Ref object, Ref composite,
const std::vector<Literal>& indexes) {
Ref Module::OpCompositeInsert(Ref result_type, Ref object, Ref composite,
const std::vector<Literal>& indexes) {
auto op{new Op(spv::Op::OpCompositeInsert, bound++, result_type)};
op->Add(object);
op->Add(composite);

View file

@ -10,7 +10,7 @@
namespace Sirit {
Ref Module::Undef(Ref result_type) {
Ref Module::OpUndef(Ref result_type) {
return AddCode(new Op(spv::Op::OpUndef, bound++, result_type));
}

View file

@ -12,15 +12,15 @@
namespace Sirit {
Ref Module::TypeVoid() {
Ref Module::OpTypeVoid() {
return AddDeclaration(new Op(spv::Op::OpTypeVoid, bound));
}
Ref Module::TypeBool() {
Ref Module::OpTypeBool() {
return AddDeclaration(new Op(spv::Op::OpTypeBool, bound));
}
Ref Module::TypeInt(int width, bool is_signed) {
Ref Module::OpTypeInt(int width, bool is_signed) {
if (width == 8) {
AddCapability(spv::Capability::Int8);
} else if (width == 16) {
@ -34,7 +34,7 @@ Ref Module::TypeInt(int width, bool is_signed) {
return AddDeclaration(op);
}
Ref Module::TypeFloat(int width) {
Ref Module::OpTypeFloat(int width) {
if (width == 16) {
AddCapability(spv::Capability::Float16);
} else if (width == 64) {
@ -45,7 +45,7 @@ Ref Module::TypeFloat(int width) {
return AddDeclaration(op);
}
Ref Module::TypeVector(Ref component_type, int component_count) {
Ref Module::OpTypeVector(Ref component_type, int component_count) {
assert(component_count >= 2);
auto op{new Op(spv::Op::OpTypeVector, bound)};
op->Add(component_type);
@ -53,7 +53,7 @@ Ref Module::TypeVector(Ref component_type, int component_count) {
return AddDeclaration(op);
}
Ref Module::TypeMatrix(Ref column_type, int column_count) {
Ref Module::OpTypeMatrix(Ref column_type, int column_count) {
assert(column_count >= 2);
AddCapability(spv::Capability::Matrix);
Op* op{new Op(spv::Op::OpTypeMatrix, bound)};
@ -62,9 +62,9 @@ Ref Module::TypeMatrix(Ref column_type, int column_count) {
return AddDeclaration(op);
}
Ref Module::TypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed,
bool ms, int sampled, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier) {
Ref Module::OpTypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed,
bool ms, int sampled, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier) {
switch (dim) {
case spv::Dim::Dim1D:
AddCapability(spv::Capability::Sampled1D);
@ -140,44 +140,44 @@ Ref Module::TypeImage(Ref sampled_type, spv::Dim dim, int depth, bool arrayed,
return AddDeclaration(op);
}
Ref Module::TypeSampler() {
Ref Module::OpTypeSampler() {
return AddDeclaration(new Op(spv::Op::OpTypeSampler, bound));
}
Ref Module::TypeSampledImage(Ref image_type) {
Ref Module::OpTypeSampledImage(Ref image_type) {
auto op{new Op(spv::Op::OpTypeSampledImage, bound)};
op->Add(image_type);
return AddDeclaration(op);
}
Ref Module::TypeArray(Ref element_type, Ref length) {
Ref Module::OpTypeArray(Ref element_type, Ref length) {
auto op{new Op(spv::Op::OpTypeArray, bound)};
op->Add(element_type);
op->Add(length);
return AddDeclaration(op);
}
Ref Module::TypeRuntimeArray(Ref element_type) {
Ref Module::OpTypeRuntimeArray(Ref element_type) {
AddCapability(spv::Capability::Shader);
auto op{new Op(spv::Op::OpTypeRuntimeArray, bound)};
op->Add(element_type);
return AddDeclaration(op);
}
Ref Module::TypeStruct(const std::vector<Ref>& members) {
Ref Module::OpTypeStruct(const std::vector<Ref>& members) {
auto op{new Op(spv::Op::OpTypeStruct, bound)};
op->Add(members);
return AddDeclaration(op);
}
Ref Module::TypeOpaque(const std::string& name) {
Ref Module::OpTypeOpaque(const std::string& name) {
AddCapability(spv::Capability::Kernel);
auto op{new Op(spv::Op::OpTypeOpaque, bound)};
op->Add(name);
return AddDeclaration(op);
}
Ref Module::TypePointer(spv::StorageClass storage_class, Ref type) {
Ref Module::OpTypePointer(spv::StorageClass storage_class, Ref type) {
switch (storage_class) {
case spv::StorageClass::Uniform:
case spv::StorageClass::Output:
@ -199,34 +199,34 @@ Ref Module::TypePointer(spv::StorageClass storage_class, Ref type) {
return AddDeclaration(op);
}
Ref Module::TypeFunction(Ref return_type, const std::vector<Ref>& arguments) {
Ref Module::OpTypeFunction(Ref return_type, const std::vector<Ref>& arguments) {
auto op{new Op(spv::Op::OpTypeFunction, bound)};
op->Add(return_type);
op->Add(arguments);
return AddDeclaration(op);
}
Ref Module::TypeEvent() {
Ref Module::OpTypeEvent() {
AddCapability(spv::Capability::Kernel);
return AddDeclaration(new Op(spv::Op::OpTypeEvent, bound));
}
Ref Module::TypeDeviceEvent() {
Ref Module::OpTypeDeviceEvent() {
AddCapability(spv::Capability::DeviceEnqueue);
return AddDeclaration(new Op(spv::Op::OpTypeDeviceEvent, bound));
}
Ref Module::TypeReserveId() {
Ref Module::OpTypeReserveId() {
AddCapability(spv::Capability::Pipes);
return AddDeclaration(new Op(spv::Op::OpTypeReserveId, bound));
}
Ref Module::TypeQueue() {
Ref Module::OpTypeQueue() {
AddCapability(spv::Capability::DeviceEnqueue);
return AddDeclaration(new Op(spv::Op::OpTypeQueue, bound));
}
Ref Module::TypePipe(spv::AccessQualifier access_qualifier) {
Ref Module::OpTypePipe(spv::AccessQualifier access_qualifier) {
AddCapability(spv::Capability::Pipes);
auto op{new Op(spv::Op::OpTypePipe, bound)};
op->Add(static_cast<u32>(access_qualifier));

View file

@ -4,7 +4,7 @@
* Lesser General Public License version 2.1 or any later version.
*/
#include "literal-number.h"
#include "literal_number.h"
#include <cassert>
namespace Sirit {

View file

@ -24,6 +24,7 @@ class LiteralNumber : public Operand {
template <typename T> static LiteralNumber* Create(T value) {
static_assert(sizeof(T) == 4 || sizeof(T) == 8);
LiteralNumber* number = new LiteralNumber(std::type_index(typeid(T)));
if (number->is_32 = sizeof(T) == 4; number->is_32) {
number->raw = *reinterpret_cast<u32*>(&value);
@ -34,7 +35,7 @@ class LiteralNumber : public Operand {
}
private:
std::type_index type;
const std::type_index type;
bool is_32;
u64 raw;
};

View file

@ -4,7 +4,9 @@
* Lesser General Public License version 2.1 or any later version.
*/
#include "literal-string.h"
#include "literal_string.h"
#include "common_types.h"
#include <string>
namespace Sirit {

View file

@ -23,7 +23,7 @@ class LiteralString : public Operand {
virtual bool operator==(const Operand& other) const;
private:
std::string string;
const std::string string;
};
} // namespace Sirit

View file

@ -7,8 +7,8 @@
#include <cassert>
#include "common_types.h"
#include "literal-number.h"
#include "literal-string.h"
#include "literal_number.h"
#include "literal_string.h"
#include "op.h"
#include "operand.h"
@ -88,6 +88,7 @@ void Op::Add(const Literal& literal) {
return LiteralNumber::Create(std::get<5>(literal));
default:
assert(!"invalid literal type");
abort();
}
}();
Sink(operand);

View file

@ -19,20 +19,20 @@ public:
AddCapability(spv::Capability::Shader);
SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450);
const auto t_void = Name(TypeVoid(), "void");
const auto t_uint = Name(TypeInt(32, false), "uint");
const auto t_float = Name(TypeFloat(32), "float");
const auto t_void = OpName(OpTypeVoid(), "void");
const auto t_uint = OpName(OpTypeInt(32, false), "uint");
const auto t_float = OpName(OpTypeFloat(32), "float");
const auto float4 = Name(TypeVector(t_float, 4), "float4");
const auto in_float = Name(TypePointer(spv::StorageClass::Input, t_float), "in_float");
const auto in_float4 = Name(TypePointer(spv::StorageClass::Input, float4), "in_float4");
const auto out_float4 = Name(TypePointer(spv::StorageClass::Output, float4), "out_float4");
const auto float4 = OpName(OpTypeVector(t_float, 4), "float4");
const auto in_float = OpName(OpTypePointer(spv::StorageClass::Input, t_float), "in_float");
const auto in_float4 = OpName(OpTypePointer(spv::StorageClass::Input, float4), "in_float4");
const auto out_float4 = OpName(OpTypePointer(spv::StorageClass::Output, float4), "out_float4");
const auto gl_per_vertex = Name(TypeStruct({float4}), "gl_PerVertex");
const auto gl_per_vertex_ptr = Name(TypePointer(spv::StorageClass::Output, gl_per_vertex), "out_gl_PerVertex");
const auto gl_per_vertex = OpName(OpTypeStruct({float4}), "gl_PerVertex");
const auto gl_per_vertex_ptr = OpName(OpTypePointer(spv::StorageClass::Output, gl_per_vertex), "out_gl_PerVertex");
const auto in_pos = Name(Variable(in_float4, spv::StorageClass::Input), "in_pos");
const auto per_vertex = Name(Variable(gl_per_vertex_ptr, spv::StorageClass::Output), "per_vertex");
const auto in_pos = OpName(OpVariable(in_float4, spv::StorageClass::Input), "in_pos");
const auto per_vertex = OpName(OpVariable(gl_per_vertex_ptr, spv::StorageClass::Output), "per_vertex");
Decorate(in_pos, spv::Decoration::Location, {0});
Decorate(gl_per_vertex, spv::Decoration::Block);
@ -41,22 +41,22 @@ public:
AddGlobalVariable(in_pos);
AddGlobalVariable(per_vertex);
const auto main_func = Emit(Name(Function(t_void, spv::FunctionControlMask::MaskNone, TypeFunction(t_void)), "main"));
const auto main_func = Emit(OpName(OpFunction(t_void, spv::FunctionControlMask::MaskNone, TypeFunction(t_void)), "main"));
Emit(Label());
const auto ptr_pos_x = Emit(AccessChain(in_float, in_pos, {Constant(t_uint, 0u)}));
const auto ptr_pos_y = Emit(AccessChain(in_float, in_pos, {Constant(t_uint, 1u)}));
const auto ptr_pos_x = Emit(OpAccessChain(in_float, in_pos, {OpConstant(t_uint, 0u)}));
const auto ptr_pos_y = Emit(OpAccessChain(in_float, in_pos, {OpConstant(t_uint, 1u)}));
const auto pos_x = Emit(Load(t_float, ptr_pos_x));
const auto pos_y = Emit(Load(t_float, ptr_pos_y));
auto tmp_position = Emit(Undef(float4));
tmp_position = Emit(CompositeInsert(float4, pos_x, tmp_position, {0}));
tmp_position = Emit(CompositeInsert(float4, pos_y, tmp_position, {1}));
tmp_position = Emit(CompositeInsert(float4, Constant(t_float, 0.f), tmp_position, {2}));
tmp_position = Emit(CompositeInsert(float4, Constant(t_float, 1.f), tmp_position, {3}));
tmp_position = Emit(OpCompositeInsert(float4, pos_x, tmp_position, {0}));
tmp_position = Emit(OpCompositeInsert(float4, pos_y, tmp_position, {1}));
tmp_position = Emit(OpCompositeInsert(float4, OpConstant(t_float, 0.f), tmp_position, {2}));
tmp_position = Emit(OpCompositeInsert(float4, OpConstant(t_float, 1.f), tmp_position, {3}));
const auto gl_position = Emit(AccessChain(out_float4, per_vertex, {Constant(t_uint, 0u)}));
const auto gl_position = Emit(OpAccessChain(out_float4, per_vertex, {OpConstant(t_uint, 0u)}));
Emit(Store(gl_position, tmp_position));
Emit(Return());