| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void GrVkBuffer::vkAbandon() { | 118 void GrVkBuffer::vkAbandon() { |
| 119 fResource->unrefAndAbandon(); | 119 fResource->unrefAndAbandon(); |
| 120 fMapPtr = nullptr; | 120 fMapPtr = nullptr; |
| 121 VALIDATE(); | 121 VALIDATE(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void* GrVkBuffer::vkMap(const GrVkGpu* gpu) { | 124 void* GrVkBuffer::vkMap(const GrVkGpu* gpu) { |
| 125 VALIDATE(); | 125 VALIDATE(); |
| 126 SkASSERT(!this->vkIsMapped()); | 126 SkASSERT(!this->vkIsMapped()); |
| 127 | 127 |
| 128 // we should be the only owner | 128 if (!fResource->unique()) { |
| 129 SkASSERT(fResource->unique()); | 129 // in use by the command buffer, so we need to create a new one |
| 130 fResource->unref(gpu); |
| 131 fResource = Create(gpu, fDesc); |
| 132 } |
| 130 | 133 |
| 131 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SI
ZE, 0, &fMapPtr)); | 134 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SI
ZE, 0, &fMapPtr)); |
| 132 if (err) { | 135 if (err) { |
| 133 fMapPtr = nullptr; | 136 fMapPtr = nullptr; |
| 134 } | 137 } |
| 135 | 138 |
| 136 VALIDATE(); | 139 VALIDATE(); |
| 137 return fMapPtr; | 140 return fMapPtr; |
| 138 } | 141 } |
| 139 | 142 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 180 |
| 178 return true; | 181 return true; |
| 179 } | 182 } |
| 180 | 183 |
| 181 void GrVkBuffer::validate() const { | 184 void GrVkBuffer::validate() const { |
| 182 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f
Type | 185 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f
Type |
| 183 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType | 186 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType |
| 184 || kUniform_Type == fDesc.fType); | 187 || kUniform_Type == fDesc.fType); |
| 185 } | 188 } |
| 186 | 189 |
| OLD | NEW |