1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci* Copyright 2015 Google Inc. 3cb93a386Sopenharmony_ci* 4cb93a386Sopenharmony_ci* Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci* found in the LICENSE file. 6cb93a386Sopenharmony_ci*/ 7cb93a386Sopenharmony_ci#include "src/gpu/vk/GrVkMemory.h" 8cb93a386Sopenharmony_ci 9cb93a386Sopenharmony_ci#ifdef NOT_BUILD_FOR_OHOS_SDK 10cb93a386Sopenharmony_ci#include <parameters.h> 11cb93a386Sopenharmony_ci#endif 12cb93a386Sopenharmony_ci 13cb93a386Sopenharmony_ci#include "include/core/SkExecutor.h" 14cb93a386Sopenharmony_ci#include "src/core/SkTraceEvent.h" 15cb93a386Sopenharmony_ci#include "src/core/SkUtils.h" 16cb93a386Sopenharmony_ci#include "src/gpu/vk/GrVkGpu.h" 17cb93a386Sopenharmony_ci#include "src/gpu/vk/GrVkUtil.h" 18cb93a386Sopenharmony_ci 19cb93a386Sopenharmony_ci#define VK_CALL(GPU, X) GR_VK_CALL((GPU)->vkInterface(), X) 20cb93a386Sopenharmony_ci 21cb93a386Sopenharmony_ciusing AllocationPropertyFlags = GrVkMemoryAllocator::AllocationPropertyFlags; 22cb93a386Sopenharmony_ciusing BufferUsage = GrVkMemoryAllocator::BufferUsage; 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_cistatic bool FindMemoryType(GrVkGpu *gpu, uint32_t typeFilter, VkMemoryPropertyFlags properties, uint32_t &typeIndex) 25cb93a386Sopenharmony_ci{ 26cb93a386Sopenharmony_ci VkPhysicalDevice physicalDevice = gpu->physicalDevice(); 27cb93a386Sopenharmony_ci VkPhysicalDeviceMemoryProperties memProperties{}; 28cb93a386Sopenharmony_ci VK_CALL(gpu, GetPhysicalDeviceMemoryProperties(physicalDevice, &memProperties)); 29cb93a386Sopenharmony_ci 30cb93a386Sopenharmony_ci bool hasFound = false; 31cb93a386Sopenharmony_ci for (uint32_t i = 0; i < memProperties.memoryTypeCount && !hasFound; ++i) { 32cb93a386Sopenharmony_ci if (typeFilter & (1 << i)) { 33cb93a386Sopenharmony_ci uint32_t supportedFlags = memProperties.memoryTypes[i].propertyFlags & properties; 34cb93a386Sopenharmony_ci if (supportedFlags == properties) { 35cb93a386Sopenharmony_ci typeIndex = i; 36cb93a386Sopenharmony_ci hasFound = true; 37cb93a386Sopenharmony_ci } 38cb93a386Sopenharmony_ci } 39cb93a386Sopenharmony_ci } 40cb93a386Sopenharmony_ci 41cb93a386Sopenharmony_ci return hasFound; 42cb93a386Sopenharmony_ci} 43cb93a386Sopenharmony_ci 44cb93a386Sopenharmony_cibool GrVkMemory::AllocAndBindBufferMemory(GrVkGpu* gpu, 45cb93a386Sopenharmony_ci VkBuffer buffer, 46cb93a386Sopenharmony_ci BufferUsage usage, 47cb93a386Sopenharmony_ci#ifdef SKIA_DFX_FOR_OHOS 48cb93a386Sopenharmony_ci GrVkAlloc* alloc, 49cb93a386Sopenharmony_ci size_t size) { 50cb93a386Sopenharmony_ci#else 51cb93a386Sopenharmony_ci GrVkAlloc* alloc) { 52cb93a386Sopenharmony_ci#endif 53cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 54cb93a386Sopenharmony_ci GrVkBackendMemory memory = 0; 55cb93a386Sopenharmony_ci 56cb93a386Sopenharmony_ci AllocationPropertyFlags propFlags; 57cb93a386Sopenharmony_ci bool shouldPersistentlyMapCpuToGpu = gpu->vkCaps().shouldPersistentlyMapCpuToGpuBuffers(); 58cb93a386Sopenharmony_ci if (usage == BufferUsage::kTransfersFromCpuToGpu || 59cb93a386Sopenharmony_ci (usage == BufferUsage::kCpuWritesGpuReads && shouldPersistentlyMapCpuToGpu)) { 60cb93a386Sopenharmony_ci // In general it is always fine (and often better) to keep buffers always mapped that we are 61cb93a386Sopenharmony_ci // writing to on the cpu. 62cb93a386Sopenharmony_ci propFlags = AllocationPropertyFlags::kPersistentlyMapped; 63cb93a386Sopenharmony_ci } else { 64cb93a386Sopenharmony_ci propFlags = AllocationPropertyFlags::kNone; 65cb93a386Sopenharmony_ci } 66cb93a386Sopenharmony_ci 67cb93a386Sopenharmony_ci VkResult result = allocator->allocateBufferMemory(buffer, usage, propFlags, &memory); 68cb93a386Sopenharmony_ci if (!gpu->checkVkResult(result)) { 69cb93a386Sopenharmony_ci return false; 70cb93a386Sopenharmony_ci } 71cb93a386Sopenharmony_ci allocator->getAllocInfo(memory, alloc); 72cb93a386Sopenharmony_ci 73cb93a386Sopenharmony_ci#ifdef SKIA_DFX_FOR_OHOS 74cb93a386Sopenharmony_ci alloc->fBytes = size; 75cb93a386Sopenharmony_ci gpu->addAllocBufferBytes(size); 76cb93a386Sopenharmony_ci#endif 77cb93a386Sopenharmony_ci 78cb93a386Sopenharmony_ci // Bind buffer 79cb93a386Sopenharmony_ci VkResult err; 80cb93a386Sopenharmony_ci GR_VK_CALL_RESULT(gpu, err, BindBufferMemory(gpu->device(), buffer, alloc->fMemory, 81cb93a386Sopenharmony_ci alloc->fOffset)); 82cb93a386Sopenharmony_ci if (err) { 83cb93a386Sopenharmony_ci FreeBufferMemory(gpu, *alloc); 84cb93a386Sopenharmony_ci return false; 85cb93a386Sopenharmony_ci } 86cb93a386Sopenharmony_ci 87cb93a386Sopenharmony_ci return true; 88cb93a386Sopenharmony_ci} 89cb93a386Sopenharmony_ci 90cb93a386Sopenharmony_cibool GrVkMemory::ImportAndBindBufferMemory(GrVkGpu* gpu, 91cb93a386Sopenharmony_ci OH_NativeBuffer *nativeBuffer, 92cb93a386Sopenharmony_ci VkBuffer buffer, 93cb93a386Sopenharmony_ci GrVkAlloc* alloc) { 94cb93a386Sopenharmony_ci HITRACE_OHOS_NAME_ALWAYS("ImportAndBindBufferMemory"); 95cb93a386Sopenharmony_ci VkDevice device = gpu->device(); 96cb93a386Sopenharmony_ci VkMemoryRequirements memReqs{}; 97cb93a386Sopenharmony_ci VK_CALL(gpu, GetBufferMemoryRequirements(device, buffer, &memReqs)); 98cb93a386Sopenharmony_ci 99cb93a386Sopenharmony_ci uint32_t typeIndex = 0; 100cb93a386Sopenharmony_ci bool hasFound = FindMemoryType(gpu, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, typeIndex); 101cb93a386Sopenharmony_ci if (!hasFound) { 102cb93a386Sopenharmony_ci return false; 103cb93a386Sopenharmony_ci } 104cb93a386Sopenharmony_ci 105cb93a386Sopenharmony_ci // Import external memory 106cb93a386Sopenharmony_ci VkImportNativeBufferInfoOHOS importInfo{}; 107cb93a386Sopenharmony_ci importInfo.sType = VK_STRUCTURE_TYPE_IMPORT_NATIVE_BUFFER_INFO_OHOS; 108cb93a386Sopenharmony_ci importInfo.pNext = nullptr; 109cb93a386Sopenharmony_ci importInfo.buffer = nativeBuffer; 110cb93a386Sopenharmony_ci 111cb93a386Sopenharmony_ci VkMemoryDedicatedAllocateInfo dedicatedAllocInfo{}; 112cb93a386Sopenharmony_ci dedicatedAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO; 113cb93a386Sopenharmony_ci dedicatedAllocInfo.pNext = &importInfo; 114cb93a386Sopenharmony_ci dedicatedAllocInfo.image = VK_NULL_HANDLE; 115cb93a386Sopenharmony_ci dedicatedAllocInfo.buffer = buffer; 116cb93a386Sopenharmony_ci 117cb93a386Sopenharmony_ci VkMemoryAllocateInfo allocateInfo{}; 118cb93a386Sopenharmony_ci allocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; 119cb93a386Sopenharmony_ci allocateInfo.pNext = &dedicatedAllocInfo; 120cb93a386Sopenharmony_ci allocateInfo.allocationSize = memReqs.size; 121cb93a386Sopenharmony_ci allocateInfo.memoryTypeIndex = typeIndex; 122cb93a386Sopenharmony_ci 123cb93a386Sopenharmony_ci VkResult err; 124cb93a386Sopenharmony_ci VkDeviceMemory memory; 125cb93a386Sopenharmony_ci GR_VK_CALL_RESULT(gpu, err, AllocateMemory(device, &allocateInfo, nullptr, &memory)); 126cb93a386Sopenharmony_ci if (err) { 127cb93a386Sopenharmony_ci return false; 128cb93a386Sopenharmony_ci } 129cb93a386Sopenharmony_ci 130cb93a386Sopenharmony_ci // Bind buffer 131cb93a386Sopenharmony_ci GR_VK_CALL_RESULT(gpu, err, BindBufferMemory(device, buffer, memory, 0)); 132cb93a386Sopenharmony_ci if (err) { 133cb93a386Sopenharmony_ci VK_CALL(gpu, FreeMemory(device, memory, nullptr)); 134cb93a386Sopenharmony_ci return false; 135cb93a386Sopenharmony_ci } 136cb93a386Sopenharmony_ci 137cb93a386Sopenharmony_ci alloc->fMemory = memory; 138cb93a386Sopenharmony_ci alloc->fOffset = 0; 139cb93a386Sopenharmony_ci alloc->fSize = memReqs.size; 140cb93a386Sopenharmony_ci alloc->fFlags = 0; 141cb93a386Sopenharmony_ci alloc->fIsExternalMemory = true; 142cb93a386Sopenharmony_ci 143cb93a386Sopenharmony_ci return true; 144cb93a386Sopenharmony_ci} 145cb93a386Sopenharmony_ci 146cb93a386Sopenharmony_civoid GrVkMemory::FreeBufferMemory(const GrVkGpu* gpu, const GrVkAlloc& alloc) { 147cb93a386Sopenharmony_ci#ifdef SKIA_DFX_FOR_OHOS 148cb93a386Sopenharmony_ci ((GrVkGpu*)gpu)->removeAllocBufferBytes(alloc.fBytes); 149cb93a386Sopenharmony_ci#endif 150cb93a386Sopenharmony_ci if (alloc.fIsExternalMemory) { 151cb93a386Sopenharmony_ci VK_CALL(gpu, FreeMemory(gpu->device(), alloc.fMemory, nullptr)); 152cb93a386Sopenharmony_ci } else { 153cb93a386Sopenharmony_ci SkASSERT(alloc.fBackendMemory); 154cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 155cb93a386Sopenharmony_ci if (alloc.fAllocator != nullptr) { 156cb93a386Sopenharmony_ci allocator = alloc.fAllocator; 157cb93a386Sopenharmony_ci } 158cb93a386Sopenharmony_ci allocator->freeMemory(alloc.fBackendMemory); 159cb93a386Sopenharmony_ci } 160cb93a386Sopenharmony_ci} 161cb93a386Sopenharmony_ci 162cb93a386Sopenharmony_cibool GrVkMemory::AllocAndBindImageMemory(GrVkGpu* gpu, 163cb93a386Sopenharmony_ci VkImage image, 164cb93a386Sopenharmony_ci GrMemoryless memoryless, 165cb93a386Sopenharmony_ci GrVkAlloc* alloc, 166cb93a386Sopenharmony_ci int memorySize) { 167cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 168cb93a386Sopenharmony_ci GrVkBackendMemory memory = 0; 169cb93a386Sopenharmony_ci 170cb93a386Sopenharmony_ci bool vmaFlag = SkGetVmaCacheFlag(); 171cb93a386Sopenharmony_ci bool vmaCacheFlag = vmaFlag && memorySize > SkGetNeedCachedMemroySize(); 172cb93a386Sopenharmony_ci if (vmaCacheFlag) { 173cb93a386Sopenharmony_ci allocator = gpu->memoryAllocatorCacheImage(); 174cb93a386Sopenharmony_ci } 175cb93a386Sopenharmony_ci 176cb93a386Sopenharmony_ci VkMemoryRequirements memReqs; 177cb93a386Sopenharmony_ci HITRACE_OHOS_NAME_FMT_ALWAYS("AllocAndBindImageMemory vmaCacheFlag %d memSizeOver %d", 178cb93a386Sopenharmony_ci vmaCacheFlag, memorySize > SkGetNeedCachedMemroySize()); 179cb93a386Sopenharmony_ci GR_VK_CALL(gpu->vkInterface(), GetImageMemoryRequirements(gpu->device(), image, &memReqs)); 180cb93a386Sopenharmony_ci 181cb93a386Sopenharmony_ci AllocationPropertyFlags propFlags; 182cb93a386Sopenharmony_ci // If we ever find that our allocator is not aggressive enough in using dedicated image 183cb93a386Sopenharmony_ci // memory we can add a size check here to force the use of dedicate memory. However for now, 184cb93a386Sopenharmony_ci // we let the allocators decide. The allocator can query the GPU for each image to see if the 185cb93a386Sopenharmony_ci // GPU recommends or requires the use of dedicated memory. 186cb93a386Sopenharmony_ci if (vmaCacheFlag) { 187cb93a386Sopenharmony_ci propFlags = AllocationPropertyFlags::kNone; 188cb93a386Sopenharmony_ci } else if (gpu->vkCaps().shouldAlwaysUseDedicatedImageMemory()) { 189cb93a386Sopenharmony_ci propFlags = AllocationPropertyFlags::kDedicatedAllocation; 190cb93a386Sopenharmony_ci } else { 191cb93a386Sopenharmony_ci propFlags = AllocationPropertyFlags::kNone; 192cb93a386Sopenharmony_ci } 193cb93a386Sopenharmony_ci 194cb93a386Sopenharmony_ci if (gpu->protectedContext()) { 195cb93a386Sopenharmony_ci propFlags |= AllocationPropertyFlags::kProtected; 196cb93a386Sopenharmony_ci } 197cb93a386Sopenharmony_ci 198cb93a386Sopenharmony_ci if (memoryless == GrMemoryless::kYes) { 199cb93a386Sopenharmony_ci propFlags |= AllocationPropertyFlags::kLazyAllocation; 200cb93a386Sopenharmony_ci } 201cb93a386Sopenharmony_ci 202cb93a386Sopenharmony_ci { // OH ISSUE: add trace for vulkan interface 203cb93a386Sopenharmony_ci HITRACE_OHOS_NAME_ALWAYS("allocateImageMemory"); 204cb93a386Sopenharmony_ci VkResult result = allocator->allocateImageMemory(image, propFlags, &memory); 205cb93a386Sopenharmony_ci if (!gpu->checkVkResult(result)) { 206cb93a386Sopenharmony_ci return false; 207cb93a386Sopenharmony_ci } 208cb93a386Sopenharmony_ci } 209cb93a386Sopenharmony_ci 210cb93a386Sopenharmony_ci allocator->getAllocInfo(memory, alloc); 211cb93a386Sopenharmony_ci#ifdef SKIA_DFX_FOR_OHOS 212cb93a386Sopenharmony_ci alloc->fBytes = memorySize; 213cb93a386Sopenharmony_ci gpu->addAllocImageBytes(memorySize); 214cb93a386Sopenharmony_ci#endif 215cb93a386Sopenharmony_ci 216cb93a386Sopenharmony_ci { // OH ISSUE: add trace for vulkan interface 217cb93a386Sopenharmony_ci HITRACE_OHOS_NAME_ALWAYS("BindImageMemory"); 218cb93a386Sopenharmony_ci // Bind buffer 219cb93a386Sopenharmony_ci VkResult err; 220cb93a386Sopenharmony_ci GR_VK_CALL_RESULT(gpu, err, BindImageMemory(gpu->device(), image, alloc->fMemory, 221cb93a386Sopenharmony_ci alloc->fOffset)); 222cb93a386Sopenharmony_ci if (err) { 223cb93a386Sopenharmony_ci FreeImageMemory(gpu, *alloc); 224cb93a386Sopenharmony_ci return false; 225cb93a386Sopenharmony_ci } 226cb93a386Sopenharmony_ci } 227cb93a386Sopenharmony_ci 228cb93a386Sopenharmony_ci return true; 229cb93a386Sopenharmony_ci} 230cb93a386Sopenharmony_ci 231cb93a386Sopenharmony_civoid GrVkMemory::FreeImageMemory(const GrVkGpu* gpu, const GrVkAlloc& alloc) { 232cb93a386Sopenharmony_ci#ifdef SKIA_DFX_FOR_OHOS 233cb93a386Sopenharmony_ci ((GrVkGpu*)gpu)->removeAllocImageBytes(alloc.fBytes); 234cb93a386Sopenharmony_ci#endif 235cb93a386Sopenharmony_ci SkASSERT(alloc.fBackendMemory); 236cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 237cb93a386Sopenharmony_ci if (alloc.fAllocator != nullptr) { 238cb93a386Sopenharmony_ci allocator = alloc.fAllocator; 239cb93a386Sopenharmony_ci } 240cb93a386Sopenharmony_ci allocator->freeMemory(alloc.fBackendMemory); 241cb93a386Sopenharmony_ci} 242cb93a386Sopenharmony_ci 243cb93a386Sopenharmony_civoid* GrVkMemory::MapAlloc(GrVkGpu* gpu, const GrVkAlloc& alloc) { 244cb93a386Sopenharmony_ci SkASSERT(GrVkAlloc::kMappable_Flag & alloc.fFlags); 245cb93a386Sopenharmony_ci SkASSERT(alloc.fBackendMemory); 246cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 247cb93a386Sopenharmony_ci if (alloc.fAllocator != nullptr) { 248cb93a386Sopenharmony_ci allocator = alloc.fAllocator; 249cb93a386Sopenharmony_ci } 250cb93a386Sopenharmony_ci void* mapPtr; 251cb93a386Sopenharmony_ci VkResult result = allocator->mapMemory(alloc.fBackendMemory, &mapPtr); 252cb93a386Sopenharmony_ci if (!gpu->checkVkResult(result)) { 253cb93a386Sopenharmony_ci return nullptr; 254cb93a386Sopenharmony_ci } 255cb93a386Sopenharmony_ci return mapPtr; 256cb93a386Sopenharmony_ci} 257cb93a386Sopenharmony_ci 258cb93a386Sopenharmony_civoid GrVkMemory::UnmapAlloc(const GrVkGpu* gpu, const GrVkAlloc& alloc) { 259cb93a386Sopenharmony_ci SkASSERT(alloc.fBackendMemory); 260cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 261cb93a386Sopenharmony_ci if (alloc.fAllocator != nullptr) { 262cb93a386Sopenharmony_ci allocator = alloc.fAllocator; 263cb93a386Sopenharmony_ci } 264cb93a386Sopenharmony_ci allocator->unmapMemory(alloc.fBackendMemory); 265cb93a386Sopenharmony_ci} 266cb93a386Sopenharmony_ci 267cb93a386Sopenharmony_civoid GrVkMemory::GetNonCoherentMappedMemoryRange(const GrVkAlloc& alloc, VkDeviceSize offset, 268cb93a386Sopenharmony_ci VkDeviceSize size, VkDeviceSize alignment, 269cb93a386Sopenharmony_ci VkMappedMemoryRange* range) { 270cb93a386Sopenharmony_ci SkASSERT(alloc.fFlags & GrVkAlloc::kNoncoherent_Flag); 271cb93a386Sopenharmony_ci offset = offset + alloc.fOffset; 272cb93a386Sopenharmony_ci VkDeviceSize offsetDiff = offset & (alignment -1); 273cb93a386Sopenharmony_ci offset = offset - offsetDiff; 274cb93a386Sopenharmony_ci size = (size + alignment - 1) & ~(alignment - 1); 275cb93a386Sopenharmony_ci#ifdef SK_DEBUG 276cb93a386Sopenharmony_ci SkASSERT(offset >= alloc.fOffset); 277cb93a386Sopenharmony_ci SkASSERT(offset + size <= alloc.fOffset + alloc.fSize); 278cb93a386Sopenharmony_ci SkASSERT(0 == (offset & (alignment-1))); 279cb93a386Sopenharmony_ci SkASSERT(size > 0); 280cb93a386Sopenharmony_ci SkASSERT(0 == (size & (alignment-1))); 281cb93a386Sopenharmony_ci#endif 282cb93a386Sopenharmony_ci 283cb93a386Sopenharmony_ci memset(range, 0, sizeof(VkMappedMemoryRange)); 284cb93a386Sopenharmony_ci range->sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; 285cb93a386Sopenharmony_ci range->memory = alloc.fMemory; 286cb93a386Sopenharmony_ci range->offset = offset; 287cb93a386Sopenharmony_ci range->size = size; 288cb93a386Sopenharmony_ci} 289cb93a386Sopenharmony_ci 290cb93a386Sopenharmony_civoid GrVkMemory::FlushMappedAlloc(GrVkGpu* gpu, const GrVkAlloc& alloc, VkDeviceSize offset, 291cb93a386Sopenharmony_ci VkDeviceSize size) { 292cb93a386Sopenharmony_ci if (alloc.fFlags & GrVkAlloc::kNoncoherent_Flag) { 293cb93a386Sopenharmony_ci SkASSERT(offset == 0); 294cb93a386Sopenharmony_ci SkASSERT(size <= alloc.fSize); 295cb93a386Sopenharmony_ci SkASSERT(alloc.fBackendMemory); 296cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 297cb93a386Sopenharmony_ci if (alloc.fAllocator != nullptr) { 298cb93a386Sopenharmony_ci allocator = alloc.fAllocator; 299cb93a386Sopenharmony_ci } 300cb93a386Sopenharmony_ci VkResult result = allocator->flushMemory(alloc.fBackendMemory, offset, size); 301cb93a386Sopenharmony_ci gpu->checkVkResult(result); 302cb93a386Sopenharmony_ci } 303cb93a386Sopenharmony_ci} 304cb93a386Sopenharmony_ci 305cb93a386Sopenharmony_civoid GrVkMemory::InvalidateMappedAlloc(GrVkGpu* gpu, const GrVkAlloc& alloc, 306cb93a386Sopenharmony_ci VkDeviceSize offset, VkDeviceSize size) { 307cb93a386Sopenharmony_ci if (alloc.fFlags & GrVkAlloc::kNoncoherent_Flag) { 308cb93a386Sopenharmony_ci SkASSERT(offset == 0); 309cb93a386Sopenharmony_ci SkASSERT(size <= alloc.fSize); 310cb93a386Sopenharmony_ci SkASSERT(alloc.fBackendMemory); 311cb93a386Sopenharmony_ci GrVkMemoryAllocator* allocator = gpu->memoryAllocator(); 312cb93a386Sopenharmony_ci if (alloc.fAllocator != nullptr) { 313cb93a386Sopenharmony_ci allocator = alloc.fAllocator; 314cb93a386Sopenharmony_ci } 315cb93a386Sopenharmony_ci VkResult result = allocator->invalidateMemory(alloc.fBackendMemory, offset, size); 316cb93a386Sopenharmony_ci gpu->checkVkResult(result); 317cb93a386Sopenharmony_ci } 318cb93a386Sopenharmony_ci} 319cb93a386Sopenharmony_ci 320