Files
metal2vulkan/crates/metal2vulkan-runtime/src/tests/managed.rs
T
Anees Iqbal 13b279df1b Squash 11203 commits of translator, runtime, and validation work
Rolls up everything since 43c46ac8 into a single commit. Its tree is
identical to the tree of private master at
b3c77f2d2b20a432be10591a2129547c10b1c24b.

- A Cargo workspace of five crates under crates/: metal2vulkan (the
  translator and the metal2vulkan command), metal2vulkan-runtime (the
  Metal API on Vulkan), metal2vulkan-air (the AIR front end),
  metal2vulkan-validation and metal2vulkan-devtools.
- Dual license: GPL-2.0-or-later OR LGPL-3.0-or-later.
- docs/: API, architecture, fast paths, how-to, Metal coverage,
  refusals, runtime porting and validation guides.

Private-Commit: b3c77f2d2b20a432be10591a2129547c10b1c24b
2026-10-11 20:09:13 +03:00

35 lines
1.0 KiB
Rust

//! Managed storage (`managed.rs`): its memory class.
use crate::memory::{candidates, MemoryClass};
use ash::vk;
fn ty(flags: vk::MemoryPropertyFlags) -> vk::MemoryType {
vk::MemoryType {
property_flags: flags,
heap_index: 0,
}
}
#[test]
fn managed_memory_is_host_coherent_and_cached_first() {
use vk::MemoryPropertyFlags as P;
let types = [
ty(P::DEVICE_LOCAL),
ty(P::DEVICE_LOCAL | P::HOST_VISIBLE | P::HOST_COHERENT),
ty(P::HOST_VISIBLE | P::HOST_CACHED),
ty(P::HOST_VISIBLE | P::HOST_COHERENT),
ty(P::HOST_VISIBLE | P::HOST_COHERENT | P::HOST_CACHED),
];
// Cached coherent first; never non-coherent memory, which would need flushes; never
// host-invisible memory.
assert_eq!(
candidates(&types, 0b11111, MemoryClass::Managed, false),
[4, 1, 3]
);
// Without cached coherent memory, any host-visible coherent type.
assert_eq!(
candidates(&types, 0b01111, MemoryClass::Managed, false),
[1, 3]
);
}