Skip to content
Open
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
14 changes: 14 additions & 0 deletions src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,20 @@ impl Allocator {
let mut memory_type_index_opt =
self.find_memorytype_index(&desc.requirements, mem_loc_preferred_bits);

// A GpuToCpu allocation exists to be read by the CPU, so being cached
// matters more than being coherent. Some adapters -- Intel's ANV on
// parts whose GPU does not share the CPU's last level cache -- expose
// cached memory and coherent memory but never both, and reading the
// uncached (write-combined) type is about two orders of magnitude
// slower. Callers must flush and invalidate non-coherent ranges
// regardless, so prefer cached before giving that up.
if memory_type_index_opt.is_none() && desc.location == MemoryLocation::GpuToCpu {
memory_type_index_opt = self.find_memorytype_index(
&desc.requirements,
vk::MemoryPropertyFlags::HOST_VISIBLE | vk::MemoryPropertyFlags::HOST_CACHED,
);
}

if memory_type_index_opt.is_none() {
let mem_loc_required_bits = match desc.location {
MemoryLocation::GpuOnly => vk::MemoryPropertyFlags::DEVICE_LOCAL,
Expand Down
Loading