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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 GrVkAlloc* alloc) { | 52 GrVkAlloc* alloc) { |
53 const GrVkInterface* iface = gpu->vkInterface(); | 53 const GrVkInterface* iface = gpu->vkInterface(); |
54 VkDevice device = gpu->device(); | 54 VkDevice device = gpu->device(); |
55 | 55 |
56 VkMemoryRequirements memReqs; | 56 VkMemoryRequirements memReqs; |
57 GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs)); | 57 GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs)); |
58 | 58 |
59 VkMemoryPropertyFlags desiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| | 59 VkMemoryPropertyFlags desiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| |
60 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| | 60 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| |
61 VK_MEMORY_PROPERTY_HOST_CACHED_BIT; | 61 VK_MEMORY_PROPERTY_HOST_CACHED_BIT; |
62 uint32_t typeIndex; | 62 uint32_t typeIndex = 0; |
63 if (!get_valid_memory_type_index(gpu->physicalDeviceMemoryProperties(), | 63 if (!get_valid_memory_type_index(gpu->physicalDeviceMemoryProperties(), |
64 memReqs.memoryTypeBits, | 64 memReqs.memoryTypeBits, |
65 desiredMemProps, | 65 desiredMemProps, |
66 &typeIndex)) { | 66 &typeIndex)) { |
67 // this memory type should always be available | 67 // this memory type should always be available |
68 SkASSERT_RELEASE(get_valid_memory_type_index(gpu->physicalDeviceMemoryPr
operties(), | 68 SkASSERT_RELEASE(get_valid_memory_type_index(gpu->physicalDeviceMemoryPr
operties(), |
69 memReqs.memoryTypeBits, | 69 memReqs.memoryTypeBits, |
70 VK_MEMORY_PROPERTY_HOST_VIS
IBLE_BIT | | 70 VK_MEMORY_PROPERTY_HOST_VIS
IBLE_BIT | |
71 VK_MEMORY_PROPERTY_HOST_COH
ERENT_BIT, | 71 VK_MEMORY_PROPERTY_HOST_COH
ERENT_BIT, |
72 &typeIndex)); | 72 &typeIndex)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 bool GrVkMemory::AllocAndBindImageMemory(const GrVkGpu* gpu, | 111 bool GrVkMemory::AllocAndBindImageMemory(const GrVkGpu* gpu, |
112 VkImage image, | 112 VkImage image, |
113 bool linearTiling, | 113 bool linearTiling, |
114 GrVkAlloc* alloc) { | 114 GrVkAlloc* alloc) { |
115 const GrVkInterface* iface = gpu->vkInterface(); | 115 const GrVkInterface* iface = gpu->vkInterface(); |
116 VkDevice device = gpu->device(); | 116 VkDevice device = gpu->device(); |
117 | 117 |
118 VkMemoryRequirements memReqs; | 118 VkMemoryRequirements memReqs; |
119 GR_VK_CALL(iface, GetImageMemoryRequirements(device, image, &memReqs)); | 119 GR_VK_CALL(iface, GetImageMemoryRequirements(device, image, &memReqs)); |
120 | 120 |
121 uint32_t typeIndex; | 121 uint32_t typeIndex = 0; |
122 GrVkHeap* heap; | 122 GrVkHeap* heap; |
123 if (linearTiling) { | 123 if (linearTiling) { |
124 VkMemoryPropertyFlags desiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_
BIT | | 124 VkMemoryPropertyFlags desiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_
BIT | |
125 VK_MEMORY_PROPERTY_HOST_COHERENT
_BIT | | 125 VK_MEMORY_PROPERTY_HOST_COHERENT
_BIT | |
126 VK_MEMORY_PROPERTY_HOST_CACHED_B
IT; | 126 VK_MEMORY_PROPERTY_HOST_CACHED_B
IT; |
127 if (!get_valid_memory_type_index(gpu->physicalDeviceMemoryProperties(), | 127 if (!get_valid_memory_type_index(gpu->physicalDeviceMemoryProperties(), |
128 memReqs.memoryTypeBits, | 128 memReqs.memoryTypeBits, |
129 desiredMemProps, | 129 desiredMemProps, |
130 &typeIndex)) { | 130 &typeIndex)) { |
131 // this memory type should always be available | 131 // this memory type should always be available |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 fSubHeaps[i]->free(alloc); | 518 fSubHeaps[i]->free(alloc); |
519 fUsedSize -= alloc.fSize; | 519 fUsedSize -= alloc.fSize; |
520 return true; | 520 return true; |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 return false; | 524 return false; |
525 } | 525 } |
526 | 526 |
527 | 527 |
OLD | NEW |