From cc049bbb7ccb1f6c4f1e872ce4e299478158c2b7 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Mon, 23 Apr 2018 17:22:54 +0200 Subject: [PATCH] Fix flush and invalidate ranges --- libportability-gfx/src/impls.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 2ba5d82..8f62fcb 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -839,7 +839,15 @@ pub extern "C" fn gfxFlushMappedMemoryRanges( slice::from_raw_parts(pMemoryRanges, memoryRangeCount as _) } .iter() - .map(|r| (&*r.memory, r.offset .. r.offset + r.size)); + .map(|r| { + let range = if r.size == VK_WHOLE_SIZE as VkDeviceSize { + (Some(r.offset), None) + } else { + (Some(r.offset), Some(r.offset + r.size)) + }; + + (&*r.memory, range) + }); gpu.device.flush_mapped_memory_ranges(ranges); VkResult::VK_SUCCESS @@ -854,7 +862,15 @@ pub extern "C" fn gfxInvalidateMappedMemoryRanges( slice::from_raw_parts(pMemoryRanges, memoryRangeCount as _) } .iter() - .map(|r| (&*r.memory, r.offset .. r.offset + r.size)); + .map(|r| { + let range = if r.size == VK_WHOLE_SIZE as VkDeviceSize { + (Some(r.offset), None) + } else { + (Some(r.offset), Some(r.offset + r.size)) + }; + + (&*r.memory, range) + }); gpu.device.invalidate_mapped_memory_ranges(ranges); VkResult::VK_SUCCESS