Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support combined sampler and image for GLSL #27

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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,
Expand Down Expand Up @@ -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
}
});
}
_ => {}
}

Expand Down Expand Up @@ -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;
Expand Down