Lines Matching defs:gpu

7 #include "src/gpu/vk/GrVkMemory.h"
16 #include "src/gpu/vk/GrVkGpu.h"
17 #include "src/gpu/vk/GrVkUtil.h"
24 static bool FindMemoryType(GrVkGpu *gpu, uint32_t typeFilter, VkMemoryPropertyFlags properties, uint32_t &typeIndex)
26 VkPhysicalDevice physicalDevice = gpu->physicalDevice();
28 VK_CALL(gpu, GetPhysicalDeviceMemoryProperties(physicalDevice, &memProperties));
44 bool GrVkMemory::AllocAndBindBufferMemory(GrVkGpu* gpu,
53 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
57 bool shouldPersistentlyMapCpuToGpu = gpu->vkCaps().shouldPersistentlyMapCpuToGpuBuffers();
68 if (!gpu->checkVkResult(result)) {
75 gpu->addAllocBufferBytes(size);
80 GR_VK_CALL_RESULT(gpu, err, BindBufferMemory(gpu->device(), buffer, alloc->fMemory,
83 FreeBufferMemory(gpu, *alloc);
90 bool GrVkMemory::ImportAndBindBufferMemory(GrVkGpu* gpu,
95 VkDevice device = gpu->device();
97 VK_CALL(gpu, GetBufferMemoryRequirements(device, buffer, &memReqs));
100 bool hasFound = FindMemoryType(gpu, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, typeIndex);
125 GR_VK_CALL_RESULT(gpu, err, AllocateMemory(device, &allocateInfo, nullptr, &memory));
131 GR_VK_CALL_RESULT(gpu, err, BindBufferMemory(device, buffer, memory, 0));
133 VK_CALL(gpu, FreeMemory(device, memory, nullptr));
146 void GrVkMemory::FreeBufferMemory(const GrVkGpu* gpu, const GrVkAlloc& alloc) {
148 ((GrVkGpu*)gpu)->removeAllocBufferBytes(alloc.fBytes);
151 VK_CALL(gpu, FreeMemory(gpu->device(), alloc.fMemory, nullptr));
154 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
162 bool GrVkMemory::AllocAndBindImageMemory(GrVkGpu* gpu,
167 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
173 allocator = gpu->memoryAllocatorCacheImage();
179 GR_VK_CALL(gpu->vkInterface(), GetImageMemoryRequirements(gpu->device(), image, &memReqs));
188 } else if (gpu->vkCaps().shouldAlwaysUseDedicatedImageMemory()) {
194 if (gpu->protectedContext()) {
205 if (!gpu->checkVkResult(result)) {
213 gpu->addAllocImageBytes(memorySize);
220 GR_VK_CALL_RESULT(gpu, err, BindImageMemory(gpu->device(), image, alloc->fMemory,
223 FreeImageMemory(gpu, *alloc);
231 void GrVkMemory::FreeImageMemory(const GrVkGpu* gpu, const GrVkAlloc& alloc) {
233 ((GrVkGpu*)gpu)->removeAllocImageBytes(alloc.fBytes);
236 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
243 void* GrVkMemory::MapAlloc(GrVkGpu* gpu, const GrVkAlloc& alloc) {
246 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
252 if (!gpu->checkVkResult(result)) {
258 void GrVkMemory::UnmapAlloc(const GrVkGpu* gpu, const GrVkAlloc& alloc) {
260 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
290 void GrVkMemory::FlushMappedAlloc(GrVkGpu* gpu, const GrVkAlloc& alloc, VkDeviceSize offset,
296 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
301 gpu->checkVkResult(result);
305 void GrVkMemory::InvalidateMappedAlloc(GrVkGpu* gpu, const GrVkAlloc& alloc,
311 GrVkMemoryAllocator* allocator = gpu->memoryAllocator();
316 gpu->checkVkResult(result);