From ba92d8ea08723719d82f6a344a7fbc8e56c89f99 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 11 Mar 2019 03:41:44 -0300 Subject: [PATCH] Update README.md and remove automatic capabilities addition --- README.md | 11 ++-- src/instructions/constant.cpp | 2 - src/instructions/flow.cpp | 1 - src/instructions/type.cpp | 96 ----------------------------------- 4 files changed, 5 insertions(+), 105 deletions(-) diff --git a/README.md b/README.md index ed3148e..8fa51ee 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ What it does for you: * Sort declaration opcodes * Handle types and constant duplicates * Emit SPIR-V opcodes -* Add capabilities automatically What does not do for you: * Avoid ID duplicates (emitting the same instruction twice) @@ -35,11 +34,11 @@ public: AddCapability(spv::Capability::Shader); SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450); - auto main_type{TypeFunction(TypeVoid())}; - auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))}; - Emit(Label()); - Emit(Return()); - Emit(FunctionEnd()); + auto main_type{OpTypeFunction(TypeVoid())}; + auto main_func{Emit(OpFunction(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))}; + Emit(OpLabel()); + Emit(OpReturn()); + Emit(OpFunctionEnd()); AddEntryPoint(spv::ExecutionModel::Vertex, main_func, "main"); } diff --git a/src/instructions/constant.cpp b/src/instructions/constant.cpp index 9522f2d..3af2c11 100644 --- a/src/instructions/constant.cpp +++ b/src/instructions/constant.cpp @@ -32,8 +32,6 @@ Id Module::ConstantComposite(Id result_type, const std::vector& constituents Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode, bool normalized, spv::SamplerFilterMode filter_mode) { - AddCapability(spv::Capability::LiteralSampler); - AddCapability(spv::Capability::Kernel); auto op{std::make_unique(spv::Op::OpConstantSampler, bound, result_type)}; op->Add(static_cast(addressing_mode)); op->Add(normalized ? 1 : 0); diff --git a/src/instructions/flow.cpp b/src/instructions/flow.cpp index bdd0991..25c1afd 100644 --- a/src/instructions/flow.cpp +++ b/src/instructions/flow.cpp @@ -77,7 +77,6 @@ Id Module::OpReturnValue(Id value) { } Id Module::OpKill() { - AddCapability(spv::Capability::Shader); return AddCode(std::make_unique(spv::Op::OpKill)); } diff --git a/src/instructions/type.cpp b/src/instructions/type.cpp index 6cf76ca..3e9dab9 100644 --- a/src/instructions/type.cpp +++ b/src/instructions/type.cpp @@ -22,13 +22,6 @@ Id Module::OpTypeBool() { } Id Module::OpTypeInt(int width, bool is_signed) { - if (width == 8) { - AddCapability(spv::Capability::Int8); - } else if (width == 16) { - AddCapability(spv::Capability::Int16); - } else if (width == 64) { - AddCapability(spv::Capability::Int64); - } auto op{std::make_unique(spv::Op::OpTypeInt, bound)}; op->Add(width); op->Add(is_signed ? 1 : 0); @@ -36,11 +29,6 @@ Id Module::OpTypeInt(int width, bool is_signed) { } Id Module::OpTypeFloat(int width) { - if (width == 16) { - AddCapability(spv::Capability::Float16); - } else if (width == 64) { - AddCapability(spv::Capability::Float64); - } auto op{std::make_unique(spv::Op::OpTypeFloat, bound)}; op->Add(width); return AddDeclaration(std::move(op)); @@ -56,7 +44,6 @@ Id Module::OpTypeVector(Id component_type, int component_count) { Id Module::OpTypeMatrix(Id column_type, int column_count) { assert(column_count >= 2); - AddCapability(spv::Capability::Matrix); auto op{std::make_unique(spv::Op::OpTypeMatrix, bound)}; op->Add(column_type); op->Add(column_count); @@ -66,66 +53,6 @@ Id Module::OpTypeMatrix(Id column_type, int column_count) { Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled, spv::ImageFormat image_format, std::optional access_qualifier) { - switch (dim) { - case spv::Dim::Dim1D: - AddCapability(spv::Capability::Sampled1D); - break; - case spv::Dim::Cube: - AddCapability(spv::Capability::Shader); - break; - case spv::Dim::Rect: - AddCapability(spv::Capability::SampledRect); - break; - case spv::Dim::Buffer: - AddCapability(spv::Capability::SampledBuffer); - break; - case spv::Dim::SubpassData: - AddCapability(spv::Capability::InputAttachment); - break; - } - switch (image_format) { - case spv::ImageFormat::Rgba32f: - case spv::ImageFormat::Rgba16f: - case spv::ImageFormat::R32f: - case spv::ImageFormat::Rgba8: - case spv::ImageFormat::Rgba8Snorm: - case spv::ImageFormat::Rgba32i: - case spv::ImageFormat::Rgba16i: - case spv::ImageFormat::Rgba8i: - case spv::ImageFormat::R32i: - case spv::ImageFormat::Rgba32ui: - case spv::ImageFormat::Rgba16ui: - case spv::ImageFormat::Rgba8ui: - case spv::ImageFormat::R32ui: - AddCapability(spv::Capability::Shader); - break; - case spv::ImageFormat::Rg32f: - case spv::ImageFormat::Rg16f: - case spv::ImageFormat::R11fG11fB10f: - case spv::ImageFormat::R16f: - case spv::ImageFormat::Rgba16: - case spv::ImageFormat::Rgb10A2: - case spv::ImageFormat::Rg16: - case spv::ImageFormat::Rg8: - case spv::ImageFormat::R16: - case spv::ImageFormat::R8: - case spv::ImageFormat::Rgba16Snorm: - case spv::ImageFormat::Rg16Snorm: - case spv::ImageFormat::Rg8Snorm: - case spv::ImageFormat::Rg32i: - case spv::ImageFormat::Rg16i: - case spv::ImageFormat::Rg8i: - case spv::ImageFormat::R16i: - case spv::ImageFormat::R8i: - case spv::ImageFormat::Rgb10a2ui: - case spv::ImageFormat::Rg32ui: - case spv::ImageFormat::Rg16ui: - case spv::ImageFormat::Rg8ui: - case spv::ImageFormat::R16ui: - case spv::ImageFormat::R8ui: - AddCapability(spv::Capability::StorageImageExtendedFormats); - break; - } auto op{std::make_unique(spv::Op::OpTypeImage, bound)}; op->Add(sampled_type); op->Add(static_cast(dim)); @@ -135,7 +62,6 @@ Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, b op->Add(sampled); op->Add(static_cast(image_format)); if (access_qualifier.has_value()) { - AddCapability(spv::Capability::Kernel); op->Add(static_cast(access_qualifier.value())); } return AddDeclaration(std::move(op)); @@ -159,7 +85,6 @@ Id Module::OpTypeArray(Id element_type, Id length) { } Id Module::OpTypeRuntimeArray(Id element_type) { - AddCapability(spv::Capability::Shader); auto op{std::make_unique(spv::Op::OpTypeRuntimeArray, bound)}; op->Add(element_type); return AddDeclaration(std::move(op)); @@ -172,28 +97,12 @@ Id Module::OpTypeStruct(const std::vector& members) { } Id Module::OpTypeOpaque(const std::string& name) { - AddCapability(spv::Capability::Kernel); auto op{std::make_unique(spv::Op::OpTypeOpaque, bound)}; op->Add(name); return AddDeclaration(std::move(op)); } Id Module::OpTypePointer(spv::StorageClass storage_class, Id type) { - switch (storage_class) { - case spv::StorageClass::Uniform: - case spv::StorageClass::Output: - case spv::StorageClass::Private: - case spv::StorageClass::PushConstant: - case spv::StorageClass::StorageBuffer: - AddCapability(spv::Capability::Shader); - break; - case spv::StorageClass::Generic: - AddCapability(spv::Capability::GenericPointer); - break; - case spv::StorageClass::AtomicCounter: - AddCapability(spv::Capability::AtomicStorage); - break; - } auto op{std::make_unique(spv::Op::OpTypePointer, bound)}; op->Add(static_cast(storage_class)); op->Add(type); @@ -208,27 +117,22 @@ Id Module::OpTypeFunction(Id return_type, const std::vector& arguments) { } Id Module::OpTypeEvent() { - AddCapability(spv::Capability::Kernel); return AddDeclaration(std::make_unique(spv::Op::OpTypeEvent, bound)); } Id Module::OpTypeDeviceEvent() { - AddCapability(spv::Capability::DeviceEnqueue); return AddDeclaration(std::make_unique(spv::Op::OpTypeDeviceEvent, bound)); } Id Module::OpTypeReserveId() { - AddCapability(spv::Capability::Pipes); return AddDeclaration(std::make_unique(spv::Op::OpTypeReserveId, bound)); } Id Module::OpTypeQueue() { - AddCapability(spv::Capability::DeviceEnqueue); return AddDeclaration(std::make_unique(spv::Op::OpTypeQueue, bound)); } Id Module::OpTypePipe(spv::AccessQualifier access_qualifier) { - AddCapability(spv::Capability::Pipes); auto op{std::make_unique(spv::Op::OpTypePipe, bound)}; op->Add(static_cast(access_qualifier)); return AddDeclaration(std::move(op));