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

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

Issue 1816153002: Set up cache in vulkan to reuse GrVkPrograms (aka VkPipelines) (Closed) Base URL: https://skia.googlesource.com/skia.git@progSamplers
Patch Set: cleanup 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
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 "GrVkGpu.h" 8 #include "GrVkGpu.h"
9 9
10 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 imageDesc.fLevels = 1; 521 imageDesc.fLevels = 1;
522 imageDesc.fSamples = 1; 522 imageDesc.fSamples = 1;
523 imageDesc.fImageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TI LING_OPTIMAL; 523 imageDesc.fImageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TI LING_OPTIMAL;
524 imageDesc.fUsageFlags = usageFlags; 524 imageDesc.fUsageFlags = usageFlags;
525 imageDesc.fMemProps = memProps; 525 imageDesc.fMemProps = memProps;
526 526
527 GrVkTexture* tex; 527 GrVkTexture* tex;
528 if (renderTarget) { 528 if (renderTarget) {
529 tex = GrVkTextureRenderTarget::CreateNewTextureRenderTarget(this, desc, lifeCycle, 529 tex = GrVkTextureRenderTarget::CreateNewTextureRenderTarget(this, desc, lifeCycle,
530 imageDesc); 530 imageDesc);
531 #if 0
532 // This clear can be included to fix warning described in htttps://bugs. skia.org/5045
533 // Obviously we do not want to be clearling needlessly every time we cre ate a render target.
534 SkIRect rect = SkIRect::MakeWH(tex->width(), tex->height());
535 this->clear(rect, GrColor_TRANSPARENT_BLACK, tex->asRenderTarget());
536 #endif
537 } else { 531 } else {
538 tex = GrVkTexture::CreateNewTexture(this, desc, lifeCycle, imageDesc); 532 tex = GrVkTexture::CreateNewTexture(this, desc, lifeCycle, imageDesc);
539 } 533 }
540 534
541 if (!tex) { 535 if (!tex) {
542 return nullptr; 536 return nullptr;
543 } 537 }
544 538
545 // TODO: We're ignoring MIP levels here. 539 // TODO: We're ignoring MIP levels here.
546 if (!texels.empty()) { 540 if (!texels.empty()) {
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 memcpy(tmpRow, top, tightRowBytes); 1301 memcpy(tmpRow, top, tightRowBytes);
1308 memcpy(top, bottom, tightRowBytes); 1302 memcpy(top, bottom, tightRowBytes);
1309 memcpy(bottom, tmpRow, tightRowBytes); 1303 memcpy(bottom, tmpRow, tightRowBytes);
1310 top += rowBytes; 1304 top += rowBytes;
1311 bottom -= rowBytes; 1305 bottom -= rowBytes;
1312 } 1306 }
1313 } 1307 }
1314 1308
1315 return true; 1309 return true;
1316 } 1310 }
1317
1318 bool GrVkGpu::prepareDrawState(const GrPipeline& pipeline, 1311 bool GrVkGpu::prepareDrawState(const GrPipeline& pipeline,
1319 const GrPrimitiveProcessor& primProc, 1312 const GrPrimitiveProcessor& primProc,
1320 GrPrimitiveType primitiveType, 1313 GrPrimitiveType primitiveType,
1321 const GrVkRenderPass& renderPass, 1314 const GrVkRenderPass& renderPass,
1322 GrVkProgram** program) { 1315 GrVkProgram** program) {
1323 // Get GrVkProgramDesc 1316 *program = fResourceProvider.findOrCreateCompatibleProgram(pipeline,
1324 GrVkProgramDesc desc; 1317 primProc,
1325 if (!GrVkProgramDescBuilder::Build(&desc, primProc, pipeline, *this->vkCaps( ).glslCaps())) { 1318 primitiveType,
1326 GrCapsDebugf(this->caps(), "Failed to vk program descriptor!\n"); 1319 renderPass);
1327 return false;
1328 }
1329
1330 *program = GrVkProgramBuilder::CreateProgram(this,
1331 pipeline,
1332 primProc,
1333 primitiveType,
1334 desc,
1335 renderPass);
1336 if (!program) { 1320 if (!program) {
1337 return false; 1321 return false;
1338 } 1322 }
1339 1323
1340 (*program)->setData(this, primProc, pipeline); 1324 (*program)->setData(this, primProc, pipeline);
1341 1325
1342 (*program)->bind(this, fCurrentCmdBuffer); 1326 (*program)->bind(this, fCurrentCmdBuffer);
1343 1327
1344 GrVkPipeline::SetDynamicState(this, fCurrentCmdBuffer, pipeline); 1328 GrVkPipeline::SetDynamicState(this, fCurrentCmdBuffer, pipeline);
1345 1329
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 fStats.incNumDraws(); 1433 fStats.incNumDraws();
1450 } while ((nonIdxMesh = iter.next())); 1434 } while ((nonIdxMesh = iter.next()));
1451 } 1435 }
1452 1436
1453 fCurrentCmdBuffer->endRenderPass(this); 1437 fCurrentCmdBuffer->endRenderPass(this);
1454 1438
1455 // Technically we don't have to call this here (since there is a safety chec k in program:setData 1439 // Technically we don't have to call this here (since there is a safety chec k in program:setData
1456 // but this will allow for quicker freeing of resources if the program sits in a cache for a 1440 // but this will allow for quicker freeing of resources if the program sits in a cache for a
1457 // while. 1441 // while.
1458 program->freeTempResources(this); 1442 program->freeTempResources(this);
1459 // This free will go away once we setup a program cache, and then the cache will be responsible
1460 // for call freeGpuResources.
1461 program->freeGPUResources(this);
1462 program->unref(); 1443 program->unref();
1463 1444
1464 #if SWAP_PER_DRAW 1445 #if SWAP_PER_DRAW
1465 glFlush(); 1446 glFlush();
1466 #if defined(SK_BUILD_FOR_MAC) 1447 #if defined(SK_BUILD_FOR_MAC)
1467 aglSwapBuffers(aglGetCurrentContext()); 1448 aglSwapBuffers(aglGetCurrentContext());
1468 int set_a_break_pt_here = 9; 1449 int set_a_break_pt_here = 9;
1469 aglSwapBuffers(aglGetCurrentContext()); 1450 aglSwapBuffers(aglGetCurrentContext());
1470 #elif defined(SK_BUILD_FOR_WIN32) 1451 #elif defined(SK_BUILD_FOR_WIN32)
1471 SwapBuf(); 1452 SwapBuf();
1472 int set_a_break_pt_here = 9; 1453 int set_a_break_pt_here = 9;
1473 SwapBuf(); 1454 SwapBuf();
1474 #endif 1455 #endif
1475 #endif 1456 #endif
1476 } 1457 }
1477 1458
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698