Update README.md and remove automatic capabilities addition

This commit is contained in:
ReinUsesLisp 2019-03-11 03:41:44 -03:00
parent 73595f4588
commit ba92d8ea08
4 changed files with 5 additions and 105 deletions

View File

@ -10,7 +10,6 @@ What it does for you:
* Sort declaration opcodes * Sort declaration opcodes
* Handle types and constant duplicates * Handle types and constant duplicates
* Emit SPIR-V opcodes * Emit SPIR-V opcodes
* Add capabilities automatically
What does not do for you: What does not do for you:
* Avoid ID duplicates (emitting the same instruction twice) * Avoid ID duplicates (emitting the same instruction twice)
@ -35,11 +34,11 @@ public:
AddCapability(spv::Capability::Shader); AddCapability(spv::Capability::Shader);
SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450); SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450);
auto main_type{TypeFunction(TypeVoid())}; auto main_type{OpTypeFunction(TypeVoid())};
auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))}; auto main_func{Emit(OpFunction(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};
Emit(Label()); Emit(OpLabel());
Emit(Return()); Emit(OpReturn());
Emit(FunctionEnd()); Emit(OpFunctionEnd());
AddEntryPoint(spv::ExecutionModel::Vertex, main_func, "main"); AddEntryPoint(spv::ExecutionModel::Vertex, main_func, "main");
} }

View File

@ -32,8 +32,6 @@ Id Module::ConstantComposite(Id result_type, const std::vector<Id>& constituents
Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode, Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode,
bool normalized, spv::SamplerFilterMode filter_mode) { bool normalized, spv::SamplerFilterMode filter_mode) {
AddCapability(spv::Capability::LiteralSampler);
AddCapability(spv::Capability::Kernel);
auto op{std::make_unique<Op>(spv::Op::OpConstantSampler, bound, result_type)}; auto op{std::make_unique<Op>(spv::Op::OpConstantSampler, bound, result_type)};
op->Add(static_cast<u32>(addressing_mode)); op->Add(static_cast<u32>(addressing_mode));
op->Add(normalized ? 1 : 0); op->Add(normalized ? 1 : 0);

View File

@ -77,7 +77,6 @@ Id Module::OpReturnValue(Id value) {
} }
Id Module::OpKill() { Id Module::OpKill() {
AddCapability(spv::Capability::Shader);
return AddCode(std::make_unique<Op>(spv::Op::OpKill)); return AddCode(std::make_unique<Op>(spv::Op::OpKill));
} }

View File

@ -22,13 +22,6 @@ Id Module::OpTypeBool() {
} }
Id Module::OpTypeInt(int width, bool is_signed) { 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<Op>(spv::Op::OpTypeInt, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeInt, bound)};
op->Add(width); op->Add(width);
op->Add(is_signed ? 1 : 0); op->Add(is_signed ? 1 : 0);
@ -36,11 +29,6 @@ Id Module::OpTypeInt(int width, bool is_signed) {
} }
Id Module::OpTypeFloat(int width) { 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<Op>(spv::Op::OpTypeFloat, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeFloat, bound)};
op->Add(width); op->Add(width);
return AddDeclaration(std::move(op)); 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) { Id Module::OpTypeMatrix(Id column_type, int column_count) {
assert(column_count >= 2); assert(column_count >= 2);
AddCapability(spv::Capability::Matrix);
auto op{std::make_unique<Op>(spv::Op::OpTypeMatrix, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeMatrix, bound)};
op->Add(column_type); op->Add(column_type);
op->Add(column_count); 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, Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled,
spv::ImageFormat image_format, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier) { std::optional<spv::AccessQualifier> 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<Op>(spv::Op::OpTypeImage, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeImage, bound)};
op->Add(sampled_type); op->Add(sampled_type);
op->Add(static_cast<u32>(dim)); op->Add(static_cast<u32>(dim));
@ -135,7 +62,6 @@ Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, b
op->Add(sampled); op->Add(sampled);
op->Add(static_cast<u32>(image_format)); op->Add(static_cast<u32>(image_format));
if (access_qualifier.has_value()) { if (access_qualifier.has_value()) {
AddCapability(spv::Capability::Kernel);
op->Add(static_cast<u32>(access_qualifier.value())); op->Add(static_cast<u32>(access_qualifier.value()));
} }
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
@ -159,7 +85,6 @@ Id Module::OpTypeArray(Id element_type, Id length) {
} }
Id Module::OpTypeRuntimeArray(Id element_type) { Id Module::OpTypeRuntimeArray(Id element_type) {
AddCapability(spv::Capability::Shader);
auto op{std::make_unique<Op>(spv::Op::OpTypeRuntimeArray, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeRuntimeArray, bound)};
op->Add(element_type); op->Add(element_type);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
@ -172,28 +97,12 @@ Id Module::OpTypeStruct(const std::vector<Id>& members) {
} }
Id Module::OpTypeOpaque(const std::string& name) { Id Module::OpTypeOpaque(const std::string& name) {
AddCapability(spv::Capability::Kernel);
auto op{std::make_unique<Op>(spv::Op::OpTypeOpaque, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeOpaque, bound)};
op->Add(name); op->Add(name);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypePointer(spv::StorageClass storage_class, Id type) { 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<Op>(spv::Op::OpTypePointer, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypePointer, bound)};
op->Add(static_cast<u32>(storage_class)); op->Add(static_cast<u32>(storage_class));
op->Add(type); op->Add(type);
@ -208,27 +117,22 @@ Id Module::OpTypeFunction(Id return_type, const std::vector<Id>& arguments) {
} }
Id Module::OpTypeEvent() { Id Module::OpTypeEvent() {
AddCapability(spv::Capability::Kernel);
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeEvent, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeEvent, bound));
} }
Id Module::OpTypeDeviceEvent() { Id Module::OpTypeDeviceEvent() {
AddCapability(spv::Capability::DeviceEnqueue);
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeDeviceEvent, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeDeviceEvent, bound));
} }
Id Module::OpTypeReserveId() { Id Module::OpTypeReserveId() {
AddCapability(spv::Capability::Pipes);
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeReserveId, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeReserveId, bound));
} }
Id Module::OpTypeQueue() { Id Module::OpTypeQueue() {
AddCapability(spv::Capability::DeviceEnqueue);
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeQueue, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeQueue, bound));
} }
Id Module::OpTypePipe(spv::AccessQualifier access_qualifier) { Id Module::OpTypePipe(spv::AccessQualifier access_qualifier) {
AddCapability(spv::Capability::Pipes);
auto op{std::make_unique<Op>(spv::Op::OpTypePipe, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypePipe, bound)};
op->Add(static_cast<u32>(access_qualifier)); op->Add(static_cast<u32>(access_qualifier));
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));