From 5bb4b0dc13e95726ee2f37eb1e9f19b3ca81d147 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 2 Dec 2015 20:27:03 +0100 Subject: [PATCH] Mapped memory offsets don't have to be aligned at all * The guarantee is that the base pointer (ie. returned pointer minus offset) is aligned to some value. --- .../driver/vulkan/wrappers/vk_resource_funcs.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp index a716badb9..13533595e 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_resource_funcs.cpp @@ -368,11 +368,8 @@ bool WrappedVulkan::Serialise_vkUnmapMemory( device = GetResourceManager()->GetLiveHandle(devId); mem = GetResourceManager()->GetLiveHandle(id); - // VKTODOLOW figure out what alignments there are on mapping, so we only map the region - // we're going to modify. For now, offset/size is handled in the memcpy before and we - // map the whole region void *mapPtr = NULL; - VkResult ret = ObjDisp(device)->MapMemory(Unwrap(device), Unwrap(mem), 0, 0, 0, &mapPtr); + VkResult ret = ObjDisp(device)->MapMemory(Unwrap(device), Unwrap(mem), memOffset, memSize, 0, &mapPtr); if(ret != VK_SUCCESS) { @@ -380,7 +377,7 @@ bool WrappedVulkan::Serialise_vkUnmapMemory( } else { - memcpy((byte *)mapPtr+memOffset, data, (size_t)memSize); + memcpy((byte *)mapPtr, data, (size_t)memSize); ObjDisp(device)->UnmapMemory(Unwrap(device), Unwrap(mem)); } @@ -493,11 +490,8 @@ bool WrappedVulkan::Serialise_vkFlushMappedMemoryRanges( device = GetResourceManager()->GetLiveHandle(devId); VkDeviceMemory mem = GetResourceManager()->GetLiveHandle(id); - // VKTODOLOW figure out what alignments there are on mapping, so we only map the region - // we're going to modify. For no, offset/size is handled in the memcpy before and we - // map the whole region void *mapPtr = NULL; - VkResult ret = ObjDisp(device)->MapMemory(Unwrap(device), Unwrap(mem), 0, 0, 0, &mapPtr); + VkResult ret = ObjDisp(device)->MapMemory(Unwrap(device), Unwrap(mem), memOffset, memSize, 0, &mapPtr); if(ret != VK_SUCCESS) { @@ -505,7 +499,7 @@ bool WrappedVulkan::Serialise_vkFlushMappedMemoryRanges( } else { - memcpy((byte *)mapPtr+memOffset, data, (size_t)memSize); + memcpy((byte *)mapPtr, data, (size_t)memSize); ObjDisp(device)->UnmapMemory(Unwrap(device), Unwrap(mem)); }