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

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

Issue 1774963003: Buffer fix for VkProgram caching (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 9 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
« no previous file with comments | « no previous file | src/gpu/vk/GrVkProgramDataManager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
129 SkASSERT(fResource->unique());
130
128 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SI ZE, 0, &fMapPtr)); 131 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SI ZE, 0, &fMapPtr));
129 if (err) { 132 if (err) {
130 fMapPtr = nullptr; 133 fMapPtr = nullptr;
131 } 134 }
132 135
133 VALIDATE(); 136 VALIDATE();
134 return fMapPtr; 137 return fMapPtr;
135 } 138 }
136 139
137 void GrVkBuffer::vkUnmap(const GrVkGpu* gpu) { 140 void GrVkBuffer::vkUnmap(const GrVkGpu* gpu) {
(...skipping 10 matching lines...) Expand all
148 return SkToBool(fMapPtr); 151 return SkToBool(fMapPtr);
149 } 152 }
150 153
151 bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz eInBytes) { 154 bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz eInBytes) {
152 SkASSERT(!this->vkIsMapped()); 155 SkASSERT(!this->vkIsMapped());
153 VALIDATE(); 156 VALIDATE();
154 if (srcSizeInBytes > fDesc.fSizeInBytes) { 157 if (srcSizeInBytes > fDesc.fSizeInBytes) {
155 return false; 158 return false;
156 } 159 }
157 160
161 if (!fResource->unique()) {
162 // in use by the command buffer, so we need to create a new one
163 fResource->unref(gpu);
164 fResource = Create(gpu, fDesc);
165 }
166
158 void* mapPtr; 167 void* mapPtr;
159 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, srcSizeInBy tes, 0, &mapPtr)); 168 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, srcSizeInBy tes, 0, &mapPtr));
160 169
161 if (VK_SUCCESS != err) { 170 if (VK_SUCCESS != err) {
162 return false; 171 return false;
163 } 172 }
164 173
165 memcpy(mapPtr, src, srcSizeInBytes); 174 memcpy(mapPtr, src, srcSizeInBytes);
166 175
167 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc())); 176 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc()));
168 177
169 return true; 178 return true;
170 } 179 }
171 180
172 void GrVkBuffer::validate() const { 181 void GrVkBuffer::validate() const {
173 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type 182 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type
174 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType 183 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType
175 || kUniform_Type == fDesc.fType); 184 || kUniform_Type == fDesc.fType);
176 } 185 }
177 186
OLDNEW
« no previous file with comments | « no previous file | src/gpu/vk/GrVkProgramDataManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698