Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/gpu/vk/GrVkBuffer.cpp

Issue 2348523002: Support use of non-coherent memory allocations in Vulkan. (Closed)
Patch Set: Fix viewer init Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « include/gpu/vk/GrVkTypes.h ('k') | src/gpu/vk/GrVkGpu.cpp » ('j') | src/gpu/vk/GrVkMemory.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698