MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator / Map

Method Map

include/vk_mem_alloc.h:11090–11130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11088}
11089
11090VkResult VmaDeviceMemoryBlock::Map(VmaAllocator hAllocator, uint32_t count, void** ppData)
11091{
11092 if (count == 0)
11093 {
11094 return VK_SUCCESS;
11095 }
11096
11097 VmaMutexLock lock(m_MapAndBindMutex, hAllocator->m_UseMutex);
11098 const uint32_t oldTotalMapCount = m_MapCount + m_MappingHysteresis.GetExtraMapping();
11099 if (oldTotalMapCount != 0)
11100 {
11101 VMA_ASSERT(m_pMappedData != VMA_NULL);
11102 m_MappingHysteresis.PostMap();
11103 m_MapCount += count;
11104 if (ppData != VMA_NULL)
11105 {
11106 *ppData = m_pMappedData;
11107 }
11108 return VK_SUCCESS;
11109 }
11110
11111 VkResult result = (*hAllocator->GetVulkanFunctions().vkMapMemory)(
11112 hAllocator->m_hDevice,
11113 m_hMemory,
11114 0, // offset
11115 VK_WHOLE_SIZE,
11116 0, // flags
11117 &m_pMappedData);
11118 if (result == VK_SUCCESS)
11119 {
11120 VMA_ASSERT(m_pMappedData != VMA_NULL);
11121 m_IsMapped.store(true);
11122 m_MappingHysteresis.PostMap();
11123 m_MapCount = count;
11124 if (ppData != VMA_NULL)
11125 {
11126 *ppData = m_pMappedData;
11127 }
11128 }
11129 return result;
11130}
11131
11132void VmaDeviceMemoryBlock::Unmap(VmaAllocator hAllocator, uint32_t count)
11133{

Callers 2

DefragmentPassEndMethod · 0.80

Calls 7

GetExtraMappingMethod · 0.80
PostMapMethod · 0.80
GetTypeMethod · 0.80
GetOffsetMethod · 0.80
BlockAllocMapMethod · 0.80
DedicatedAllocMapMethod · 0.80
GetBlockMethod · 0.45

Tested by

no test coverage detected