| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu, | 61 bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu, |
| 62 VkBuffer buffer, | 62 VkBuffer buffer, |
| 63 const VkMemoryPropertyFlags flags, | 63 const VkMemoryPropertyFlags flags, |
| 64 VkDeviceMemory* memory) { | 64 VkDeviceMemory* memory) { |
| 65 const GrVkInterface* iface = gpu->vkInterface(); | 65 const GrVkInterface* iface = gpu->vkInterface(); |
| 66 VkDevice device = gpu->device(); | 66 VkDevice device = gpu->device(); |
| 67 | 67 |
| 68 VkMemoryRequirements memReqs; | 68 VkMemoryRequirements memReqs; |
| 69 GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs)); | 69 GR_VK_CALL(iface, GetBufferMemoryRequirements(device, buffer, &memReqs)); |
| 70 | 70 |
| 71 | |
| 72 if (!alloc_device_memory(gpu, &memReqs, flags, memory)) { | 71 if (!alloc_device_memory(gpu, &memReqs, flags, memory)) { |
| 73 return false; | 72 return false; |
| 74 } | 73 } |
| 75 | 74 |
| 76 // Bind Memory to queue | 75 // Bind Memory to queue |
| 77 VkResult err = GR_VK_CALL(iface, BindBufferMemory(device, buffer, *memory, 0
)); | 76 VkResult err = GR_VK_CALL(iface, BindBufferMemory(device, buffer, *memory, 0
)); |
| 78 if (err) { | 77 if (err) { |
| 79 GR_VK_CALL(iface, FreeMemory(device, *memory, nullptr)); | 78 GR_VK_CALL(iface, FreeMemory(device, *memory, nullptr)); |
| 80 return false; | 79 return false; |
| 81 } | 80 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 flags = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; | 146 flags = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; |
| 148 } else if (VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == layout) { | 147 } else if (VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == layout) { |
| 149 flags = VK_ACCESS_TRANSFER_WRITE_BIT; | 148 flags = VK_ACCESS_TRANSFER_WRITE_BIT; |
| 150 } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout) { | 149 } else if (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL == layout) { |
| 151 flags = VK_ACCESS_TRANSFER_READ_BIT; | 150 flags = VK_ACCESS_TRANSFER_READ_BIT; |
| 152 } else if (VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) { | 151 } else if (VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL == layout) { |
| 153 flags = VK_ACCESS_SHADER_READ_BIT; | 152 flags = VK_ACCESS_SHADER_READ_BIT; |
| 154 } | 153 } |
| 155 return flags; | 154 return flags; |
| 156 } | 155 } |
| OLD | NEW |