diff --git a/src/lib.rs b/src/lib.rs index 16de548..a1c42db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,7 @@ impl std::fmt::Debug for DescriptorType { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum BindingCount { /// A single resource binding. /// @@ -133,7 +133,7 @@ pub enum BindingCount { Unbounded, } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DescriptorInfo { pub ty: DescriptorType, pub binding_count: BindingCount, @@ -291,6 +291,31 @@ impl Reflection { assert_eq!(storage_class, ptr_storage_class); return self.get_descriptor_type_for_var(element_type_id, storage_class); } + spirv::Op::TypeSampledImage => { + let element_type_id = get_operand_at!(type_instruction, Operand::IdRef, 0)?; + + let image_instruction = + Self::find_assignment_for(&self.0.types_global_values, element_type_id)?; + + let descriptor = self.get_descriptor_type(image_instruction, storage_class)?; + + let dim = get_operand_at!(image_instruction, Operand::Dim, 1)?; + assert_ne!(dim, spirv::Dim::DimSubpassData); + + return Ok(if dim == spirv::Dim::DimBuffer { + if descriptor.ty != DescriptorType::UNIFORM_TEXEL_BUFFER + && descriptor.ty != DescriptorType::STORAGE_TEXEL_BUFFER + { + todo!("Unexpected sampled image type {:?}", descriptor.ty) + } + descriptor + } else { + DescriptorInfo { + ty: DescriptorType::COMBINED_IMAGE_SAMPLER, + ..descriptor + } + }); + } _ => {} } @@ -329,19 +354,6 @@ impl Reflection { )); } } - spirv::Op::TypeSampledImage => { - todo!("{:?} Not implemented; untested", type_instruction.class); - // Note that `dim`, `sampled` and `storage` are parsed from TypeImage - // if dim == SpvDimBuffer { - // if sampled { - // DescriptorType::UNIFORM_TEXEL_BUFFER - // } else if storage { - // DescriptorType::STORAGE_TEXEL_BUFFER - // } - // } else { - // DescriptorType::COMBINED_IMAGE_SAMPLER - // } - } spirv::Op::TypeStruct => { let mut is_uniform_buffer = false; let mut is_storage_buffer = false;