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

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

Issue 1836863002: Change VkPipelineStateCahce to use Hash and LRU LList. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update macro name 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/GrVkGpu.h ('k') | src/gpu/vk/GrVkPipelineStateCache.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 "GrVkGpu.h" 8 #include "GrVkGpu.h"
9 9
10 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 memcpy(tmpRow, top, tightRowBytes); 1286 memcpy(tmpRow, top, tightRowBytes);
1287 memcpy(top, bottom, tightRowBytes); 1287 memcpy(top, bottom, tightRowBytes);
1288 memcpy(bottom, tmpRow, tightRowBytes); 1288 memcpy(bottom, tmpRow, tightRowBytes);
1289 top += rowBytes; 1289 top += rowBytes;
1290 bottom -= rowBytes; 1290 bottom -= rowBytes;
1291 } 1291 }
1292 } 1292 }
1293 1293
1294 return true; 1294 return true;
1295 } 1295 }
1296 bool GrVkGpu::prepareDrawState(const GrPipeline& pipeline, 1296 sk_sp<GrVkPipelineState> GrVkGpu::prepareDrawState(const GrPipeline& pipeline,
1297 const GrPrimitiveProcessor& primProc, 1297 const GrPrimitiveProcessor& p rimProc,
1298 GrPrimitiveType primitiveType, 1298 GrPrimitiveType primitiveType ,
1299 const GrVkRenderPass& renderPass, 1299 const GrVkRenderPass& renderP ass) {
1300 GrVkPipelineState** pipelineState) { 1300 sk_sp<GrVkPipelineState> pipelineState =
1301 *pipelineState = fResourceProvider.findOrCreateCompatiblePipelineState(pipel ine, 1301 fResourceProvider.findOrCreateCompatiblePipelineState(pipeline,
1302 primP roc, 1302 primProc,
1303 primi tiveType, 1303 primitiveType,
1304 rende rPass); 1304 renderPass);
1305 if (!pipelineState) { 1305 if (!pipelineState) {
1306 return false; 1306 return pipelineState;
1307 } 1307 }
1308 1308
1309 (*pipelineState)->setData(this, primProc, pipeline); 1309 pipelineState->setData(this, primProc, pipeline);
1310 1310
1311 (*pipelineState)->bind(this, fCurrentCmdBuffer); 1311 pipelineState->bind(this, fCurrentCmdBuffer);
1312 1312
1313 GrVkPipeline::SetDynamicState(this, fCurrentCmdBuffer, pipeline); 1313 GrVkPipeline::SetDynamicState(this, fCurrentCmdBuffer, pipeline);
1314 1314
1315 return true; 1315 return pipelineState;
1316 } 1316 }
1317 1317
1318 void GrVkGpu::onDraw(const GrPipeline& pipeline, 1318 void GrVkGpu::onDraw(const GrPipeline& pipeline,
1319 const GrPrimitiveProcessor& primProc, 1319 const GrPrimitiveProcessor& primProc,
1320 const GrMesh* meshes, 1320 const GrMesh* meshes,
1321 int meshCount) { 1321 int meshCount) {
1322 if (!meshCount) { 1322 if (!meshCount) {
1323 return; 1323 return;
1324 } 1324 }
1325 GrRenderTarget* rt = pipeline.getRenderTarget(); 1325 GrRenderTarget* rt = pipeline.getRenderTarget();
1326 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(rt); 1326 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(rt);
1327 const GrVkRenderPass* renderPass = vkRT->simpleRenderPass(); 1327 const GrVkRenderPass* renderPass = vkRT->simpleRenderPass();
1328 SkASSERT(renderPass); 1328 SkASSERT(renderPass);
1329 1329
1330 fCurrentCmdBuffer->beginRenderPass(this, renderPass, *vkRT); 1330 fCurrentCmdBuffer->beginRenderPass(this, renderPass, *vkRT);
1331 1331
1332 GrVkPipelineState* pipelineState = nullptr;
1333 GrPrimitiveType primitiveType = meshes[0].primitiveType(); 1332 GrPrimitiveType primitiveType = meshes[0].primitiveType();
1334 if (!this->prepareDrawState(pipeline, primProc, primitiveType, *renderPass, &pipelineState)) { 1333 sk_sp<GrVkPipelineState> pipelineState = this->prepareDrawState(pipeline,
1334 primProc,
1335 primitiveTyp e,
1336 *renderPass) ;
1337 if (!pipelineState) {
1335 return; 1338 return;
1336 } 1339 }
1337 1340
1338 // Change layout of our render target so it can be used as the color attachm ent 1341 // Change layout of our render target so it can be used as the color attachm ent
1339 VkImageLayout layout = vkRT->currentLayout(); 1342 VkImageLayout layout = vkRT->currentLayout();
1340 // Our color attachment is purely a destination and won't be read so don't n eed to flush or 1343 // Our color attachment is purely a destination and won't be read so don't n eed to flush or
1341 // invalidate any caches 1344 // invalidate any caches
1342 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(l ayout); 1345 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(l ayout);
1343 VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; 1346 VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
1344 VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(layout); 1347 VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(layout);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 1382
1380 const GrMesh& mesh = meshes[i]; 1383 const GrMesh& mesh = meshes[i];
1381 GrMesh::Iterator iter; 1384 GrMesh::Iterator iter;
1382 const GrNonInstancedMesh* nonIdxMesh = iter.init(mesh); 1385 const GrNonInstancedMesh* nonIdxMesh = iter.init(mesh);
1383 do { 1386 do {
1384 if (nonIdxMesh->primitiveType() != primitiveType) { 1387 if (nonIdxMesh->primitiveType() != primitiveType) {
1385 // Technically we don't have to call this here (since there is a safety check in 1388 // Technically we don't have to call this here (since there is a safety check in
1386 // pipelineState:setData but this will allow for quicker freeing of resources if the 1389 // pipelineState:setData but this will allow for quicker freeing of resources if the
1387 // pipelineState sits in a cache for a while. 1390 // pipelineState sits in a cache for a while.
1388 pipelineState->freeTempResources(this); 1391 pipelineState->freeTempResources(this);
1389 pipelineState->unref();
1390 SkDEBUGCODE(pipelineState = nullptr); 1392 SkDEBUGCODE(pipelineState = nullptr);
1391 primitiveType = nonIdxMesh->primitiveType(); 1393 primitiveType = nonIdxMesh->primitiveType();
1392 if (!this->prepareDrawState(pipeline, primProc, primitiveType, * renderPass, 1394 pipelineState = this->prepareDrawState(pipeline,
1393 &pipelineState)) { 1395 primProc,
1396 primitiveType,
1397 *renderPass);
1398 if (!pipelineState) {
1394 return; 1399 return;
1395 } 1400 }
1396 } 1401 }
1397 SkASSERT(pipelineState); 1402 SkASSERT(pipelineState);
1398 this->bindGeometry(primProc, *nonIdxMesh); 1403 this->bindGeometry(primProc, *nonIdxMesh);
1399 1404
1400 if (nonIdxMesh->isIndexed()) { 1405 if (nonIdxMesh->isIndexed()) {
1401 fCurrentCmdBuffer->drawIndexed(this, 1406 fCurrentCmdBuffer->drawIndexed(this,
1402 nonIdxMesh->indexCount(), 1407 nonIdxMesh->indexCount(),
1403 1, 1408 1,
(...skipping 11 matching lines...) Expand all
1415 fStats.incNumDraws(); 1420 fStats.incNumDraws();
1416 } while ((nonIdxMesh = iter.next())); 1421 } while ((nonIdxMesh = iter.next()));
1417 } 1422 }
1418 1423
1419 fCurrentCmdBuffer->endRenderPass(this); 1424 fCurrentCmdBuffer->endRenderPass(this);
1420 1425
1421 // Technically we don't have to call this here (since there is a safety chec k in 1426 // Technically we don't have to call this here (since there is a safety chec k in
1422 // pipelineState:setData but this will allow for quicker freeing of resource s if the 1427 // pipelineState:setData but this will allow for quicker freeing of resource s if the
1423 // pipelineState sits in a cache for a while. 1428 // pipelineState sits in a cache for a while.
1424 pipelineState->freeTempResources(this); 1429 pipelineState->freeTempResources(this);
1425 pipelineState->unref();
1426 1430
1427 #if SWAP_PER_DRAW 1431 #if SWAP_PER_DRAW
1428 glFlush(); 1432 glFlush();
1429 #if defined(SK_BUILD_FOR_MAC) 1433 #if defined(SK_BUILD_FOR_MAC)
1430 aglSwapBuffers(aglGetCurrentContext()); 1434 aglSwapBuffers(aglGetCurrentContext());
1431 int set_a_break_pt_here = 9; 1435 int set_a_break_pt_here = 9;
1432 aglSwapBuffers(aglGetCurrentContext()); 1436 aglSwapBuffers(aglGetCurrentContext());
1433 #elif defined(SK_BUILD_FOR_WIN32) 1437 #elif defined(SK_BUILD_FOR_WIN32)
1434 SwapBuf(); 1438 SwapBuf();
1435 int set_a_break_pt_here = 9; 1439 int set_a_break_pt_here = 9;
1436 SwapBuf(); 1440 SwapBuf();
1437 #endif 1441 #endif
1438 #endif 1442 #endif
1439 } 1443 }
1440 1444
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | src/gpu/vk/GrVkPipelineStateCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698