aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'stockton-render/src/utils.rs')
-rw-r--r--stockton-render/src/utils.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/stockton-render/src/utils.rs b/stockton-render/src/utils.rs
new file mode 100644
index 0000000..152ba10
--- /dev/null
+++ b/stockton-render/src/utils.rs
@@ -0,0 +1,19 @@
+use crate::types::*;
+use hal::{memory::Properties as MemProperties, MemoryTypeId};
+
+pub fn find_memory_type_id(
+ adapter: &Adapter,
+ type_mask: u32,
+ props: MemProperties,
+) -> Option<MemoryTypeId> {
+ adapter
+ .physical_device
+ .memory_properties()
+ .memory_types
+ .iter()
+ .enumerate()
+ .find(|&(id, memory_type)| {
+ type_mask & (1 << id) != 0 && memory_type.properties.contains(props)
+ })
+ .map(|(id, _)| MemoryTypeId(id))
+}