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 "GrVkBuffer.h" | 8 #include "GrVkBuffer.h" |
9 #include "GrVkGpu.h" | 9 #include "GrVkGpu.h" |
10 #include "GrVkMemory.h" | 10 #include "GrVkMemory.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 bufInfo.queueFamilyIndexCount = 0; | 50 bufInfo.queueFamilyIndexCount = 0; |
51 bufInfo.pQueueFamilyIndices = nullptr; | 51 bufInfo.pQueueFamilyIndices = nullptr; |
52 | 52 |
53 VkResult err; | 53 VkResult err; |
54 err = VK_CALL(gpu, CreateBuffer(gpu->device(), &bufInfo, nullptr, &buffer)); | 54 err = VK_CALL(gpu, CreateBuffer(gpu->device(), &bufInfo, nullptr, &buffer)); |
55 if (err) { | 55 if (err) { |
56 return nullptr; | 56 return nullptr; |
57 } | 57 } |
58 | 58 |
59 VkMemoryPropertyFlags requiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| | 59 VkMemoryPropertyFlags requiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| |
60 VK_MEMORY_PROPERTY_HOST_COHERENT_BI
T; | 60 VK_MEMORY_PROPERTY_HOST_COHERENT_BI
T | |
| 61 VK_MEMORY_PROPERTY_HOST_CACHED_BIT; |
61 | 62 |
62 if (!GrVkMemory::AllocAndBindBufferMemory(gpu, | 63 if (!GrVkMemory::AllocAndBindBufferMemory(gpu, |
63 buffer, | 64 buffer, |
64 requiredMemProps, | 65 requiredMemProps, |
65 &alloc)) { | 66 &alloc)) { |
66 VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr)); | 67 // Try again without requiring host cached memory |
67 return nullptr; | 68 requiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | |
| 69 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; |
| 70 if (!GrVkMemory::AllocAndBindBufferMemory(gpu, |
| 71 buffer, |
| 72 requiredMemProps, |
| 73 &alloc)) { |
| 74 VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr)); |
| 75 return nullptr; |
| 76 } |
68 } | 77 } |
69 | 78 |
70 const GrVkBuffer::Resource* resource = new GrVkBuffer::Resource(buffer, allo
c); | 79 const GrVkBuffer::Resource* resource = new GrVkBuffer::Resource(buffer, allo
c); |
71 if (!resource) { | 80 if (!resource) { |
72 VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr)); | 81 VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr)); |
73 VK_CALL(gpu, FreeMemory(gpu->device(), alloc, nullptr)); | 82 VK_CALL(gpu, FreeMemory(gpu->device(), alloc, nullptr)); |
74 return nullptr; | 83 return nullptr; |
75 } | 84 } |
76 | 85 |
77 return resource; | 86 return resource; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 189 |
181 return true; | 190 return true; |
182 } | 191 } |
183 | 192 |
184 void GrVkBuffer::validate() const { | 193 void GrVkBuffer::validate() const { |
185 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f
Type | 194 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f
Type |
186 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType | 195 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType |
187 || kUniform_Type == fDesc.fType); | 196 || kUniform_Type == fDesc.fType); |
188 } | 197 } |
189 | 198 |
OLD | NEW |