Skip to content

Commit

Permalink
separate is_required_memory_type and has_required_properties
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 committed Sep 4, 2024
1 parent a61e843 commit d221534
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ impl super::Device {
#[cfg(windows)]
fn find_memory_type_index(
&self,
type_bits: u32,
flags: vk::MemoryPropertyFlags,
type_bits_req: u32,
flags_req: vk::MemoryPropertyFlags,
) -> Option<usize> {
let mem_properties = unsafe {
self.shared
Expand All @@ -704,7 +704,10 @@ impl super::Device {

// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceMemoryProperties.html
for (i, mem_ty) in mem_properties.memory_types_as_slice().iter().enumerate() {
if type_bits & (1 << i) != 0 && mem_ty.property_flags & flags == flags {
let types_bits = 1 << i;
let is_required_memory_type = type_bits_req & types_bits != 0;
let has_required_properties = mem_ty.property_flags & flags_req == flags_req;
if is_required_memory_type && has_required_properties {
return Some(i);
}
}
Expand Down

0 comments on commit d221534

Please sign in to comment.