File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ namespace Anvil
6464 bool bake (Anvil::MemoryAllocator::Items& in_items) final ;
6565 VkResult map (void * in_memory_object,
6666 VkDeviceSize in_start_offset,
67+ VkDeviceSize in_memory_block_start_offset,
6768 VkDeviceSize in_size,
6869 void ** out_result_ptr) final ;
6970 bool supports_baking () const final ;
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ namespace Anvil
127127 bool bake (Anvil::MemoryAllocator::Items& in_items) final ;
128128 VkResult map (void * in_memory_object,
129129 VkDeviceSize in_start_offset,
130+ VkDeviceSize in_memory_block_start_offset,
130131 VkDeviceSize in_size,
131132 void ** out_result_ptr);
132133 bool supports_baking () const final ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ namespace Anvil
3636
3737 virtual VkResult map (void * in_memory_object,
3838 VkDeviceSize in_start_offset,
39+ VkDeviceSize in_memory_block_start_offset,
3940 VkDeviceSize in_size,
4041 void ** out_result_ptr) = 0;
4142 virtual bool supports_baking () const = 0;
Original file line number Diff line number Diff line change @@ -418,9 +418,12 @@ bool Anvil::MemoryAllocatorBackends::OneShot::bake(Anvil::MemoryAllocator::Items
418418
419419VkResult Anvil::MemoryAllocatorBackends::OneShot::map (void * in_memory_object,
420420 VkDeviceSize in_start_offset,
421+ VkDeviceSize in_memory_block_start_offset,
421422 VkDeviceSize in_size,
422423 void ** out_result_ptr)
423424{
425+ ANVIL_REDUNDANT_VARIABLE (in_memory_block_start_offset);
426+
424427 return Anvil::Vulkan::vkMapMemory (m_device_ptr->get_device_vk (),
425428 reinterpret_cast <VkDeviceMemory>(in_memory_object),
426429 in_start_offset,
Original file line number Diff line number Diff line change @@ -361,17 +361,26 @@ bool Anvil::MemoryAllocatorBackends::VMA::init()
361361
362362VkResult Anvil::MemoryAllocatorBackends::VMA::map (void * in_memory_object,
363363 VkDeviceSize in_start_offset,
364+ VkDeviceSize in_memory_block_start_offset,
364365 VkDeviceSize in_size,
365366 void ** out_result_ptr)
366367{
368+ VkResult result;
369+ void * result_ptr = nullptr ;
370+
367371 ANVIL_REDUNDANT_ARGUMENT (in_size);
368372 ANVIL_REDUNDANT_ARGUMENT (in_start_offset);
369373
370374 anvil_assert (in_start_offset == 0 );
371375
372- return vmaMapMemory (m_vma_allocator_ptr->get_handle (),
373- static_cast <VmaAllocation>(in_memory_object),
374- out_result_ptr);
376+ result = vmaMapMemory (m_vma_allocator_ptr->get_handle (),
377+ static_cast <VmaAllocation>(in_memory_object),
378+ &result_ptr);
379+
380+ result_ptr = reinterpret_cast <uint8_t *>(result_ptr) - in_memory_block_start_offset;
381+
382+ *out_result_ptr = result_ptr;
383+ return result;
375384}
376385
377386/* * Please see header for specification */
Original file line number Diff line number Diff line change @@ -682,8 +682,11 @@ bool Anvil::MemoryBlock::open_gpu_memory_access()
682682 {
683683 result_vk = m_parent_memory_allocator_backend_ptr->map (m_backend_object,
684684 0 , /* in_start_offset */
685- m_create_info_ptr->get_size (),
685+ m_create_info_ptr->get_start_offset (),
686+ m_create_info_ptr->get_size (),
686687 static_cast <void **>(&m_gpu_data_ptr) );
688+
689+ m_gpu_data_ptr = reinterpret_cast <uint8_t *>(m_gpu_data_ptr);
687690 }
688691 else
689692 {
You can’t perform that action at this time.
0 commit comments