| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrVkMemory.h" | 8 #include "GrVkMemory.h" |
| 9 | 9 |
| 10 #include "GrVkGpu.h" | 10 #include "GrVkGpu.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 GR_STATIC_ASSERT(2 == GrVkBuffer::kUniform_Type); | 42 GR_STATIC_ASSERT(2 == GrVkBuffer::kUniform_Type); |
| 43 GR_STATIC_ASSERT(3 == GrVkBuffer::kCopyRead_Type); | 43 GR_STATIC_ASSERT(3 == GrVkBuffer::kCopyRead_Type); |
| 44 GR_STATIC_ASSERT(4 == GrVkBuffer::kCopyWrite_Type); | 44 GR_STATIC_ASSERT(4 == GrVkBuffer::kCopyWrite_Type); |
| 45 | 45 |
| 46 return kBufferToHeap[type]; | 46 return kBufferToHeap[type]; |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu, | 49 bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu, |
| 50 VkBuffer buffer, | 50 VkBuffer buffer, |
| 51 GrVkBuffer::Type type, | 51 GrVkBuffer::Type type, |
| 52 bool dynamic, |
| 52 GrVkAlloc* alloc) { | 53 GrVkAlloc* alloc) { |
| 53 const GrVkInterface* iface = gpu->vkInterface(); | 54 const GrVkInterface* iface = gpu->vkInterface(); |
| 54 VkDevice device = gpu->device(); | 55 VkDevice device = gpu->device(); |
| 55 | 56 |
| 56 VkMemoryRequirements memReqs; | 57 VkMemoryRequirements memReqs; |
| 57 GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs)); | 58 GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs)); |
| 58 | 59 |
| 59 VkMemoryPropertyFlags desiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| | 60 VkMemoryPropertyFlags desiredMemProps = dynamic ? VK_MEMORY_PROPERTY_HOST_VI
SIBLE_BIT | |
| 60 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| | 61 VK_MEMORY_PROPERTY_HOST_CO
HERENT_BIT | |
| 61 VK_MEMORY_PROPERTY_HOST_CACHED_BIT; | 62 VK_MEMORY_PROPERTY_HOST_CA
CHED_BIT |
| 63 : VK_MEMORY_PROPERTY_DEVICE_
LOCAL_BIT; |
| 62 uint32_t typeIndex = 0; | 64 uint32_t typeIndex = 0; |
| 63 if (!get_valid_memory_type_index(gpu->physicalDeviceMemoryProperties(), | 65 if (!get_valid_memory_type_index(gpu->physicalDeviceMemoryProperties(), |
| 64 memReqs.memoryTypeBits, | 66 memReqs.memoryTypeBits, |
| 65 desiredMemProps, | 67 desiredMemProps, |
| 66 &typeIndex)) { | 68 &typeIndex)) { |
| 67 // this memory type should always be available | 69 // this memory type should always be available |
| 68 SkASSERT_RELEASE(get_valid_memory_type_index(gpu->physicalDeviceMemoryPr
operties(), | 70 SkASSERT_RELEASE(get_valid_memory_type_index(gpu->physicalDeviceMemoryPr
operties(), |
| 69 memReqs.memoryTypeBits, | 71 memReqs.memoryTypeBits, |
| 70 VK_MEMORY_PROPERTY_HOST_VIS
IBLE_BIT | | 72 VK_MEMORY_PROPERTY_HOST_VIS
IBLE_BIT | |
| 71 VK_MEMORY_PROPERTY_HOST_COH
ERENT_BIT, | 73 VK_MEMORY_PROPERTY_HOST_COH
ERENT_BIT, |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 fSubHeaps[i]->free(alloc); | 558 fSubHeaps[i]->free(alloc); |
| 557 fUsedSize -= alloc.fSize; | 559 fUsedSize -= alloc.fSize; |
| 558 return true; | 560 return true; |
| 559 } | 561 } |
| 560 } | 562 } |
| 561 | 563 |
| 562 return false; | 564 return false; |
| 563 } | 565 } |
| 564 | 566 |
| 565 | 567 |
| OLD | NEW |