mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2025-02-16 09:02:25 +00:00
Convert Vulkano-shaders to use spirv_headers crate (#1624)
* Convert Vulkano-shaders to use spirv_headers crate * Fix issue after merge
This commit is contained in:
parent
5ec3e0d12f
commit
d5fd3d3f0b
@ -15,13 +15,15 @@ categories = ["rendering::graphics-api"]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
num-traits = "0.2"
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
shaderc = "0.7"
|
||||
syn = { version = "1.0", features = ["full", "extra-traits"] }
|
||||
spirv_headers = "1.5"
|
||||
syn = { version="1.0", features=["full", "extra-traits"] }
|
||||
|
||||
[dev-dependencies]
|
||||
vulkano = { version = "0.24.0", path = "../vulkano" }
|
||||
vulkano = { version="0.24.0", path="../vulkano" }
|
||||
|
||||
[features]
|
||||
shaderc-build-from-source = ["shaderc/build-from-source"]
|
||||
|
@ -8,8 +8,6 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::entry_point;
|
||||
use crate::enums::Capability;
|
||||
use crate::enums::StorageClass;
|
||||
use crate::parse;
|
||||
use crate::parse::Instruction;
|
||||
pub use crate::parse::ParseError;
|
||||
@ -20,6 +18,7 @@ use crate::TypesMeta;
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
pub use shaderc::{CompilationArtifact, IncludeType, ResolvedInclude, ShaderKind};
|
||||
use shaderc::{CompileOptions, Compiler, EnvVersion, SpirvVersion, TargetEnv};
|
||||
use spirv_headers::{Capability, StorageClass};
|
||||
use std::iter::Iterator;
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
@ -430,141 +429,205 @@ impl From<ParseError> for Error {
|
||||
// TODO: this function is a draft, as the actual names may not be the same
|
||||
fn capability_requirement(cap: &Capability) -> DeviceRequirement {
|
||||
match *cap {
|
||||
Capability::CapabilityMatrix => DeviceRequirement::None,
|
||||
Capability::CapabilityShader => DeviceRequirement::None,
|
||||
Capability::CapabilityGeometry => DeviceRequirement::Features(&["geometry_shader"]),
|
||||
Capability::CapabilityTessellation => DeviceRequirement::Features(&["tessellation_shader"]),
|
||||
Capability::CapabilityAddresses => panic!(), // not supported
|
||||
Capability::CapabilityLinkage => panic!(), // not supported
|
||||
Capability::CapabilityKernel => panic!(), // not supported
|
||||
Capability::CapabilityVector16 => panic!(), // not supported
|
||||
Capability::CapabilityFloat16Buffer => panic!(), // not supported
|
||||
Capability::CapabilityFloat16 => panic!(), // not supported
|
||||
Capability::CapabilityFloat64 => DeviceRequirement::Features(&["shader_float64"]),
|
||||
Capability::CapabilityInt64 => DeviceRequirement::Features(&["shader_int64"]),
|
||||
Capability::CapabilityInt64Atomics => panic!(), // not supported
|
||||
Capability::CapabilityImageBasic => panic!(), // not supported
|
||||
Capability::CapabilityImageReadWrite => panic!(), // not supported
|
||||
Capability::CapabilityImageMipmap => panic!(), // not supported
|
||||
Capability::CapabilityPipes => panic!(), // not supported
|
||||
Capability::CapabilityGroups => panic!(), // not supported
|
||||
Capability::CapabilityDeviceEnqueue => panic!(), // not supported
|
||||
Capability::CapabilityLiteralSampler => panic!(), // not supported
|
||||
Capability::CapabilityAtomicStorage => panic!(), // not supported
|
||||
Capability::CapabilityInt16 => DeviceRequirement::Features(&["shader_int16"]),
|
||||
Capability::CapabilityTessellationPointSize => {
|
||||
Capability::Matrix => DeviceRequirement::None,
|
||||
Capability::Shader => DeviceRequirement::None,
|
||||
Capability::Geometry => DeviceRequirement::Features(&["geometry_shader"]),
|
||||
Capability::Tessellation => DeviceRequirement::Features(&["tessellation_shader"]),
|
||||
Capability::Addresses => panic!(), // not supported
|
||||
Capability::Linkage => panic!(), // not supported
|
||||
Capability::Kernel => panic!(), // not supported
|
||||
Capability::Vector16 => panic!(), // not supported
|
||||
Capability::Float16Buffer => panic!(), // not supported
|
||||
Capability::Float16 => panic!(), // not supported
|
||||
Capability::Float64 => DeviceRequirement::Features(&["shader_float64"]),
|
||||
Capability::Int64 => DeviceRequirement::Features(&["shader_int64"]),
|
||||
Capability::Int64Atomics => panic!(), // not supported
|
||||
Capability::ImageBasic => panic!(), // not supported
|
||||
Capability::ImageReadWrite => panic!(), // not supported
|
||||
Capability::ImageMipmap => panic!(), // not supported
|
||||
Capability::Pipes => panic!(), // not supported
|
||||
Capability::Groups => panic!(), // not supported
|
||||
Capability::DeviceEnqueue => panic!(), // not supported
|
||||
Capability::LiteralSampler => panic!(), // not supported
|
||||
Capability::AtomicStorage => panic!(), // not supported
|
||||
Capability::Int16 => DeviceRequirement::Features(&["shader_int16"]),
|
||||
Capability::TessellationPointSize => {
|
||||
DeviceRequirement::Features(&["shader_tessellation_and_geometry_point_size"])
|
||||
}
|
||||
Capability::CapabilityGeometryPointSize => {
|
||||
Capability::GeometryPointSize => {
|
||||
DeviceRequirement::Features(&["shader_tessellation_and_geometry_point_size"])
|
||||
}
|
||||
Capability::CapabilityImageGatherExtended => {
|
||||
Capability::ImageGatherExtended => {
|
||||
DeviceRequirement::Features(&["shader_image_gather_extended"])
|
||||
}
|
||||
Capability::CapabilityStorageImageMultisample => {
|
||||
Capability::StorageImageMultisample => {
|
||||
DeviceRequirement::Features(&["shader_storage_image_multisample"])
|
||||
}
|
||||
Capability::CapabilityUniformBufferArrayDynamicIndexing => {
|
||||
Capability::UniformBufferArrayDynamicIndexing => {
|
||||
DeviceRequirement::Features(&["shader_uniform_buffer_array_dynamic_indexing"])
|
||||
}
|
||||
Capability::CapabilitySampledImageArrayDynamicIndexing => {
|
||||
Capability::SampledImageArrayDynamicIndexing => {
|
||||
DeviceRequirement::Features(&["shader_sampled_image_array_dynamic_indexing"])
|
||||
}
|
||||
Capability::CapabilityStorageBufferArrayDynamicIndexing => {
|
||||
Capability::StorageBufferArrayDynamicIndexing => {
|
||||
DeviceRequirement::Features(&["shader_storage_buffer_array_dynamic_indexing"])
|
||||
}
|
||||
Capability::CapabilityStorageImageArrayDynamicIndexing => {
|
||||
Capability::StorageImageArrayDynamicIndexing => {
|
||||
DeviceRequirement::Features(&["shader_storage_image_array_dynamic_indexing"])
|
||||
}
|
||||
Capability::CapabilityClipDistance => {
|
||||
DeviceRequirement::Features(&["shader_clip_distance"])
|
||||
}
|
||||
Capability::CapabilityCullDistance => {
|
||||
DeviceRequirement::Features(&["shader_cull_distance"])
|
||||
}
|
||||
Capability::CapabilityImageCubeArray => DeviceRequirement::Features(&["image_cube_array"]),
|
||||
Capability::CapabilitySampleRateShading => {
|
||||
DeviceRequirement::Features(&["sample_rate_shading"])
|
||||
}
|
||||
Capability::CapabilityImageRect => panic!(), // not supported
|
||||
Capability::CapabilitySampledRect => panic!(), // not supported
|
||||
Capability::CapabilityGenericPointer => panic!(), // not supported
|
||||
Capability::CapabilityInt8 => DeviceRequirement::Extensions(&["khr_8bit_storage"]),
|
||||
Capability::CapabilityInputAttachment => DeviceRequirement::None,
|
||||
Capability::CapabilitySparseResidency => {
|
||||
DeviceRequirement::Features(&["shader_resource_residency"])
|
||||
}
|
||||
Capability::CapabilityMinLod => DeviceRequirement::Features(&["shader_resource_min_lod"]),
|
||||
Capability::CapabilitySampled1D => DeviceRequirement::None,
|
||||
Capability::CapabilityImage1D => DeviceRequirement::None,
|
||||
Capability::CapabilitySampledCubeArray => {
|
||||
DeviceRequirement::Features(&["image_cube_array"])
|
||||
}
|
||||
Capability::CapabilitySampledBuffer => DeviceRequirement::None,
|
||||
Capability::CapabilityImageBuffer => DeviceRequirement::None,
|
||||
Capability::CapabilityImageMSArray => {
|
||||
Capability::ClipDistance => DeviceRequirement::Features(&["shader_clip_distance"]),
|
||||
Capability::CullDistance => DeviceRequirement::Features(&["shader_cull_distance"]),
|
||||
Capability::ImageCubeArray => DeviceRequirement::Features(&["image_cube_array"]),
|
||||
Capability::SampleRateShading => DeviceRequirement::Features(&["sample_rate_shading"]),
|
||||
Capability::ImageRect => panic!(), // not supported
|
||||
Capability::SampledRect => panic!(), // not supported
|
||||
Capability::GenericPointer => panic!(), // not supported
|
||||
Capability::Int8 => DeviceRequirement::Extensions(&["khr_8bit_storage"]),
|
||||
Capability::InputAttachment => DeviceRequirement::None,
|
||||
Capability::SparseResidency => DeviceRequirement::Features(&["shader_resource_residency"]),
|
||||
Capability::MinLod => DeviceRequirement::Features(&["shader_resource_min_lod"]),
|
||||
Capability::Sampled1D => DeviceRequirement::None,
|
||||
Capability::Image1D => DeviceRequirement::None,
|
||||
Capability::SampledCubeArray => DeviceRequirement::Features(&["image_cube_array"]),
|
||||
Capability::SampledBuffer => DeviceRequirement::None,
|
||||
Capability::ImageBuffer => DeviceRequirement::None,
|
||||
Capability::ImageMSArray => {
|
||||
DeviceRequirement::Features(&["shader_storage_image_multisample"])
|
||||
}
|
||||
Capability::CapabilityStorageImageExtendedFormats => {
|
||||
Capability::StorageImageExtendedFormats => {
|
||||
DeviceRequirement::Features(&["shader_storage_image_extended_formats"])
|
||||
}
|
||||
Capability::CapabilityImageQuery => DeviceRequirement::None,
|
||||
Capability::CapabilityDerivativeControl => DeviceRequirement::None,
|
||||
Capability::CapabilityInterpolationFunction => {
|
||||
DeviceRequirement::Features(&["sample_rate_shading"])
|
||||
}
|
||||
Capability::CapabilityTransformFeedback => panic!(), // not supported
|
||||
Capability::CapabilityGeometryStreams => panic!(), // not supported
|
||||
Capability::CapabilityStorageImageReadWithoutFormat => {
|
||||
Capability::ImageQuery => DeviceRequirement::None,
|
||||
Capability::DerivativeControl => DeviceRequirement::None,
|
||||
Capability::InterpolationFunction => DeviceRequirement::Features(&["sample_rate_shading"]),
|
||||
Capability::TransformFeedback => panic!(), // not supported
|
||||
Capability::GeometryStreams => panic!(), // not supported
|
||||
Capability::StorageImageReadWithoutFormat => {
|
||||
DeviceRequirement::Features(&["shader_storage_image_read_without_format"])
|
||||
}
|
||||
Capability::CapabilityStorageImageWriteWithoutFormat => {
|
||||
Capability::StorageImageWriteWithoutFormat => {
|
||||
DeviceRequirement::Features(&["shader_storage_image_write_without_format"])
|
||||
}
|
||||
Capability::CapabilityMultiViewport => DeviceRequirement::Features(&["multi_viewport"]),
|
||||
Capability::CapabilityDrawParameters => {
|
||||
DeviceRequirement::Features(&["shader_draw_parameters"])
|
||||
}
|
||||
Capability::CapabilityStorageUniformBufferBlock16 => {
|
||||
Capability::MultiViewport => DeviceRequirement::Features(&["multi_viewport"]),
|
||||
Capability::DrawParameters => DeviceRequirement::Features(&["shader_draw_parameters"]),
|
||||
Capability::StorageBuffer16BitAccess => {
|
||||
DeviceRequirement::Extensions(&["khr_16bit_storage"])
|
||||
}
|
||||
Capability::CapabilityStorageUniform16 => {
|
||||
Capability::UniformAndStorageBuffer16BitAccess => {
|
||||
DeviceRequirement::Extensions(&["khr_16bit_storage"])
|
||||
}
|
||||
Capability::CapabilityStoragePushConstant16 => {
|
||||
DeviceRequirement::Extensions(&["khr_16bit_storage"])
|
||||
}
|
||||
Capability::CapabilityStorageInputOutput16 => {
|
||||
DeviceRequirement::Extensions(&["khr_16bit_storage"])
|
||||
}
|
||||
Capability::CapabilityMultiView => DeviceRequirement::Features(&["multiview"]),
|
||||
Capability::CapabilityStorageInputOutput8 => {
|
||||
DeviceRequirement::Extensions(&["khr_8bit_storage"])
|
||||
}
|
||||
Capability::CapabilityStoragePushConstant8 => {
|
||||
DeviceRequirement::Extensions(&["khr_8bit_storage"])
|
||||
}
|
||||
Capability::StoragePushConstant16 => DeviceRequirement::Extensions(&["khr_16bit_storage"]),
|
||||
Capability::StorageInputOutput16 => DeviceRequirement::Extensions(&["khr_16bit_storage"]),
|
||||
Capability::MultiView => DeviceRequirement::Features(&["multiview"]),
|
||||
Capability::StoragePushConstant8 => DeviceRequirement::Extensions(&["khr_8bit_storage"]),
|
||||
Capability::SubgroupDispatch => todo!(),
|
||||
Capability::NamedBarrier => todo!(),
|
||||
Capability::PipeStorage => todo!(),
|
||||
Capability::GroupNonUniform => todo!(),
|
||||
Capability::GroupNonUniformVote => todo!(),
|
||||
Capability::GroupNonUniformArithmetic => todo!(),
|
||||
Capability::GroupNonUniformBallot => todo!(),
|
||||
Capability::GroupNonUniformShuffle => todo!(),
|
||||
Capability::GroupNonUniformShuffleRelative => todo!(),
|
||||
Capability::GroupNonUniformClustered => todo!(),
|
||||
Capability::GroupNonUniformQuad => todo!(),
|
||||
Capability::ShaderLayer => todo!(),
|
||||
Capability::ShaderViewportIndex => todo!(),
|
||||
Capability::SubgroupBallotKHR => todo!(),
|
||||
Capability::SubgroupVoteKHR => todo!(),
|
||||
Capability::DeviceGroup => todo!(),
|
||||
Capability::VariablePointersStorageBuffer => todo!(),
|
||||
Capability::VariablePointers => todo!(),
|
||||
Capability::AtomicStorageOps => todo!(),
|
||||
Capability::SampleMaskPostDepthCoverage => todo!(),
|
||||
Capability::StorageBuffer8BitAccess => todo!(),
|
||||
Capability::UniformAndStorageBuffer8BitAccess => todo!(),
|
||||
Capability::DenormPreserve => todo!(),
|
||||
Capability::DenormFlushToZero => todo!(),
|
||||
Capability::SignedZeroInfNanPreserve => todo!(),
|
||||
Capability::RoundingModeRTE => todo!(),
|
||||
Capability::RoundingModeRTZ => todo!(),
|
||||
Capability::RayQueryProvisionalKHR => todo!(),
|
||||
Capability::RayTraversalPrimitiveCullingProvisionalKHR => todo!(),
|
||||
Capability::Float16ImageAMD => todo!(),
|
||||
Capability::ImageGatherBiasLodAMD => todo!(),
|
||||
Capability::FragmentMaskAMD => todo!(),
|
||||
Capability::StencilExportEXT => todo!(),
|
||||
Capability::ImageReadWriteLodAMD => todo!(),
|
||||
Capability::ShaderClockKHR => todo!(),
|
||||
Capability::SampleMaskOverrideCoverageNV => todo!(),
|
||||
Capability::GeometryShaderPassthroughNV => todo!(),
|
||||
Capability::ShaderViewportIndexLayerEXT => todo!(),
|
||||
Capability::ShaderViewportMaskNV => todo!(),
|
||||
Capability::ShaderStereoViewNV => todo!(),
|
||||
Capability::PerViewAttributesNV => todo!(),
|
||||
Capability::FragmentFullyCoveredEXT => todo!(),
|
||||
Capability::MeshShadingNV => todo!(),
|
||||
Capability::ImageFootprintNV => todo!(),
|
||||
Capability::FragmentBarycentricNV => todo!(),
|
||||
Capability::ComputeDerivativeGroupQuadsNV => todo!(),
|
||||
Capability::FragmentDensityEXT => todo!(),
|
||||
Capability::GroupNonUniformPartitionedNV => todo!(),
|
||||
Capability::ShaderNonUniform => todo!(),
|
||||
Capability::RuntimeDescriptorArray => todo!(),
|
||||
Capability::InputAttachmentArrayDynamicIndexing => todo!(),
|
||||
Capability::UniformTexelBufferArrayDynamicIndexing => todo!(),
|
||||
Capability::StorageTexelBufferArrayDynamicIndexing => todo!(),
|
||||
Capability::UniformBufferArrayNonUniformIndexing => todo!(),
|
||||
Capability::SampledImageArrayNonUniformIndexing => todo!(),
|
||||
Capability::StorageBufferArrayNonUniformIndexing => todo!(),
|
||||
Capability::StorageImageArrayNonUniformIndexing => todo!(),
|
||||
Capability::InputAttachmentArrayNonUniformIndexing => todo!(),
|
||||
Capability::UniformTexelBufferArrayNonUniformIndexing => todo!(),
|
||||
Capability::StorageTexelBufferArrayNonUniformIndexing => todo!(),
|
||||
Capability::RayTracingNV => todo!(),
|
||||
Capability::VulkanMemoryModel => todo!(),
|
||||
Capability::VulkanMemoryModelDeviceScope => todo!(),
|
||||
Capability::PhysicalStorageBufferAddresses => todo!(),
|
||||
Capability::ComputeDerivativeGroupLinearNV => todo!(),
|
||||
Capability::RayTracingProvisionalKHR => todo!(),
|
||||
Capability::CooperativeMatrixNV => todo!(),
|
||||
Capability::FragmentShaderSampleInterlockEXT => todo!(),
|
||||
Capability::FragmentShaderShadingRateInterlockEXT => todo!(),
|
||||
Capability::ShaderSMBuiltinsNV => todo!(),
|
||||
Capability::FragmentShaderPixelInterlockEXT => todo!(),
|
||||
Capability::DemoteToHelperInvocationEXT => todo!(),
|
||||
Capability::SubgroupShuffleINTEL => todo!(),
|
||||
Capability::SubgroupBufferBlockIOINTEL => todo!(),
|
||||
Capability::SubgroupImageBlockIOINTEL => todo!(),
|
||||
Capability::SubgroupImageMediaBlockIOINTEL => todo!(),
|
||||
Capability::IntegerFunctions2INTEL => todo!(),
|
||||
Capability::SubgroupAvcMotionEstimationINTEL => todo!(),
|
||||
Capability::SubgroupAvcMotionEstimationIntraINTEL => todo!(),
|
||||
Capability::SubgroupAvcMotionEstimationChromaINTEL => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the Vulkan device requirement for a SPIR-V storage class.
|
||||
fn storage_class_requirement(storage_class: &StorageClass) -> DeviceRequirement {
|
||||
match *storage_class {
|
||||
StorageClass::StorageClassUniformConstant => DeviceRequirement::None,
|
||||
StorageClass::StorageClassInput => DeviceRequirement::None,
|
||||
StorageClass::StorageClassUniform => DeviceRequirement::None,
|
||||
StorageClass::StorageClassOutput => DeviceRequirement::None,
|
||||
StorageClass::StorageClassWorkgroup => DeviceRequirement::None,
|
||||
StorageClass::StorageClassCrossWorkgroup => DeviceRequirement::None,
|
||||
StorageClass::StorageClassPrivate => DeviceRequirement::None,
|
||||
StorageClass::StorageClassFunction => DeviceRequirement::None,
|
||||
StorageClass::StorageClassGeneric => DeviceRequirement::None,
|
||||
StorageClass::StorageClassPushConstant => DeviceRequirement::None,
|
||||
StorageClass::StorageClassAtomicCounter => DeviceRequirement::None,
|
||||
StorageClass::StorageClassImage => DeviceRequirement::None,
|
||||
StorageClass::StorageClassStorageBuffer => {
|
||||
StorageClass::UniformConstant => DeviceRequirement::None,
|
||||
StorageClass::Input => DeviceRequirement::None,
|
||||
StorageClass::Uniform => DeviceRequirement::None,
|
||||
StorageClass::Output => DeviceRequirement::None,
|
||||
StorageClass::Workgroup => DeviceRequirement::None,
|
||||
StorageClass::CrossWorkgroup => DeviceRequirement::None,
|
||||
StorageClass::Private => DeviceRequirement::None,
|
||||
StorageClass::Function => DeviceRequirement::None,
|
||||
StorageClass::Generic => DeviceRequirement::None,
|
||||
StorageClass::PushConstant => DeviceRequirement::None,
|
||||
StorageClass::AtomicCounter => DeviceRequirement::None,
|
||||
StorageClass::Image => DeviceRequirement::None,
|
||||
StorageClass::StorageBuffer => {
|
||||
DeviceRequirement::Extensions(&["khr_storage_buffer_storage_class"])
|
||||
}
|
||||
StorageClass::CallableDataNV => todo!(),
|
||||
StorageClass::IncomingCallableDataNV => todo!(),
|
||||
StorageClass::RayPayloadNV => todo!(),
|
||||
StorageClass::HitAttributeNV => todo!(),
|
||||
StorageClass::IncomingRayPayloadNV => todo!(),
|
||||
StorageClass::ShaderRecordBufferNV => todo!(),
|
||||
StorageClass::PhysicalStorageBuffer => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::enums::{Decoration, Dim, ImageFormat, StorageClass};
|
||||
use crate::parse::{Instruction, Spirv};
|
||||
use crate::{spirv_search, TypesMeta};
|
||||
use proc_macro2::TokenStream;
|
||||
use spirv_headers::{Decoration, Dim, ImageFormat, StorageClass};
|
||||
use std::cmp;
|
||||
use std::collections::HashSet;
|
||||
|
||||
@ -42,7 +42,7 @@ pub(super) fn write_pipeline_layout_desc(
|
||||
let type_id = match instruction {
|
||||
&Instruction::TypePointer {
|
||||
type_id,
|
||||
storage_class: StorageClass::StorageClassPushConstant,
|
||||
storage_class: StorageClass::PushConstant,
|
||||
..
|
||||
} => type_id,
|
||||
_ => continue,
|
||||
@ -158,7 +158,7 @@ fn find_descriptors(
|
||||
};
|
||||
|
||||
// Looping to find all the interface elements that have the `DescriptorSet` decoration.
|
||||
for set_decoration in doc.get_decorations(Decoration::DecorationDescriptorSet) {
|
||||
for set_decoration in doc.get_decorations(Decoration::DescriptorSet) {
|
||||
let variable_id = set_decoration.target_id;
|
||||
|
||||
if exact && !variables.as_ref().unwrap().contains(&variable_id) {
|
||||
@ -175,11 +175,11 @@ fn find_descriptors(
|
||||
// Find the binding point of this descriptor.
|
||||
// TODO: There was a previous todo here, I think it was asking for this to be implemented for member decorations? check git history
|
||||
let binding = doc
|
||||
.get_decoration_params(variable_id, Decoration::DecorationBinding)
|
||||
.get_decoration_params(variable_id, Decoration::Binding)
|
||||
.unwrap()[0];
|
||||
|
||||
let nonwritable = doc
|
||||
.get_decoration_params(variable_id, Decoration::DecorationNonWritable)
|
||||
.get_decoration_params(variable_id, Decoration::NonWritable)
|
||||
.is_some();
|
||||
|
||||
// Find information about the kind of binding for this descriptor.
|
||||
@ -385,10 +385,10 @@ fn descriptor_infos(
|
||||
match i {
|
||||
Instruction::TypeStruct { result_id, member_types } if *result_id == pointed_ty => {
|
||||
let decoration_block = doc
|
||||
.get_decoration_params(pointed_ty, Decoration::DecorationBlock)
|
||||
.get_decoration_params(pointed_ty, Decoration::Block)
|
||||
.is_some();
|
||||
let decoration_buffer_block = doc
|
||||
.get_decoration_params(pointed_ty, Decoration::DecorationBufferBlock)
|
||||
.get_decoration_params(pointed_ty, Decoration::BufferBlock)
|
||||
.is_some();
|
||||
assert!(
|
||||
decoration_block ^ decoration_buffer_block,
|
||||
@ -397,11 +397,11 @@ fn descriptor_infos(
|
||||
|
||||
// false -> VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
|
||||
// true -> VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
|
||||
let storage = pointer_storage == StorageClass::StorageClassStorageBuffer;
|
||||
let storage = pointer_storage == StorageClass::StorageBuffer;
|
||||
|
||||
// Determine whether all members have a NonWritable decoration.
|
||||
let nonwritable = (0..member_types.len() as u32).all(|i| {
|
||||
doc.get_member_decoration_params(pointed_ty, i, Decoration::DecorationNonWritable).is_some()
|
||||
doc.get_member_decoration_params(pointed_ty, i, Decoration::NonWritable).is_some()
|
||||
});
|
||||
|
||||
// Uniforms are never writable.
|
||||
@ -447,7 +447,7 @@ fn descriptor_infos(
|
||||
SubpassData"
|
||||
);
|
||||
assert!(
|
||||
*format == ImageFormat::ImageFormatUnknown,
|
||||
*format == ImageFormat::Unknown,
|
||||
"If Dim is SubpassData, Image Format must be Unknown"
|
||||
);
|
||||
assert!(!sampled, "If Dim is SubpassData, Sampled must be 2");
|
||||
@ -744,45 +744,45 @@ mod tests {
|
||||
|
||||
fn to_vulkan_format(spirv_format: ImageFormat) -> TokenStream {
|
||||
match spirv_format {
|
||||
ImageFormat::ImageFormatUnknown => quote! { None },
|
||||
ImageFormat::ImageFormatRgba32f => quote! { Some(Format::R32G32B32A32Sfloat) },
|
||||
ImageFormat::ImageFormatRgba16f => quote! { Some(Format::R16G16B16A16Sfloat) },
|
||||
ImageFormat::ImageFormatR32f => quote! { Some(Format::R32Sfloat) },
|
||||
ImageFormat::ImageFormatRgba8 => quote! { Some(Format::R8G8B8A8Unorm) },
|
||||
ImageFormat::ImageFormatRgba8Snorm => quote! { Some(Format::R8G8B8A8Snorm) },
|
||||
ImageFormat::ImageFormatRg32f => quote! { Some(Format::R32G32Sfloat) },
|
||||
ImageFormat::ImageFormatRg16f => quote! { Some(Format::R16G16Sfloat) },
|
||||
ImageFormat::ImageFormatR11fG11fB10f => quote! { Some(Format::B10G11R11UfloatPack32) },
|
||||
ImageFormat::ImageFormatR16f => quote! { Some(Format::R16Sfloat) },
|
||||
ImageFormat::ImageFormatRgba16 => quote! { Some(Format::R16G16B16A16Unorm) },
|
||||
ImageFormat::ImageFormatRgb10A2 => quote! { Some(Format::A2B10G10R10UnormPack32) },
|
||||
ImageFormat::ImageFormatRg16 => quote! { Some(Format::R16G16Unorm) },
|
||||
ImageFormat::ImageFormatRg8 => quote! { Some(Format::R8G8Unorm) },
|
||||
ImageFormat::ImageFormatR16 => quote! { Some(Format::R16Unorm) },
|
||||
ImageFormat::ImageFormatR8 => quote! { Some(Format::R8Unorm) },
|
||||
ImageFormat::ImageFormatRgba16Snorm => quote! { Some(Format::R16G16B16A16Snorm) },
|
||||
ImageFormat::ImageFormatRg16Snorm => quote! { Some(Format::R16G16Snorm) },
|
||||
ImageFormat::ImageFormatRg8Snorm => quote! { Some(Format::R8G8Snorm) },
|
||||
ImageFormat::ImageFormatR16Snorm => quote! { Some(Format::R16Snorm) },
|
||||
ImageFormat::ImageFormatR8Snorm => quote! { Some(Format::R8Snorm) },
|
||||
ImageFormat::ImageFormatRgba32i => quote! { Some(Format::R32G32B32A32Sint) },
|
||||
ImageFormat::ImageFormatRgba16i => quote! { Some(Format::R16G16B16A16Sint) },
|
||||
ImageFormat::ImageFormatRgba8i => quote! { Some(Format::R8G8B8A8Sint) },
|
||||
ImageFormat::ImageFormatR32i => quote! { Some(Format::R32Sint) },
|
||||
ImageFormat::ImageFormatRg32i => quote! { Some(Format::R32G32Sint) },
|
||||
ImageFormat::ImageFormatRg16i => quote! { Some(Format::R16G16Sint) },
|
||||
ImageFormat::ImageFormatRg8i => quote! { Some(Format::R8G8Sint) },
|
||||
ImageFormat::ImageFormatR16i => quote! { Some(Format::R16Sint) },
|
||||
ImageFormat::ImageFormatR8i => quote! { Some(Format::R8Sint) },
|
||||
ImageFormat::ImageFormatRgba32ui => quote! { Some(Format::R32G32B32A32Uint) },
|
||||
ImageFormat::ImageFormatRgba16ui => quote! { Some(Format::R16G16B16A16Uint) },
|
||||
ImageFormat::ImageFormatRgba8ui => quote! { Some(Format::R8G8B8A8Uint) },
|
||||
ImageFormat::ImageFormatR32ui => quote! { Some(Format::R32Uint) },
|
||||
ImageFormat::ImageFormatRgb10a2ui => quote! { Some(Format::A2B10G10R10UintPack32) },
|
||||
ImageFormat::ImageFormatRg32ui => quote! { Some(Format::R32G32Uint) },
|
||||
ImageFormat::ImageFormatRg16ui => quote! { Some(Format::R16G16Uint) },
|
||||
ImageFormat::ImageFormatRg8ui => quote! { Some(Format::R8G8Uint) },
|
||||
ImageFormat::ImageFormatR16ui => quote! { Some(Format::R16Uint) },
|
||||
ImageFormat::ImageFormatR8ui => quote! { Some(Format::R8Uint) },
|
||||
ImageFormat::Unknown => quote! { None },
|
||||
ImageFormat::Rgba32f => quote! { Some(Format::R32G32B32A32Sfloat) },
|
||||
ImageFormat::Rgba16f => quote! { Some(Format::R16G16B16A16Sfloat) },
|
||||
ImageFormat::R32f => quote! { Some(Format::R32Sfloat) },
|
||||
ImageFormat::Rgba8 => quote! { Some(Format::R8G8B8A8Unorm) },
|
||||
ImageFormat::Rgba8Snorm => quote! { Some(Format::R8G8B8A8Snorm) },
|
||||
ImageFormat::Rg32f => quote! { Some(Format::R32G32Sfloat) },
|
||||
ImageFormat::Rg16f => quote! { Some(Format::R16G16Sfloat) },
|
||||
ImageFormat::R11fG11fB10f => quote! { Some(Format::B10G11R11UfloatPack32) },
|
||||
ImageFormat::R16f => quote! { Some(Format::R16Sfloat) },
|
||||
ImageFormat::Rgba16 => quote! { Some(Format::R16G16B16A16Unorm) },
|
||||
ImageFormat::Rgb10A2 => quote! { Some(Format::A2B10G10R10UnormPack32) },
|
||||
ImageFormat::Rg16 => quote! { Some(Format::R16G16Unorm) },
|
||||
ImageFormat::Rg8 => quote! { Some(Format::R8G8Unorm) },
|
||||
ImageFormat::R16 => quote! { Some(Format::R16Unorm) },
|
||||
ImageFormat::R8 => quote! { Some(Format::R8Unorm) },
|
||||
ImageFormat::Rgba16Snorm => quote! { Some(Format::R16G16B16A16Snorm) },
|
||||
ImageFormat::Rg16Snorm => quote! { Some(Format::R16G16Snorm) },
|
||||
ImageFormat::Rg8Snorm => quote! { Some(Format::R8G8Snorm) },
|
||||
ImageFormat::R16Snorm => quote! { Some(Format::R16Snorm) },
|
||||
ImageFormat::R8Snorm => quote! { Some(Format::R8Snorm) },
|
||||
ImageFormat::Rgba32i => quote! { Some(Format::R32G32B32A32Sint) },
|
||||
ImageFormat::Rgba16i => quote! { Some(Format::R16G16B16A16Sint) },
|
||||
ImageFormat::Rgba8i => quote! { Some(Format::R8G8B8A8Sint) },
|
||||
ImageFormat::R32i => quote! { Some(Format::R32Sint) },
|
||||
ImageFormat::Rg32i => quote! { Some(Format::R32G32Sint) },
|
||||
ImageFormat::Rg16i => quote! { Some(Format::R16G16Sint) },
|
||||
ImageFormat::Rg8i => quote! { Some(Format::R8G8Sint) },
|
||||
ImageFormat::R16i => quote! { Some(Format::R16Sint) },
|
||||
ImageFormat::R8i => quote! { Some(Format::R8Sint) },
|
||||
ImageFormat::Rgba32ui => quote! { Some(Format::R32G32B32A32Uint) },
|
||||
ImageFormat::Rgba16ui => quote! { Some(Format::R16G16B16A16Uint) },
|
||||
ImageFormat::Rgba8ui => quote! { Some(Format::R8G8B8A8Uint) },
|
||||
ImageFormat::R32ui => quote! { Some(Format::R32Uint) },
|
||||
ImageFormat::Rgb10a2ui => quote! { Some(Format::A2B10G10R10UintPack32) },
|
||||
ImageFormat::Rg32ui => quote! { Some(Format::R32G32Uint) },
|
||||
ImageFormat::Rg16ui => quote! { Some(Format::R16G16Uint) },
|
||||
ImageFormat::Rg8ui => quote! { Some(Format::R8G8Uint) },
|
||||
ImageFormat::R16ui => quote! { Some(Format::R16Uint) },
|
||||
ImageFormat::R8ui => quote! { Some(Format::R8Uint) },
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::descriptor_sets::write_pipeline_layout_desc;
|
||||
use crate::enums::{Decoration, ExecutionMode, ExecutionModel, StorageClass};
|
||||
use crate::parse::{Instruction, Spirv};
|
||||
use crate::{spirv_search, TypesMeta};
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use spirv_headers::{Decoration, ExecutionMode, ExecutionModel, StorageClass};
|
||||
use syn::Ident;
|
||||
|
||||
pub(super) fn write_entry_point(
|
||||
@ -32,13 +32,13 @@ pub(super) fn write_entry_point(
|
||||
};
|
||||
|
||||
let ignore_first_array_in = match *execution {
|
||||
ExecutionModel::ExecutionModelTessellationControl => true,
|
||||
ExecutionModel::ExecutionModelTessellationEvaluation => true,
|
||||
ExecutionModel::ExecutionModelGeometry => true,
|
||||
ExecutionModel::TessellationControl => true,
|
||||
ExecutionModel::TessellationEvaluation => true,
|
||||
ExecutionModel::Geometry => true,
|
||||
_ => false,
|
||||
};
|
||||
let ignore_first_array_out = match *execution {
|
||||
ExecutionModel::ExecutionModelTessellationControl => true,
|
||||
ExecutionModel::TessellationControl => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
@ -49,27 +49,35 @@ pub(super) fn write_entry_point(
|
||||
ignore_first_array_out,
|
||||
);
|
||||
|
||||
let stage = if let ExecutionModel::ExecutionModelGLCompute = *execution {
|
||||
let stage = if let ExecutionModel::GLCompute = *execution {
|
||||
quote! { ShaderStages { compute: true, ..ShaderStages::none() } }
|
||||
} else {
|
||||
match *execution {
|
||||
ExecutionModel::ExecutionModelVertex => {
|
||||
ExecutionModel::Vertex => {
|
||||
quote! { ShaderStages { vertex: true, ..ShaderStages::none() } }
|
||||
}
|
||||
ExecutionModel::ExecutionModelTessellationControl => {
|
||||
ExecutionModel::TessellationControl => {
|
||||
quote! { ShaderStages { tessellation_control: true, ..ShaderStages::none() } }
|
||||
}
|
||||
ExecutionModel::ExecutionModelTessellationEvaluation => {
|
||||
ExecutionModel::TessellationEvaluation => {
|
||||
quote! { ShaderStages { tessellation_evaluation: true, ..ShaderStages::none() } }
|
||||
}
|
||||
ExecutionModel::ExecutionModelGeometry => {
|
||||
ExecutionModel::Geometry => {
|
||||
quote! { ShaderStages { geometry: true, ..ShaderStages::none() } }
|
||||
}
|
||||
ExecutionModel::ExecutionModelFragment => {
|
||||
ExecutionModel::Fragment => {
|
||||
quote! { ShaderStages { fragment: true, ..ShaderStages::none() } }
|
||||
}
|
||||
ExecutionModel::ExecutionModelGLCompute => unreachable!(),
|
||||
ExecutionModel::ExecutionModelKernel => unreachable!(),
|
||||
ExecutionModel::GLCompute
|
||||
| ExecutionModel::Kernel
|
||||
| ExecutionModel::TaskNV
|
||||
| ExecutionModel::MeshNV
|
||||
| ExecutionModel::RayGenerationNV
|
||||
| ExecutionModel::IntersectionNV
|
||||
| ExecutionModel::AnyHitNV
|
||||
| ExecutionModel::ClosestHitNV
|
||||
| ExecutionModel::MissNV
|
||||
| ExecutionModel::CallableNV => unreachable!(),
|
||||
}
|
||||
};
|
||||
|
||||
@ -89,7 +97,7 @@ pub(super) fn write_entry_point(
|
||||
};
|
||||
|
||||
let (ty, f_call) = {
|
||||
if let ExecutionModel::ExecutionModelGLCompute = *execution {
|
||||
if let ExecutionModel::GLCompute = *execution {
|
||||
(
|
||||
quote! { ::vulkano::pipeline::shader::ComputeEntryPoint },
|
||||
quote! { compute_entry_point(
|
||||
@ -100,19 +108,19 @@ pub(super) fn write_entry_point(
|
||||
)
|
||||
} else {
|
||||
let entry_ty = match *execution {
|
||||
ExecutionModel::ExecutionModelVertex => {
|
||||
ExecutionModel::Vertex => {
|
||||
quote! { ::vulkano::pipeline::shader::GraphicsShaderType::Vertex }
|
||||
}
|
||||
|
||||
ExecutionModel::ExecutionModelTessellationControl => {
|
||||
ExecutionModel::TessellationControl => {
|
||||
quote! { ::vulkano::pipeline::shader::GraphicsShaderType::TessellationControl }
|
||||
}
|
||||
|
||||
ExecutionModel::ExecutionModelTessellationEvaluation => {
|
||||
ExecutionModel::TessellationEvaluation => {
|
||||
quote! { ::vulkano::pipeline::shader::GraphicsShaderType::TessellationEvaluation }
|
||||
}
|
||||
|
||||
ExecutionModel::ExecutionModelGeometry => {
|
||||
ExecutionModel::Geometry => {
|
||||
let mut execution_mode = None;
|
||||
|
||||
for instruction in doc.instructions.iter() {
|
||||
@ -124,19 +132,13 @@ pub(super) fn write_entry_point(
|
||||
{
|
||||
if target_id == id {
|
||||
execution_mode = match mode {
|
||||
&ExecutionMode::ExecutionModeInputPoints => {
|
||||
Some(quote! { Points })
|
||||
}
|
||||
&ExecutionMode::ExecutionModeInputLines => {
|
||||
Some(quote! { Lines })
|
||||
}
|
||||
&ExecutionMode::ExecutionModeInputLinesAdjacency => {
|
||||
&ExecutionMode::InputPoints => Some(quote! { Points }),
|
||||
&ExecutionMode::InputLines => Some(quote! { Lines }),
|
||||
&ExecutionMode::InputLinesAdjacency => {
|
||||
Some(quote! { LinesWithAdjacency })
|
||||
}
|
||||
&ExecutionMode::ExecutionModeTriangles => {
|
||||
Some(quote! { Triangles })
|
||||
}
|
||||
&ExecutionMode::ExecutionModeInputTrianglesAdjacency => {
|
||||
&ExecutionMode::Triangles => Some(quote! { Triangles }),
|
||||
&ExecutionMode::InputTrianglesAdjacency => {
|
||||
Some(quote! { TrianglesWithAdjacency })
|
||||
}
|
||||
_ => continue,
|
||||
@ -153,13 +155,23 @@ pub(super) fn write_entry_point(
|
||||
}
|
||||
}
|
||||
|
||||
ExecutionModel::ExecutionModelFragment => {
|
||||
ExecutionModel::Fragment => {
|
||||
quote! { ::vulkano::pipeline::shader::GraphicsShaderType::Fragment }
|
||||
}
|
||||
|
||||
ExecutionModel::ExecutionModelGLCompute => unreachable!(),
|
||||
ExecutionModel::GLCompute => unreachable!(),
|
||||
|
||||
ExecutionModel::ExecutionModelKernel => panic!("Kernels are not supported"),
|
||||
ExecutionModel::Kernel
|
||||
| ExecutionModel::TaskNV
|
||||
| ExecutionModel::MeshNV
|
||||
| ExecutionModel::RayGenerationNV
|
||||
| ExecutionModel::IntersectionNV
|
||||
| ExecutionModel::AnyHitNV
|
||||
| ExecutionModel::ClosestHitNV
|
||||
| ExecutionModel::MissNV
|
||||
| ExecutionModel::CallableNV => {
|
||||
panic!("Shaders with {:?} are not supported", execution)
|
||||
}
|
||||
};
|
||||
|
||||
let ty = quote! { ::vulkano::pipeline::shader::GraphicsEntryPoint };
|
||||
@ -232,12 +244,8 @@ fn write_interfaces(
|
||||
}
|
||||
|
||||
let (to_write, ignore_first_array) = match storage_class {
|
||||
&StorageClass::StorageClassInput => {
|
||||
(&mut input_elements, ignore_first_array_in)
|
||||
}
|
||||
&StorageClass::StorageClassOutput => {
|
||||
(&mut output_elements, ignore_first_array_out)
|
||||
}
|
||||
&StorageClass::Input => (&mut input_elements, ignore_first_array_in),
|
||||
&StorageClass::Output => (&mut output_elements, ignore_first_array_out),
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
@ -246,8 +254,7 @@ fn write_interfaces(
|
||||
continue;
|
||||
} // FIXME: hack
|
||||
|
||||
let location = match doc
|
||||
.get_decoration_params(result_id, Decoration::DecorationLocation)
|
||||
let location = match doc.get_decoration_params(result_id, Decoration::Location)
|
||||
{
|
||||
Some(l) => l[0],
|
||||
None => panic!(
|
||||
|
@ -1,559 +0,0 @@
|
||||
// Copyright (c) 2016 The vulkano developers
|
||||
// Licensed under the Apache License, Version 2.0
|
||||
// <LICENSE-APACHE or
|
||||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
|
||||
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
|
||||
// at your option. All files in the project carrying such
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use crate::parse::ParseError;
|
||||
|
||||
macro_rules! enumeration {
|
||||
($(typedef enum $unused:ident { $($elem:ident = $value:expr,)+ } $name:ident;)+) => (
|
||||
$(
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum $name {
|
||||
$($elem),+
|
||||
}
|
||||
|
||||
impl $name {
|
||||
pub fn from_num(num: u32) -> Result<$name, ParseError> {
|
||||
match num {
|
||||
$(
|
||||
$value => Ok($name::$elem),
|
||||
)+
|
||||
_ => Err(ParseError::UnknownConstant(stringify!($name), num)),
|
||||
}
|
||||
}
|
||||
}
|
||||
)+
|
||||
)
|
||||
}
|
||||
|
||||
// The code below is a copy-paste from `spirv-2.h`, with the `Spv` prefixes removed.
|
||||
|
||||
enumeration! {
|
||||
typedef enum SourceLanguage_ {
|
||||
SourceLanguageUnknown = 0,
|
||||
SourceLanguageESSL = 1,
|
||||
SourceLanguageGLSL = 2,
|
||||
SourceLanguageOpenCL_C = 3,
|
||||
SourceLanguageOpenCL_CPP = 4,
|
||||
} SourceLanguage;
|
||||
|
||||
typedef enum ExecutionModel_ {
|
||||
ExecutionModelVertex = 0,
|
||||
ExecutionModelTessellationControl = 1,
|
||||
ExecutionModelTessellationEvaluation = 2,
|
||||
ExecutionModelGeometry = 3,
|
||||
ExecutionModelFragment = 4,
|
||||
ExecutionModelGLCompute = 5,
|
||||
ExecutionModelKernel = 6,
|
||||
} ExecutionModel;
|
||||
|
||||
typedef enum AddressingModel_ {
|
||||
AddressingModelLogical = 0,
|
||||
AddressingModelPhysical32 = 1,
|
||||
AddressingModelPhysical64 = 2,
|
||||
} AddressingModel;
|
||||
|
||||
typedef enum MemoryModel_ {
|
||||
MemoryModelSimple = 0,
|
||||
MemoryModelGLSL450 = 1,
|
||||
MemoryModelOpenCL = 2,
|
||||
} MemoryModel;
|
||||
|
||||
typedef enum ExecutionMode_ {
|
||||
ExecutionModeInvocations = 0,
|
||||
ExecutionModeSpacingEqual = 1,
|
||||
ExecutionModeSpacingFractionalEven = 2,
|
||||
ExecutionModeSpacingFractionalOdd = 3,
|
||||
ExecutionModeVertexOrderCw = 4,
|
||||
ExecutionModeVertexOrderCcw = 5,
|
||||
ExecutionModePixelCenterInteger = 6,
|
||||
ExecutionModeOriginUpperLeft = 7,
|
||||
ExecutionModeOriginLowerLeft = 8,
|
||||
ExecutionModeEarlyFragmentTests = 9,
|
||||
ExecutionModePointMode = 10,
|
||||
ExecutionModeXfb = 11,
|
||||
ExecutionModeDepthReplacing = 12,
|
||||
ExecutionModeDepthGreater = 14,
|
||||
ExecutionModeDepthLess = 15,
|
||||
ExecutionModeDepthUnchanged = 16,
|
||||
ExecutionModeLocalSize = 17,
|
||||
ExecutionModeLocalSizeHint = 18,
|
||||
ExecutionModeInputPoints = 19,
|
||||
ExecutionModeInputLines = 20,
|
||||
ExecutionModeInputLinesAdjacency = 21,
|
||||
ExecutionModeTriangles = 22,
|
||||
ExecutionModeInputTrianglesAdjacency = 23,
|
||||
ExecutionModeQuads = 24,
|
||||
ExecutionModeIsolines = 25,
|
||||
ExecutionModeOutputVertices = 26,
|
||||
ExecutionModeOutputPoints = 27,
|
||||
ExecutionModeOutputLineStrip = 28,
|
||||
ExecutionModeOutputTriangleStrip = 29,
|
||||
ExecutionModeVecTypeHint = 30,
|
||||
ExecutionModeContractionOff = 31,
|
||||
} ExecutionMode;
|
||||
|
||||
typedef enum StorageClass_ {
|
||||
StorageClassUniformConstant = 0,
|
||||
StorageClassInput = 1,
|
||||
StorageClassUniform = 2,
|
||||
StorageClassOutput = 3,
|
||||
StorageClassWorkgroup = 4,
|
||||
StorageClassCrossWorkgroup = 5,
|
||||
StorageClassPrivate = 6,
|
||||
StorageClassFunction = 7,
|
||||
StorageClassGeneric = 8,
|
||||
StorageClassPushConstant = 9,
|
||||
StorageClassAtomicCounter = 10,
|
||||
StorageClassImage = 11,
|
||||
StorageClassStorageBuffer = 12,
|
||||
} StorageClass;
|
||||
|
||||
typedef enum Dim_ {
|
||||
Dim1D = 0,
|
||||
Dim2D = 1,
|
||||
Dim3D = 2,
|
||||
DimCube = 3,
|
||||
DimRect = 4,
|
||||
DimBuffer = 5,
|
||||
DimSubpassData = 6,
|
||||
} Dim;
|
||||
|
||||
typedef enum SamplerAddressingMode_ {
|
||||
SamplerAddressingModeNone = 0,
|
||||
SamplerAddressingModeClampToEdge = 1,
|
||||
SamplerAddressingModeClamp = 2,
|
||||
SamplerAddressingModeRepeat = 3,
|
||||
SamplerAddressingModeRepeatMirrored = 4,
|
||||
} SamplerAddressingMode;
|
||||
|
||||
typedef enum SamplerFilterMode_ {
|
||||
SamplerFilterModeNearest = 0,
|
||||
SamplerFilterModeLinear = 1,
|
||||
} SamplerFilterMode;
|
||||
|
||||
typedef enum ImageFormat_ {
|
||||
ImageFormatUnknown = 0,
|
||||
ImageFormatRgba32f = 1,
|
||||
ImageFormatRgba16f = 2,
|
||||
ImageFormatR32f = 3,
|
||||
ImageFormatRgba8 = 4,
|
||||
ImageFormatRgba8Snorm = 5,
|
||||
ImageFormatRg32f = 6,
|
||||
ImageFormatRg16f = 7,
|
||||
ImageFormatR11fG11fB10f = 8,
|
||||
ImageFormatR16f = 9,
|
||||
ImageFormatRgba16 = 10,
|
||||
ImageFormatRgb10A2 = 11,
|
||||
ImageFormatRg16 = 12,
|
||||
ImageFormatRg8 = 13,
|
||||
ImageFormatR16 = 14,
|
||||
ImageFormatR8 = 15,
|
||||
ImageFormatRgba16Snorm = 16,
|
||||
ImageFormatRg16Snorm = 17,
|
||||
ImageFormatRg8Snorm = 18,
|
||||
ImageFormatR16Snorm = 19,
|
||||
ImageFormatR8Snorm = 20,
|
||||
ImageFormatRgba32i = 21,
|
||||
ImageFormatRgba16i = 22,
|
||||
ImageFormatRgba8i = 23,
|
||||
ImageFormatR32i = 24,
|
||||
ImageFormatRg32i = 25,
|
||||
ImageFormatRg16i = 26,
|
||||
ImageFormatRg8i = 27,
|
||||
ImageFormatR16i = 28,
|
||||
ImageFormatR8i = 29,
|
||||
ImageFormatRgba32ui = 30,
|
||||
ImageFormatRgba16ui = 31,
|
||||
ImageFormatRgba8ui = 32,
|
||||
ImageFormatR32ui = 33,
|
||||
ImageFormatRgb10a2ui = 34,
|
||||
ImageFormatRg32ui = 35,
|
||||
ImageFormatRg16ui = 36,
|
||||
ImageFormatRg8ui = 37,
|
||||
ImageFormatR16ui = 38,
|
||||
ImageFormatR8ui = 39,
|
||||
} ImageFormat;
|
||||
|
||||
typedef enum ImageChannelOrder_ {
|
||||
ImageChannelOrderR = 0,
|
||||
ImageChannelOrderA = 1,
|
||||
ImageChannelOrderRG = 2,
|
||||
ImageChannelOrderRA = 3,
|
||||
ImageChannelOrderRGB = 4,
|
||||
ImageChannelOrderRGBA = 5,
|
||||
ImageChannelOrderBGRA = 6,
|
||||
ImageChannelOrderARGB = 7,
|
||||
ImageChannelOrderIntensity = 8,
|
||||
ImageChannelOrderLuminance = 9,
|
||||
ImageChannelOrderRx = 10,
|
||||
ImageChannelOrderRGx = 11,
|
||||
ImageChannelOrderRGBx = 12,
|
||||
ImageChannelOrderDepth = 13,
|
||||
ImageChannelOrderDepthStencil = 14,
|
||||
ImageChannelOrdersRGB = 15,
|
||||
ImageChannelOrdersRGBx = 16,
|
||||
ImageChannelOrdersRGBA = 17,
|
||||
ImageChannelOrdersBGRA = 18,
|
||||
} ImageChannelOrder;
|
||||
|
||||
typedef enum ImageChannelDataType_ {
|
||||
ImageChannelDataTypeSnormInt8 = 0,
|
||||
ImageChannelDataTypeSnormInt16 = 1,
|
||||
ImageChannelDataTypeUnormInt8 = 2,
|
||||
ImageChannelDataTypeUnormInt16 = 3,
|
||||
ImageChannelDataTypeUnormShort565 = 4,
|
||||
ImageChannelDataTypeUnormShort555 = 5,
|
||||
ImageChannelDataTypeUnormInt101010 = 6,
|
||||
ImageChannelDataTypeSignedInt8 = 7,
|
||||
ImageChannelDataTypeSignedInt16 = 8,
|
||||
ImageChannelDataTypeSignedInt32 = 9,
|
||||
ImageChannelDataTypeUnsignedInt8 = 10,
|
||||
ImageChannelDataTypeUnsignedInt16 = 11,
|
||||
ImageChannelDataTypeUnsignedInt32 = 12,
|
||||
ImageChannelDataTypeHalfFloat = 13,
|
||||
ImageChannelDataTypeFloat = 14,
|
||||
ImageChannelDataTypeUnormInt24 = 15,
|
||||
ImageChannelDataTypeUnormInt101010_2 = 16,
|
||||
} ImageChannelDataType;
|
||||
|
||||
typedef enum ImageOperandsShift_ {
|
||||
ImageOperandsBiasShift = 0,
|
||||
ImageOperandsLodShift = 1,
|
||||
ImageOperandsGradShift = 2,
|
||||
ImageOperandsConstOffsetShift = 3,
|
||||
ImageOperandsOffsetShift = 4,
|
||||
ImageOperandsConstOffsetsShift = 5,
|
||||
ImageOperandsSampleShift = 6,
|
||||
ImageOperandsMinLodShift = 7,
|
||||
} ImageOperandsShift;
|
||||
|
||||
typedef enum ImageOperandsMask_ {
|
||||
ImageOperandsMaskNone = 0,
|
||||
ImageOperandsBiasMask = 0x00000001,
|
||||
ImageOperandsLodMask = 0x00000002,
|
||||
ImageOperandsGradMask = 0x00000004,
|
||||
ImageOperandsConstOffsetMask = 0x00000008,
|
||||
ImageOperandsOffsetMask = 0x00000010,
|
||||
ImageOperandsConstOffsetsMask = 0x00000020,
|
||||
ImageOperandsSampleMask = 0x00000040,
|
||||
ImageOperandsMinLodMask = 0x00000080,
|
||||
} ImageOperandsMask;
|
||||
|
||||
typedef enum FPFastMathModeShift_ {
|
||||
FPFastMathModeNotNaNShift = 0,
|
||||
FPFastMathModeNotInfShift = 1,
|
||||
FPFastMathModeNSZShift = 2,
|
||||
FPFastMathModeAllowRecipShift = 3,
|
||||
FPFastMathModeFastShift = 4,
|
||||
} FPFastMathModeShift;
|
||||
|
||||
typedef enum FPFastMathModeMask_ {
|
||||
FPFastMathModeMaskNone = 0,
|
||||
FPFastMathModeNotNaNMask = 0x00000001,
|
||||
FPFastMathModeNotInfMask = 0x00000002,
|
||||
FPFastMathModeNSZMask = 0x00000004,
|
||||
FPFastMathModeAllowRecipMask = 0x00000008,
|
||||
FPFastMathModeFastMask = 0x00000010,
|
||||
} FPFastMathModeMask;
|
||||
|
||||
typedef enum FPRoundingMode_ {
|
||||
FPRoundingModeRTE = 0,
|
||||
FPRoundingModeRTZ = 1,
|
||||
FPRoundingModeRTP = 2,
|
||||
FPRoundingModeRTN = 3,
|
||||
} FPRoundingMode;
|
||||
|
||||
typedef enum LinkageType_ {
|
||||
LinkageTypeExport = 0,
|
||||
LinkageTypeImport = 1,
|
||||
} LinkageType;
|
||||
|
||||
typedef enum AccessQualifier_ {
|
||||
AccessQualifierReadOnly = 0,
|
||||
AccessQualifierWriteOnly = 1,
|
||||
AccessQualifierReadWrite = 2,
|
||||
} AccessQualifier;
|
||||
|
||||
typedef enum FunctionParameterAttribute_ {
|
||||
FunctionParameterAttributeZext = 0,
|
||||
FunctionParameterAttributeSext = 1,
|
||||
FunctionParameterAttributeByVal = 2,
|
||||
FunctionParameterAttributeSret = 3,
|
||||
FunctionParameterAttributeNoAlias = 4,
|
||||
FunctionParameterAttributeNoCapture = 5,
|
||||
FunctionParameterAttributeNoWrite = 6,
|
||||
FunctionParameterAttributeNoReadWrite = 7,
|
||||
} FunctionParameterAttribute;
|
||||
|
||||
typedef enum Decoration_ {
|
||||
DecorationRelaxedPrecision = 0,
|
||||
DecorationSpecId = 1,
|
||||
DecorationBlock = 2,
|
||||
DecorationBufferBlock = 3,
|
||||
DecorationRowMajor = 4,
|
||||
DecorationColMajor = 5,
|
||||
DecorationArrayStride = 6,
|
||||
DecorationMatrixStride = 7,
|
||||
DecorationGLSLShared = 8,
|
||||
DecorationGLSLPacked = 9,
|
||||
DecorationCPacked = 10,
|
||||
DecorationBuiltIn = 11,
|
||||
DecorationNoPerspective = 13,
|
||||
DecorationFlat = 14,
|
||||
DecorationPatch = 15,
|
||||
DecorationCentroid = 16,
|
||||
DecorationSample = 17,
|
||||
DecorationInvariant = 18,
|
||||
DecorationRestrict = 19,
|
||||
DecorationAliased = 20,
|
||||
DecorationVolatile = 21,
|
||||
DecorationConstant = 22,
|
||||
DecorationCoherent = 23,
|
||||
DecorationNonWritable = 24,
|
||||
DecorationNonReadable = 25,
|
||||
DecorationUniform = 26,
|
||||
DecorationSaturatedConversion = 28,
|
||||
DecorationStream = 29,
|
||||
DecorationLocation = 30,
|
||||
DecorationComponent = 31,
|
||||
DecorationIndex = 32,
|
||||
DecorationBinding = 33,
|
||||
DecorationDescriptorSet = 34,
|
||||
DecorationOffset = 35,
|
||||
DecorationXfbBuffer = 36,
|
||||
DecorationXfbStride = 37,
|
||||
DecorationFuncParamAttr = 38,
|
||||
DecorationFPRoundingMode = 39,
|
||||
DecorationFPFastMathMode = 40,
|
||||
DecorationLinkageAttributes = 41,
|
||||
DecorationNoContraction = 42,
|
||||
DecorationInputAttachmentIndex = 43,
|
||||
DecorationAlignment = 44,
|
||||
} Decoration;
|
||||
|
||||
typedef enum BuiltIn_ {
|
||||
BuiltInPosition = 0,
|
||||
BuiltInPointSize = 1,
|
||||
BuiltInClipDistance = 3,
|
||||
BuiltInCullDistance = 4,
|
||||
BuiltInVertexId = 5,
|
||||
BuiltInInstanceId = 6,
|
||||
BuiltInPrimitiveId = 7,
|
||||
BuiltInInvocationId = 8,
|
||||
BuiltInLayer = 9,
|
||||
BuiltInViewportIndex = 10,
|
||||
BuiltInTessLevelOuter = 11,
|
||||
BuiltInTessLevelInner = 12,
|
||||
BuiltInTessCoord = 13,
|
||||
BuiltInPatchVertices = 14,
|
||||
BuiltInFragCoord = 15,
|
||||
BuiltInPointCoord = 16,
|
||||
BuiltInFrontFacing = 17,
|
||||
BuiltInSampleId = 18,
|
||||
BuiltInSamplePosition = 19,
|
||||
BuiltInSampleMask = 20,
|
||||
BuiltInFragDepth = 22,
|
||||
BuiltInHelperInvocation = 23,
|
||||
BuiltInNumWorkgroups = 24,
|
||||
BuiltInWorkgroupSize = 25,
|
||||
BuiltInWorkgroupId = 26,
|
||||
BuiltInLocalInvocationId = 27,
|
||||
BuiltInGlobalInvocationId = 28,
|
||||
BuiltInLocalInvocationIndex = 29,
|
||||
BuiltInWorkDim = 30,
|
||||
BuiltInGlobalSize = 31,
|
||||
BuiltInEnqueuedWorkgroupSize = 32,
|
||||
BuiltInGlobalOffset = 33,
|
||||
BuiltInGlobalLinearId = 34,
|
||||
BuiltInSubgroupSize = 36,
|
||||
BuiltInSubgroupMaxSize = 37,
|
||||
BuiltInNumSubgroups = 38,
|
||||
BuiltInNumEnqueuedSubgroups = 39,
|
||||
BuiltInSubgroupId = 40,
|
||||
BuiltInSubgroupLocalInvocationId = 41,
|
||||
BuiltInVertexIndex = 42,
|
||||
BuiltInInstanceIndex = 43,
|
||||
} BuiltIn;
|
||||
|
||||
typedef enum SelectionControlShift_ {
|
||||
SelectionControlFlattenShift = 0,
|
||||
SelectionControlDontFlattenShift = 1,
|
||||
} SelectionControlShift;
|
||||
|
||||
typedef enum SelectionControlMask_ {
|
||||
SelectionControlMaskNone = 0,
|
||||
SelectionControlFlattenMask = 0x00000001,
|
||||
SelectionControlDontFlattenMask = 0x00000002,
|
||||
} SelectionControlMask;
|
||||
|
||||
typedef enum LoopControlShift_ {
|
||||
LoopControlUnrollShift = 0,
|
||||
LoopControlDontUnrollShift = 1,
|
||||
} LoopControlShift;
|
||||
|
||||
typedef enum LoopControlMask_ {
|
||||
LoopControlMaskNone = 0,
|
||||
LoopControlUnrollMask = 0x00000001,
|
||||
LoopControlDontUnrollMask = 0x00000002,
|
||||
} LoopControlMask;
|
||||
|
||||
typedef enum FunctionControlShift_ {
|
||||
FunctionControlInlineShift = 0,
|
||||
FunctionControlDontInlineShift = 1,
|
||||
FunctionControlPureShift = 2,
|
||||
FunctionControlConstShift = 3,
|
||||
} FunctionControlShift;
|
||||
|
||||
typedef enum FunctionControlMask_ {
|
||||
FunctionControlMaskNone = 0,
|
||||
FunctionControlInlineMask = 0x00000001,
|
||||
FunctionControlDontInlineMask = 0x00000002,
|
||||
FunctionControlPureMask = 0x00000004,
|
||||
FunctionControlConstMask = 0x00000008,
|
||||
} FunctionControlMask;
|
||||
|
||||
typedef enum MemorySemanticsShift_ {
|
||||
MemorySemanticsAcquireShift = 1,
|
||||
MemorySemanticsReleaseShift = 2,
|
||||
MemorySemanticsAcquireReleaseShift = 3,
|
||||
MemorySemanticsSequentiallyConsistentShift = 4,
|
||||
MemorySemanticsUniformMemoryShift = 6,
|
||||
MemorySemanticsSubgroupMemoryShift = 7,
|
||||
MemorySemanticsWorkgroupMemoryShift = 8,
|
||||
MemorySemanticsCrossWorkgroupMemoryShift = 9,
|
||||
MemorySemanticsAtomicCounterMemoryShift = 10,
|
||||
MemorySemanticsImageMemoryShift = 11,
|
||||
} MemorySemanticsShift;
|
||||
|
||||
typedef enum MemorySemanticsMask_ {
|
||||
MemorySemanticsMaskNone = 0,
|
||||
MemorySemanticsAcquireMask = 0x00000002,
|
||||
MemorySemanticsReleaseMask = 0x00000004,
|
||||
MemorySemanticsAcquireReleaseMask = 0x00000008,
|
||||
MemorySemanticsSequentiallyConsistentMask = 0x00000010,
|
||||
MemorySemanticsUniformMemoryMask = 0x00000040,
|
||||
MemorySemanticsSubgroupMemoryMask = 0x00000080,
|
||||
MemorySemanticsWorkgroupMemoryMask = 0x00000100,
|
||||
MemorySemanticsCrossWorkgroupMemoryMask = 0x00000200,
|
||||
MemorySemanticsAtomicCounterMemoryMask = 0x00000400,
|
||||
MemorySemanticsImageMemoryMask = 0x00000800,
|
||||
} MemorySemanticsMask;
|
||||
|
||||
typedef enum MemoryAccessShift_ {
|
||||
MemoryAccessVolatileShift = 0,
|
||||
MemoryAccessAlignedShift = 1,
|
||||
MemoryAccessNontemporalShift = 2,
|
||||
} MemoryAccessShift;
|
||||
|
||||
typedef enum MemoryAccessMask_ {
|
||||
MemoryAccessMaskNone = 0,
|
||||
MemoryAccessVolatileMask = 0x00000001,
|
||||
MemoryAccessAlignedMask = 0x00000002,
|
||||
MemoryAccessNontemporalMask = 0x00000004,
|
||||
} MemoryAccessMask;
|
||||
|
||||
typedef enum Scope_ {
|
||||
ScopeCrossDevice = 0,
|
||||
ScopeDevice = 1,
|
||||
ScopeWorkgroup = 2,
|
||||
ScopeSubgroup = 3,
|
||||
ScopeInvocation = 4,
|
||||
} Scope;
|
||||
|
||||
typedef enum GroupOperation_ {
|
||||
GroupOperationReduce = 0,
|
||||
GroupOperationInclusiveScan = 1,
|
||||
GroupOperationExclusiveScan = 2,
|
||||
} GroupOperation;
|
||||
|
||||
typedef enum KernelEnqueueFlags_ {
|
||||
KernelEnqueueFlagsNoWait = 0,
|
||||
KernelEnqueueFlagsWaitKernel = 1,
|
||||
KernelEnqueueFlagsWaitWorkGroup = 2,
|
||||
} KernelEnqueueFlags;
|
||||
|
||||
typedef enum KernelProfilingInfoShift_ {
|
||||
KernelProfilingInfoCmdExecTimeShift = 0,
|
||||
} KernelProfilingInfoShift;
|
||||
|
||||
typedef enum KernelProfilingInfoMask_ {
|
||||
KernelProfilingInfoMaskNone = 0,
|
||||
KernelProfilingInfoCmdExecTimeMask = 0x00000001,
|
||||
} KernelProfilingInfoMask;
|
||||
|
||||
typedef enum Capability_ {
|
||||
CapabilityMatrix = 0,
|
||||
CapabilityShader = 1,
|
||||
CapabilityGeometry = 2,
|
||||
CapabilityTessellation = 3,
|
||||
CapabilityAddresses = 4,
|
||||
CapabilityLinkage = 5,
|
||||
CapabilityKernel = 6,
|
||||
CapabilityVector16 = 7,
|
||||
CapabilityFloat16Buffer = 8,
|
||||
CapabilityFloat16 = 9,
|
||||
CapabilityFloat64 = 10,
|
||||
CapabilityInt64 = 11,
|
||||
CapabilityInt64Atomics = 12,
|
||||
CapabilityImageBasic = 13,
|
||||
CapabilityImageReadWrite = 14,
|
||||
CapabilityImageMipmap = 15,
|
||||
CapabilityPipes = 17,
|
||||
CapabilityGroups = 18,
|
||||
CapabilityDeviceEnqueue = 19,
|
||||
CapabilityLiteralSampler = 20,
|
||||
CapabilityAtomicStorage = 21,
|
||||
CapabilityInt16 = 22,
|
||||
CapabilityTessellationPointSize = 23,
|
||||
CapabilityGeometryPointSize = 24,
|
||||
CapabilityImageGatherExtended = 25,
|
||||
CapabilityStorageImageMultisample = 27,
|
||||
CapabilityUniformBufferArrayDynamicIndexing = 28,
|
||||
CapabilitySampledImageArrayDynamicIndexing = 29,
|
||||
CapabilityStorageBufferArrayDynamicIndexing = 30,
|
||||
CapabilityStorageImageArrayDynamicIndexing = 31,
|
||||
CapabilityClipDistance = 32,
|
||||
CapabilityCullDistance = 33,
|
||||
CapabilityImageCubeArray = 34,
|
||||
CapabilitySampleRateShading = 35,
|
||||
CapabilityImageRect = 36,
|
||||
CapabilitySampledRect = 37,
|
||||
CapabilityGenericPointer = 38,
|
||||
CapabilityInt8 = 39,
|
||||
CapabilityInputAttachment = 40,
|
||||
CapabilitySparseResidency = 41,
|
||||
CapabilityMinLod = 42,
|
||||
CapabilitySampled1D = 43,
|
||||
CapabilityImage1D = 44,
|
||||
CapabilitySampledCubeArray = 45,
|
||||
CapabilitySampledBuffer = 46,
|
||||
CapabilityImageBuffer = 47,
|
||||
CapabilityImageMSArray = 48,
|
||||
CapabilityStorageImageExtendedFormats = 49,
|
||||
CapabilityImageQuery = 50,
|
||||
CapabilityDerivativeControl = 51,
|
||||
CapabilityInterpolationFunction = 52,
|
||||
CapabilityTransformFeedback = 53,
|
||||
CapabilityGeometryStreams = 54,
|
||||
CapabilityStorageImageReadWithoutFormat = 55,
|
||||
CapabilityStorageImageWriteWithoutFormat = 56,
|
||||
CapabilityMultiViewport = 57,
|
||||
CapabilityDrawParameters = 4427,
|
||||
CapabilityStorageUniformBufferBlock16 = 4433,
|
||||
CapabilityStorageUniform16 = 4434,
|
||||
CapabilityStoragePushConstant16 = 4435,
|
||||
CapabilityStorageInputOutput16 = 4436,
|
||||
CapabilityMultiView = 4439,
|
||||
CapabilityStorageInputOutput8 = 4448,
|
||||
CapabilityStoragePushConstant8 = 4450,
|
||||
} Capability;
|
||||
}
|
@ -233,7 +233,6 @@ use syn::{
|
||||
mod codegen;
|
||||
mod descriptor_sets;
|
||||
mod entry_point;
|
||||
mod enums;
|
||||
mod parse;
|
||||
mod spec_consts;
|
||||
mod spirv_search;
|
||||
|
@ -7,7 +7,11 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::enums::*;
|
||||
use num_traits::FromPrimitive;
|
||||
use spirv_headers::{
|
||||
AccessQualifier, AddressingModel, Capability, Decoration, Dim, ExecutionMode, ExecutionModel,
|
||||
ImageFormat, MemoryModel, Op, StorageClass,
|
||||
};
|
||||
|
||||
/// Parses a SPIR-V document from a list of words.
|
||||
pub fn parse_spirv(i: &[u32]) -> Result<Spirv, ParseError> {
|
||||
@ -430,76 +434,89 @@ fn parse_instruction(i: &[u32]) -> Result<(Instruction, &[u32]), ParseError> {
|
||||
}
|
||||
|
||||
fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, ParseError> {
|
||||
Ok(match opcode {
|
||||
0 => Instruction::Nop,
|
||||
5 => Instruction::Name {
|
||||
let instruction = match Op::from_u16(opcode) {
|
||||
Some(x) => x,
|
||||
None => return Ok(Instruction::Unknown(opcode, operands.to_owned())),
|
||||
};
|
||||
|
||||
Ok(match instruction {
|
||||
Op::Nop => Instruction::Nop,
|
||||
Op::Name => Instruction::Name {
|
||||
target_id: operands[0],
|
||||
name: parse_string(&operands[1..]).0,
|
||||
},
|
||||
6 => Instruction::MemberName {
|
||||
Op::MemberName => Instruction::MemberName {
|
||||
target_id: operands[0],
|
||||
member: operands[1],
|
||||
name: parse_string(&operands[2..]).0,
|
||||
},
|
||||
11 => Instruction::ExtInstImport {
|
||||
Op::ExtInstImport => Instruction::ExtInstImport {
|
||||
result_id: operands[0],
|
||||
name: parse_string(&operands[1..]).0,
|
||||
},
|
||||
12 => Instruction::ExtInst {
|
||||
Op::ExtInst => Instruction::ExtInst {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
set: operands[2],
|
||||
instruction: operands[3],
|
||||
operands: operands[4..].to_owned(),
|
||||
},
|
||||
14 => Instruction::MemoryModel(
|
||||
AddressingModel::from_num(operands[0])?,
|
||||
MemoryModel::from_num(operands[1])?,
|
||||
Op::MemoryModel => Instruction::MemoryModel(
|
||||
AddressingModel::from_u32(operands[0])
|
||||
.ok_or(ParseError::UnknownConstant("AddressingModel", operands[0]))?,
|
||||
MemoryModel::from_u32(operands[1])
|
||||
.ok_or(ParseError::UnknownConstant("MemoryModel", operands[1]))?,
|
||||
),
|
||||
15 => {
|
||||
Op::EntryPoint => {
|
||||
let (n, r) = parse_string(&operands[2..]);
|
||||
Instruction::EntryPoint {
|
||||
execution: ExecutionModel::from_num(operands[0])?,
|
||||
execution: ExecutionModel::from_u32(operands[0])
|
||||
.ok_or(ParseError::UnknownConstant("ExecutionModel", operands[0]))?,
|
||||
id: operands[1],
|
||||
name: n,
|
||||
interface: r.to_owned(),
|
||||
}
|
||||
}
|
||||
16 => Instruction::ExecutionMode {
|
||||
Op::ExecutionMode => Instruction::ExecutionMode {
|
||||
target_id: operands[0],
|
||||
mode: ExecutionMode::from_num(operands[1])?,
|
||||
mode: ExecutionMode::from_u32(operands[1])
|
||||
.ok_or(ParseError::UnknownConstant("ExecutionMode", operands[0]))?,
|
||||
optional_literals: operands[2..].to_vec(),
|
||||
},
|
||||
17 => Instruction::Capability(Capability::from_num(operands[0])?),
|
||||
19 => Instruction::TypeVoid {
|
||||
Op::Capability => Instruction::Capability(
|
||||
Capability::from_u32(operands[0])
|
||||
.ok_or(ParseError::UnknownConstant("Capability", operands[0]))?,
|
||||
),
|
||||
Op::TypeVoid => Instruction::TypeVoid {
|
||||
result_id: operands[0],
|
||||
},
|
||||
20 => Instruction::TypeBool {
|
||||
Op::TypeBool => Instruction::TypeBool {
|
||||
result_id: operands[0],
|
||||
},
|
||||
21 => Instruction::TypeInt {
|
||||
Op::TypeInt => Instruction::TypeInt {
|
||||
result_id: operands[0],
|
||||
width: operands[1],
|
||||
signedness: operands[2] != 0,
|
||||
},
|
||||
22 => Instruction::TypeFloat {
|
||||
Op::TypeFloat => Instruction::TypeFloat {
|
||||
result_id: operands[0],
|
||||
width: operands[1],
|
||||
},
|
||||
23 => Instruction::TypeVector {
|
||||
Op::TypeVector => Instruction::TypeVector {
|
||||
result_id: operands[0],
|
||||
component_id: operands[1],
|
||||
count: operands[2],
|
||||
},
|
||||
24 => Instruction::TypeMatrix {
|
||||
Op::TypeMatrix => Instruction::TypeMatrix {
|
||||
result_id: operands[0],
|
||||
column_type_id: operands[1],
|
||||
column_count: operands[2],
|
||||
},
|
||||
25 => Instruction::TypeImage {
|
||||
Op::TypeImage => Instruction::TypeImage {
|
||||
result_id: operands[0],
|
||||
sampled_type_id: operands[1],
|
||||
dim: Dim::from_num(operands[2])?,
|
||||
dim: Dim::from_u32(operands[2])
|
||||
.ok_or(ParseError::UnknownConstant("Dim", operands[2]))?,
|
||||
depth: match operands[3] {
|
||||
0 => Some(false),
|
||||
1 => Some(true),
|
||||
@ -514,161 +531,169 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
2 => Some(false),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
format: ImageFormat::from_num(operands[7])?,
|
||||
format: ImageFormat::from_u32(operands[7])
|
||||
.ok_or(ParseError::UnknownConstant("ImageFormat", operands[7]))?,
|
||||
access: if operands.len() >= 9 {
|
||||
Some(AccessQualifier::from_num(operands[8])?)
|
||||
Some(
|
||||
AccessQualifier::from_u32(operands[8])
|
||||
.ok_or(ParseError::UnknownConstant("AccessQualifier", operands[8]))?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
},
|
||||
26 => Instruction::TypeSampler {
|
||||
Op::TypeSampler => Instruction::TypeSampler {
|
||||
result_id: operands[0],
|
||||
},
|
||||
27 => Instruction::TypeSampledImage {
|
||||
Op::TypeSampledImage => Instruction::TypeSampledImage {
|
||||
result_id: operands[0],
|
||||
image_type_id: operands[1],
|
||||
},
|
||||
28 => Instruction::TypeArray {
|
||||
Op::TypeArray => Instruction::TypeArray {
|
||||
result_id: operands[0],
|
||||
type_id: operands[1],
|
||||
length_id: operands[2],
|
||||
},
|
||||
29 => Instruction::TypeRuntimeArray {
|
||||
Op::TypeRuntimeArray => Instruction::TypeRuntimeArray {
|
||||
result_id: operands[0],
|
||||
type_id: operands[1],
|
||||
},
|
||||
30 => Instruction::TypeStruct {
|
||||
Op::TypeStruct => Instruction::TypeStruct {
|
||||
result_id: operands[0],
|
||||
member_types: operands[1..].to_owned(),
|
||||
},
|
||||
31 => Instruction::TypeOpaque {
|
||||
Op::TypeOpaque => Instruction::TypeOpaque {
|
||||
result_id: operands[0],
|
||||
name: parse_string(&operands[1..]).0,
|
||||
},
|
||||
32 => Instruction::TypePointer {
|
||||
Op::TypePointer => Instruction::TypePointer {
|
||||
result_id: operands[0],
|
||||
storage_class: StorageClass::from_num(operands[1])?,
|
||||
storage_class: StorageClass::from_u32(operands[1])
|
||||
.ok_or(ParseError::UnknownConstant("StorageClass", operands[1]))?,
|
||||
type_id: operands[2],
|
||||
},
|
||||
43 => Instruction::Constant {
|
||||
Op::Constant => Instruction::Constant {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
data: operands[2..].to_owned(),
|
||||
},
|
||||
48 => Instruction::SpecConstantTrue {
|
||||
Op::SpecConstantTrue => Instruction::SpecConstantTrue {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
},
|
||||
49 => Instruction::SpecConstantFalse {
|
||||
Op::SpecConstantFalse => Instruction::SpecConstantFalse {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
},
|
||||
50 => Instruction::SpecConstant {
|
||||
Op::SpecConstant => Instruction::SpecConstant {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
data: operands[2..].to_owned(),
|
||||
},
|
||||
51 => Instruction::SpecConstantComposite {
|
||||
Op::SpecConstantComposite => Instruction::SpecConstantComposite {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
data: operands[2..].to_owned(),
|
||||
},
|
||||
54 => Instruction::Function {
|
||||
Op::Function => Instruction::Function {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
function_control: operands[2],
|
||||
function_type_id: operands[3],
|
||||
},
|
||||
56 => Instruction::FunctionEnd,
|
||||
57 => Instruction::FunctionCall {
|
||||
Op::FunctionEnd => Instruction::FunctionEnd,
|
||||
Op::FunctionCall => Instruction::FunctionCall {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
function_id: operands[2],
|
||||
args: operands[3..].to_owned(),
|
||||
},
|
||||
59 => Instruction::Variable {
|
||||
Op::Variable => Instruction::Variable {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
storage_class: StorageClass::from_num(operands[2])?,
|
||||
storage_class: StorageClass::from_u32(operands[2])
|
||||
.ok_or(ParseError::UnknownConstant("StorageClass", operands[2]))?,
|
||||
initializer: operands.get(3).map(|&v| v),
|
||||
},
|
||||
60 => Instruction::ImageTexelPointer {
|
||||
Op::ImageTexelPointer => Instruction::ImageTexelPointer {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
image: operands[2],
|
||||
coordinate: operands[3],
|
||||
sample: operands[4],
|
||||
},
|
||||
61 => Instruction::Load {
|
||||
Op::Load => Instruction::Load {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
memory_operands: operands.get(3).map(|&v| v),
|
||||
},
|
||||
62 => Instruction::Store {
|
||||
Op::Store => Instruction::Store {
|
||||
pointer: operands[0],
|
||||
object: operands[1],
|
||||
memory_operands: operands.get(2).map(|&v| v),
|
||||
},
|
||||
63 => Instruction::CopyMemory {
|
||||
Op::CopyMemory => Instruction::CopyMemory {
|
||||
target_id: operands[0],
|
||||
source_id: operands[1],
|
||||
memory_operands: operands.get(2).map(|&v| v),
|
||||
source_memory_operands: operands.get(3).map(|&v| v),
|
||||
},
|
||||
65 => Instruction::AccessChain {
|
||||
Op::AccessChain => Instruction::AccessChain {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
base_id: operands[2],
|
||||
indexes: operands[3..].iter().map(|&v| v as i32).collect(),
|
||||
},
|
||||
66 => Instruction::InBoundsAccessChain {
|
||||
Op::InBoundsAccessChain => Instruction::InBoundsAccessChain {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
base_id: operands[2],
|
||||
indexes: operands[3..].iter().map(|&v| v as i32).collect(),
|
||||
},
|
||||
71 => Instruction::Decorate {
|
||||
Op::Decorate => Instruction::Decorate {
|
||||
target_id: operands[0],
|
||||
decoration: Decoration::from_num(operands[1])?,
|
||||
decoration: Decoration::from_u32(operands[1])
|
||||
.ok_or(ParseError::UnknownConstant("Decoration", operands[1]))?,
|
||||
params: operands[2..].to_owned(),
|
||||
},
|
||||
72 => Instruction::MemberDecorate {
|
||||
Op::MemberDecorate => Instruction::MemberDecorate {
|
||||
target_id: operands[0],
|
||||
member: operands[1],
|
||||
decoration: Decoration::from_num(operands[2])?,
|
||||
decoration: Decoration::from_u32(operands[2])
|
||||
.ok_or(ParseError::UnknownConstant("Decoration", operands[2]))?,
|
||||
params: operands[3..].to_owned(),
|
||||
},
|
||||
73 => Instruction::DecorationGroup {
|
||||
Op::DecorationGroup => Instruction::DecorationGroup {
|
||||
result_id: operands[0],
|
||||
},
|
||||
74 => Instruction::GroupDecorate {
|
||||
Op::GroupDecorate => Instruction::GroupDecorate {
|
||||
decoration_group: operands[0],
|
||||
targets: operands[1..].to_owned(),
|
||||
},
|
||||
75 => Instruction::GroupMemberDecorate {
|
||||
Op::GroupMemberDecorate => Instruction::GroupMemberDecorate {
|
||||
decoration_group: operands[0],
|
||||
targets: operands.chunks(2).map(|x| (x[0], x[1])).collect(),
|
||||
},
|
||||
83 => Instruction::CopyObject {
|
||||
Op::CopyObject => Instruction::CopyObject {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
operand_id: operands[2],
|
||||
},
|
||||
227 => Instruction::AtomicLoad {
|
||||
Op::AtomicLoad => Instruction::AtomicLoad {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
scope_id: operands[3],
|
||||
memory_semantics_id: operands[4],
|
||||
},
|
||||
228 => Instruction::AtomicStore {
|
||||
Op::AtomicStore => Instruction::AtomicStore {
|
||||
pointer: operands[0],
|
||||
scope_id: operands[1],
|
||||
memory_semantics_id: operands[2],
|
||||
value_id: operands[3],
|
||||
},
|
||||
229 => Instruction::AtomicExchange {
|
||||
Op::AtomicExchange => Instruction::AtomicExchange {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -676,7 +701,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
230 => Instruction::AtomicCompareExchange {
|
||||
Op::AtomicCompareExchange => Instruction::AtomicCompareExchange {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -686,7 +711,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
value_id: operands[6],
|
||||
comparator_id: operands[7],
|
||||
},
|
||||
231 => Instruction::AtomicCompareExchangeWeak {
|
||||
Op::AtomicCompareExchangeWeak => Instruction::AtomicCompareExchangeWeak {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -696,21 +721,21 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
value_id: operands[6],
|
||||
comparator_id: operands[7],
|
||||
},
|
||||
232 => Instruction::AtomicIIncrement {
|
||||
Op::AtomicIIncrement => Instruction::AtomicIIncrement {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
scope_id: operands[3],
|
||||
memory_semantics_id: operands[4],
|
||||
},
|
||||
233 => Instruction::AtomicIDecrement {
|
||||
Op::AtomicIDecrement => Instruction::AtomicIDecrement {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
scope_id: operands[3],
|
||||
memory_semantics_id: operands[4],
|
||||
},
|
||||
234 => Instruction::AtomicIAdd {
|
||||
Op::AtomicIAdd => Instruction::AtomicIAdd {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -718,7 +743,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
235 => Instruction::AtomicISub {
|
||||
Op::AtomicISub => Instruction::AtomicISub {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -726,7 +751,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
236 => Instruction::AtomicSMin {
|
||||
Op::AtomicSMin => Instruction::AtomicSMin {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -734,7 +759,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
237 => Instruction::AtomicUMin {
|
||||
Op::AtomicUMin => Instruction::AtomicUMin {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -742,7 +767,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
238 => Instruction::AtomicSMax {
|
||||
Op::AtomicSMax => Instruction::AtomicSMax {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -750,7 +775,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
239 => Instruction::AtomicUMax {
|
||||
Op::AtomicUMax => Instruction::AtomicUMax {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -758,7 +783,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
240 => Instruction::AtomicAnd {
|
||||
Op::AtomicAnd => Instruction::AtomicAnd {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -766,7 +791,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
241 => Instruction::AtomicOr {
|
||||
Op::AtomicOr => Instruction::AtomicOr {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -774,7 +799,7 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
242 => Instruction::AtomicXor {
|
||||
Op::AtomicXor => Instruction::AtomicXor {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
@ -782,22 +807,22 @@ fn decode_instruction(opcode: u16, operands: &[u32]) -> Result<Instruction, Pars
|
||||
memory_semantics_id: operands[4],
|
||||
value_id: operands[5],
|
||||
},
|
||||
248 => Instruction::Label {
|
||||
Op::Label => Instruction::Label {
|
||||
result_id: operands[0],
|
||||
},
|
||||
249 => Instruction::Branch {
|
||||
Op::Branch => Instruction::Branch {
|
||||
result_id: operands[0],
|
||||
},
|
||||
252 => Instruction::Kill,
|
||||
253 => Instruction::Return,
|
||||
318 => Instruction::AtomicFlagTestAndSet {
|
||||
Op::Kill => Instruction::Kill,
|
||||
Op::Return => Instruction::Return,
|
||||
Op::AtomicFlagTestAndSet => Instruction::AtomicFlagTestAndSet {
|
||||
result_type_id: operands[0],
|
||||
result_id: operands[1],
|
||||
pointer: operands[2],
|
||||
scope_id: operands[3],
|
||||
memory_semantics_id: operands[4],
|
||||
},
|
||||
319 => Instruction::AtomicFlagClear {
|
||||
Op::AtomicFlagClear => Instruction::AtomicFlagClear {
|
||||
pointer: operands[0],
|
||||
scope_id: operands[1],
|
||||
memory_semantics_id: operands[2],
|
||||
@ -987,7 +1012,7 @@ impl Spirv {
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns the params held by the Decoration::DecorationBuiltIn for the specified struct id
|
||||
/// Returns the params held by the Decoration::BuiltIn for the specified struct id
|
||||
/// Searches OpMemberDecorate and OpGroupMemberDecorate
|
||||
/// Returns None if such a decoration does not exist
|
||||
///
|
||||
@ -998,7 +1023,7 @@ impl Spirv {
|
||||
match instruction {
|
||||
Instruction::MemberDecorate {
|
||||
target_id,
|
||||
decoration: Decoration::DecorationBuiltIn,
|
||||
decoration: Decoration::BuiltIn,
|
||||
ref params,
|
||||
..
|
||||
} if *target_id == struct_id => {
|
||||
@ -1013,7 +1038,7 @@ impl Spirv {
|
||||
for instruction in &self.instructions {
|
||||
if let Instruction::Decorate {
|
||||
target_id,
|
||||
decoration: Decoration::DecorationBuiltIn,
|
||||
decoration: Decoration::BuiltIn,
|
||||
ref params,
|
||||
} = instruction
|
||||
{
|
||||
|
@ -7,15 +7,13 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use std::mem;
|
||||
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use syn::Ident;
|
||||
|
||||
use crate::enums::Decoration;
|
||||
use crate::parse::{Instruction, Spirv};
|
||||
use crate::structs;
|
||||
use crate::{spirv_search, TypesMeta};
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use spirv_headers::Decoration;
|
||||
use std::mem;
|
||||
use syn::Ident;
|
||||
|
||||
/// Returns true if the document has specialization constants.
|
||||
pub fn has_specialization_constants(doc: &Spirv) -> bool {
|
||||
@ -85,7 +83,7 @@ pub(super) fn write_specialization_constants(doc: &Spirv, types_meta: &TypesMeta
|
||||
spec_const_type_from_id(doc, type_id, types_meta);
|
||||
let rust_size = rust_size.expect("Found runtime-sized specialization constant");
|
||||
|
||||
let constant_id = doc.get_decoration_params(result_id, Decoration::DecorationSpecId);
|
||||
let constant_id = doc.get_decoration_params(result_id, Decoration::SpecId);
|
||||
|
||||
if let Some(constant_id) = constant_id {
|
||||
let constant_id = constant_id[0];
|
||||
|
@ -7,8 +7,8 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::enums::Decoration;
|
||||
use crate::parse::{Instruction, Spirv};
|
||||
use spirv_headers::Decoration;
|
||||
|
||||
/// Returns the vulkano `Format` and number of occupied locations from an id.
|
||||
///
|
||||
@ -146,10 +146,7 @@ pub fn member_name_from_id(doc: &Spirv, searched: u32, searched_member: u32) ->
|
||||
|
||||
/// Returns true if a `BuiltIn` decorator is applied on an id.
|
||||
pub fn is_builtin(doc: &Spirv, id: u32) -> bool {
|
||||
if doc
|
||||
.get_decoration_params(id, Decoration::DecorationBuiltIn)
|
||||
.is_some()
|
||||
{
|
||||
if doc.get_decoration_params(id, Decoration::BuiltIn).is_some() {
|
||||
return true;
|
||||
}
|
||||
if doc.get_member_decoration_builtin_params(id).is_some() {
|
||||
|
@ -7,14 +7,12 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use std::mem;
|
||||
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use syn::Ident;
|
||||
|
||||
use crate::enums::Decoration;
|
||||
use crate::parse::{Instruction, Spirv};
|
||||
use crate::{spirv_search, TypesMeta};
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use spirv_headers::Decoration;
|
||||
use std::mem;
|
||||
use syn::Ident;
|
||||
use syn::LitStr;
|
||||
|
||||
/// Translates all the structs that are contained in the SPIR-V document as Rust structs.
|
||||
@ -70,7 +68,7 @@ fn write_struct(
|
||||
// Ignore the whole struct is a member is built in, which includes
|
||||
// `gl_Position` for example.
|
||||
if doc
|
||||
.get_member_decoration_params(struct_id, num as u32, Decoration::DecorationBuiltIn)
|
||||
.get_member_decoration_params(struct_id, num as u32, Decoration::BuiltIn)
|
||||
.is_some()
|
||||
{
|
||||
return (quote! {}, None); // TODO: is this correct? shouldn't it return a correct struct but with a flag or something?
|
||||
@ -78,7 +76,7 @@ fn write_struct(
|
||||
|
||||
// Finding offset of the current member, as requested by the SPIR-V code.
|
||||
let spirv_offset = doc
|
||||
.get_member_decoration_params(struct_id, num as u32, Decoration::DecorationOffset)
|
||||
.get_member_decoration_params(struct_id, num as u32, Decoration::Offset)
|
||||
.map(|x| x[0]);
|
||||
|
||||
// Some structs don't have `Offset` decorations, in the case they are used as local
|
||||
@ -135,15 +133,13 @@ fn write_struct(
|
||||
Instruction::TypeArray {
|
||||
result_id, type_id, ..
|
||||
} if type_id == struct_id => {
|
||||
if let Some(params) =
|
||||
doc.get_decoration_params(result_id, Decoration::DecorationArrayStride)
|
||||
if let Some(params) = doc.get_decoration_params(result_id, Decoration::ArrayStride)
|
||||
{
|
||||
spirv_req_total_size = Some(params[0]);
|
||||
}
|
||||
}
|
||||
Instruction::TypeRuntimeArray { result_id, type_id } if type_id == struct_id => {
|
||||
if let Some(params) =
|
||||
doc.get_decoration_params(result_id, Decoration::DecorationArrayStride)
|
||||
if let Some(params) = doc.get_decoration_params(result_id, Decoration::ArrayStride)
|
||||
{
|
||||
spirv_req_total_size = Some(params[0]);
|
||||
}
|
||||
@ -526,7 +522,7 @@ pub(super) fn type_from_id(
|
||||
.expect("failed to find array length");
|
||||
let len = len.iter().rev().fold(0u64, |a, &b| (a << 32) | b as u64);
|
||||
let stride = doc
|
||||
.get_decoration_params(searched, Decoration::DecorationArrayStride)
|
||||
.get_decoration_params(searched, Decoration::ArrayStride)
|
||||
.unwrap()[0];
|
||||
if stride as usize > t_size {
|
||||
panic!("Not possible to generate a rust array with the correct alignment since the SPIR-V \
|
||||
|
Loading…
Reference in New Issue
Block a user