| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 VALIDATE(); | 145 VALIDATE(); |
| 146 return fMapPtr; | 146 return fMapPtr; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void GrVkBuffer::vkUnmap(GrVkGpu* gpu) { | 149 void GrVkBuffer::vkUnmap(GrVkGpu* gpu) { |
| 150 VALIDATE(); | 150 VALIDATE(); |
| 151 SkASSERT(this->vkIsMapped()); | 151 SkASSERT(this->vkIsMapped()); |
| 152 | 152 |
| 153 if (fDesc.fDynamic) { | 153 if (fDesc.fDynamic) { |
| 154 GrVkMemory::FlushMappedAlloc(gpu, this->alloc()); |
| 154 VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory)); | 155 VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory)); |
| 155 } else { | 156 } else { |
| 156 gpu->updateBuffer(this, fMapPtr, this->offset(), this->size()); | 157 gpu->updateBuffer(this, fMapPtr, this->offset(), this->size()); |
| 157 delete [] (unsigned char*)fMapPtr; | 158 delete [] (unsigned char*)fMapPtr; |
| 158 } | 159 } |
| 159 | 160 |
| 160 fMapPtr = nullptr; | 161 fMapPtr = nullptr; |
| 161 } | 162 } |
| 162 | 163 |
| 163 bool GrVkBuffer::vkIsMapped() const { | 164 bool GrVkBuffer::vkIsMapped() const { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 192 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, | 193 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, |
| 193 alloc.fOffset + fOffset, | 194 alloc.fOffset + fOffset, |
| 194 srcSizeInBytes, 0, &mapPtr)); | 195 srcSizeInBytes, 0, &mapPtr)); |
| 195 | 196 |
| 196 if (VK_SUCCESS != err) { | 197 if (VK_SUCCESS != err) { |
| 197 return false; | 198 return false; |
| 198 } | 199 } |
| 199 | 200 |
| 200 memcpy(mapPtr, src, srcSizeInBytes); | 201 memcpy(mapPtr, src, srcSizeInBytes); |
| 201 | 202 |
| 203 GrVkMemory::FlushMappedAlloc(gpu, this->alloc()); |
| 202 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc.fMemory)); | 204 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc.fMemory)); |
| 203 | 205 |
| 204 return true; | 206 return true; |
| 205 } | 207 } |
| 206 | 208 |
| 207 void GrVkBuffer::validate() const { | 209 void GrVkBuffer::validate() const { |
| 208 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f
Type | 210 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f
Type |
| 209 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType | 211 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType |
| 210 || kUniform_Type == fDesc.fType); | 212 || kUniform_Type == fDesc.fType); |
| 211 } | 213 } |
| OLD | NEW |