| 11088 | } |
| 11089 | |
| 11090 | VkResult 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 | |
| 11132 | void VmaDeviceMemoryBlock::Unmap(VmaAllocator hAllocator, uint32_t count) |
| 11133 | { |
no test coverage detected