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

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

Issue 1914053004: Remove unnessary uniform barriers in Vulkan. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/GrVkGpu.cpp ('k') | src/gpu/vk/GrVkPipelineStateDataManager.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 2016 Google Inc. 2 * Copyright 2016 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 "GrVkPipelineState.h" 8 #include "GrVkPipelineState.h"
9 9
10 #include "GrPipeline.h" 10 #include "GrPipeline.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; 229 descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
230 descriptorWrites[0].pNext = nullptr; 230 descriptorWrites[0].pNext = nullptr;
231 descriptorWrites[0].dstSet = fDescriptorSets[GrVkUniformHandler::kUnifor mBufferDescSet]; 231 descriptorWrites[0].dstSet = fDescriptorSets[GrVkUniformHandler::kUnifor mBufferDescSet];
232 descriptorWrites[0].dstBinding = GrVkUniformHandler::kVertexBinding; 232 descriptorWrites[0].dstBinding = GrVkUniformHandler::kVertexBinding;
233 descriptorWrites[0].dstArrayElement = 0; 233 descriptorWrites[0].dstArrayElement = 0;
234 descriptorWrites[0].descriptorCount = 1; 234 descriptorWrites[0].descriptorCount = 1;
235 descriptorWrites[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; 235 descriptorWrites[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
236 descriptorWrites[0].pImageInfo = nullptr; 236 descriptorWrites[0].pImageInfo = nullptr;
237 descriptorWrites[0].pBufferInfo = &vertBufferInfo; 237 descriptorWrites[0].pBufferInfo = &vertBufferInfo;
238 descriptorWrites[0].pTexelBufferView = nullptr; 238 descriptorWrites[0].pTexelBufferView = nullptr;
239
240 fVertexUniformBuffer->addMemoryBarrier(gpu,
241 VK_ACCESS_HOST_WRITE_BIT,
242 VK_ACCESS_UNIFORM_READ_BIT,
243 VK_PIPELINE_STAGE_HOST_BIT,
244 VK_PIPELINE_STAGE_VERTEX_SHADER_B IT,
245 false);
246 } 239 }
247 240
248 VkDescriptorBufferInfo fragBufferInfo; 241 VkDescriptorBufferInfo fragBufferInfo;
249 // Fragment Uniform Buffer 242 // Fragment Uniform Buffer
250 if (fFragmentUniformBuffer.get()) { 243 if (fFragmentUniformBuffer.get()) {
251 if (0 == uniformBindingUpdateCount) { 244 if (0 == uniformBindingUpdateCount) {
252 firstUniformWrite = 1; 245 firstUniformWrite = 1;
253 } 246 }
254 ++uniformBindingUpdateCount; 247 ++uniformBindingUpdateCount;
255 memset(&fragBufferInfo, 0, sizeof(VkDescriptorBufferInfo)); 248 memset(&fragBufferInfo, 0, sizeof(VkDescriptorBufferInfo));
256 fragBufferInfo.buffer = fFragmentUniformBuffer->buffer(); 249 fragBufferInfo.buffer = fFragmentUniformBuffer->buffer();
257 fragBufferInfo.offset = 0; 250 fragBufferInfo.offset = 0;
258 fragBufferInfo.range = fFragmentUniformBuffer->size(); 251 fragBufferInfo.range = fFragmentUniformBuffer->size();
259 252
260 descriptorWrites[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; 253 descriptorWrites[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
261 descriptorWrites[1].pNext = nullptr; 254 descriptorWrites[1].pNext = nullptr;
262 descriptorWrites[1].dstSet = fDescriptorSets[GrVkUniformHandler::kUnifor mBufferDescSet]; 255 descriptorWrites[1].dstSet = fDescriptorSets[GrVkUniformHandler::kUnifor mBufferDescSet];
263 descriptorWrites[1].dstBinding = GrVkUniformHandler::kFragBinding;; 256 descriptorWrites[1].dstBinding = GrVkUniformHandler::kFragBinding;;
264 descriptorWrites[1].dstArrayElement = 0; 257 descriptorWrites[1].dstArrayElement = 0;
265 descriptorWrites[1].descriptorCount = 1; 258 descriptorWrites[1].descriptorCount = 1;
266 descriptorWrites[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; 259 descriptorWrites[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
267 descriptorWrites[1].pImageInfo = nullptr; 260 descriptorWrites[1].pImageInfo = nullptr;
268 descriptorWrites[1].pBufferInfo = &fragBufferInfo; 261 descriptorWrites[1].pBufferInfo = &fragBufferInfo;
269 descriptorWrites[1].pTexelBufferView = nullptr; 262 descriptorWrites[1].pTexelBufferView = nullptr;
270
271 fFragmentUniformBuffer->addMemoryBarrier(gpu,
272 VK_ACCESS_HOST_WRITE_BIT,
273 VK_ACCESS_UNIFORM_READ_BIT,
274 VK_PIPELINE_STAGE_HOST_BIT,
275 VK_PIPELINE_STAGE_FRAGMENT_SHAD ER_BIT,
276 false);
277 } 263 }
278 264
279 if (uniformBindingUpdateCount) { 265 if (uniformBindingUpdateCount) {
280 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), 266 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(),
281 uniformBindingUpdate Count, 267 uniformBindingUpdate Count,
282 &descriptorWrites[fi rstUniformWrite], 268 &descriptorWrites[fi rstUniformWrite],
283 0, nullptr)); 269 0, nullptr));
284 } 270 }
285 } 271 }
286 272
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 fPool = gpu->resourceProvider().findOrCreateCompatibleDescriptorPool(fDe scType, 405 fPool = gpu->resourceProvider().findOrCreateCompatibleDescriptorPool(fDe scType,
420 fMa xDescriptors); 406 fMa xDescriptors);
421 } 407 }
422 SkASSERT(fPool || !fMaxDescriptors); 408 SkASSERT(fPool || !fMaxDescriptors);
423 } 409 }
424 410
425 void GrVkPipelineState::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu, VkDescriptorSet* ds) { 411 void GrVkPipelineState::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu, VkDescriptorSet* ds) {
426 if (!fMaxDescriptors) { 412 if (!fMaxDescriptors) {
427 return; 413 return;
428 } 414 }
429 if (fCurrentDescriptorCount == fMaxDescriptors) { 415 fCurrentDescriptorCount += fDescCountPerSet;
416 if (fCurrentDescriptorCount > fMaxDescriptors) {
430 this->getNewPool(gpu); 417 this->getNewPool(gpu);
431 fCurrentDescriptorCount = 0; 418 fCurrentDescriptorCount = fDescCountPerSet;
432 } 419 }
433 fCurrentDescriptorCount += fDescCountPerSet;
434 420
435 VkDescriptorSetAllocateInfo dsAllocateInfo; 421 VkDescriptorSetAllocateInfo dsAllocateInfo;
436 memset(&dsAllocateInfo, 0, sizeof(VkDescriptorSetAllocateInfo)); 422 memset(&dsAllocateInfo, 0, sizeof(VkDescriptorSetAllocateInfo));
437 dsAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; 423 dsAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
438 dsAllocateInfo.pNext = nullptr; 424 dsAllocateInfo.pNext = nullptr;
439 dsAllocateInfo.descriptorPool = fPool->descPool(); 425 dsAllocateInfo.descriptorPool = fPool->descPool();
440 dsAllocateInfo.descriptorSetCount = 1; 426 dsAllocateInfo.descriptorSetCount = 1;
441 dsAllocateInfo.pSetLayouts = &fDescLayout; 427 dsAllocateInfo.pSetLayouts = &fDescLayout;
442 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), AllocateDescriptorSets(gpu->device() , 428 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), AllocateDescriptorSets(gpu->device() ,
443 &dsAllocateIn fo, 429 &dsAllocateIn fo,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 486
501 b.add32(get_blend_info_key(pipeline)); 487 b.add32(get_blend_info_key(pipeline));
502 488
503 b.add32(primitiveType); 489 b.add32(primitiveType);
504 490
505 // Set key length 491 // Set key length
506 int keyLength = key->count(); 492 int keyLength = key->count();
507 SkASSERT(0 == (keyLength % 4)); 493 SkASSERT(0 == (keyLength % 4));
508 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); 494 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength);
509 } 495 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | src/gpu/vk/GrVkPipelineStateDataManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698