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

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

Issue 1872553005: Don't create new descriptor set for vulkan uniforms every draw (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « src/gpu/vk/GrVkBuffer.h ('k') | src/gpu/vk/GrVkPipelineState.cpp » ('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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc())); 156 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc()));
157 157
158 fMapPtr = nullptr; 158 fMapPtr = nullptr;
159 } 159 }
160 160
161 bool GrVkBuffer::vkIsMapped() const { 161 bool GrVkBuffer::vkIsMapped() const {
162 VALIDATE(); 162 VALIDATE();
163 return SkToBool(fMapPtr); 163 return SkToBool(fMapPtr);
164 } 164 }
165 165
166 bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz eInBytes) { 166 bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz eInBytes,
167 bool* createdNewBuffer) {
167 SkASSERT(!this->vkIsMapped()); 168 SkASSERT(!this->vkIsMapped());
168 VALIDATE(); 169 VALIDATE();
169 if (srcSizeInBytes > fDesc.fSizeInBytes) { 170 if (srcSizeInBytes > fDesc.fSizeInBytes) {
170 return false; 171 return false;
171 } 172 }
172 173
173 if (!fResource->unique()) { 174 if (!fResource->unique()) {
174 // in use by the command buffer, so we need to create a new one 175 // in use by the command buffer, so we need to create a new one
175 fResource->unref(gpu); 176 fResource->unref(gpu);
176 fResource = Create(gpu, fDesc); 177 fResource = Create(gpu, fDesc);
178 if (createdNewBuffer) {
179 *createdNewBuffer = true;
180 }
177 } 181 }
178 182
179 void* mapPtr; 183 void* mapPtr;
180 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, srcSizeInBy tes, 0, &mapPtr)); 184 VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, srcSizeInBy tes, 0, &mapPtr));
181 185
182 if (VK_SUCCESS != err) { 186 if (VK_SUCCESS != err) {
183 return false; 187 return false;
184 } 188 }
185 189
186 memcpy(mapPtr, src, srcSizeInBytes); 190 memcpy(mapPtr, src, srcSizeInBytes);
187 191
188 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc())); 192 VK_CALL(gpu, UnmapMemory(gpu->device(), alloc()));
189 193
190 return true; 194 return true;
191 } 195 }
192 196
193 void GrVkBuffer::validate() const { 197 void GrVkBuffer::validate() const {
194 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type 198 SkASSERT(!fResource || kVertex_Type == fDesc.fType || kIndex_Type == fDesc.f Type
195 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType 199 || kCopyRead_Type == fDesc.fType || kCopyWrite_Type == fDesc.fType
196 || kUniform_Type == fDesc.fType); 200 || kUniform_Type == fDesc.fType);
197 } 201 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkBuffer.h ('k') | src/gpu/vk/GrVkPipelineState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698