Skip to content

Commit

Permalink
added ShaderModule::single_entry_point() functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Firestar99 committed Aug 23, 2023
1 parent 7699bca commit 2e6719d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions vulkano/src/shader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,39 @@ impl ShaderModule {
})
})
}

/// Returns information about the entry point if self only contains a single entry point,
/// `None` otherwise.
#[inline]
pub fn single_entry_point(self: &Arc<Self>) -> Option<EntryPoint> {
self.entry_point_map.iter().next().and_then(|(_, infos)| {
infos.iter().next().map(|(_, &info_index)| EntryPoint {
module: self.clone(),
info_index,
})
})
}

/// Returns information about the entry point if self only contains a single entry point
/// with the provided ExecutionModel. Returns `None` if no entry point was found or multiple
/// entry points have been found matching the provided ExecutionModel.
#[inline]
pub fn single_entry_point_of_execution(
self: &Arc<Self>,
execution: ExecutionModel,
) -> Option<EntryPoint> {
let mut iter = self
.entry_point_map
.iter()
.filter_map(|(_, infos)| infos.get(&execution));

// check for *exactly* one entry point being present
let info_index = *iter.next()?;
iter.next().is_none().then(|| EntryPoint {
module: self.clone(),
info_index,
})
}
}

impl Drop for ShaderModule {
Expand Down

0 comments on commit 2e6719d

Please sign in to comment.