From 137dbd7cb2bceb730bb8be393057d911edd71b73 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 19 Sep 2017 22:14:54 -0700 Subject: [PATCH] working on implementing device memory --- src/vulkan_icd/vulkan_icd.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/vulkan_icd/vulkan_icd.cpp b/src/vulkan_icd/vulkan_icd.cpp index 430cb52..0a06a19 100644 --- a/src/vulkan_icd/vulkan_icd.cpp +++ b/src/vulkan_icd/vulkan_icd.cpp @@ -385,7 +385,9 @@ extern "C" VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, assert(device); assert(memory); assert(data); - *data = static_cast(vulkan::Vulkan_device_memory::from_handle(memory)->memory.get()) + offset; + *data = static_cast( + vulkan::Vulkan_device_memory::from_handle(memory)->memory.get()) + + offset; return VK_SUCCESS; } @@ -428,10 +430,22 @@ extern "C" VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, extern "C" VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, - VkDeviceSize memoryOffset) + VkDeviceSize memory_offset) { -#warning finish implementing vkBindImageMemory - assert(!"vkBindImageMemory is not implemented"); + assert(device); + assert(image); + assert(memory); + return vulkan_icd::catch_exceptions_and_return_result( + [&]() + { + auto *image_pointer = vulkan::Vulkan_image::from_handle(image); + auto *device_memory = vulkan::Vulkan_device_memory::from_handle(memory); + assert(!image_pointer->memory); + image_pointer->memory = std::shared_ptr( + device_memory->memory, + static_cast(device_memory->memory.get()) + memory_offset); + return VK_SUCCESS; + }); } extern "C" VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements( @@ -447,7 +461,8 @@ extern "C" VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements( assert(device); assert(image); assert(memory_requirements); - *memory_requirements = vulkan::Vulkan_image::from_handle(image)->descriptor.get_memory_requirements(); + *memory_requirements = + vulkan::Vulkan_image::from_handle(image)->descriptor.get_memory_requirements(); } extern "C" VKAPI_ATTR void VKAPI_CALL -- 2.30.2