OLD | NEW |
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 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool GrVkGpu::prepareDrawState(const GrPipeline& pipeline, |
1297 const GrPrimitiveProcessor& primProc, | 1297 const GrPrimitiveProcessor& primProc, |
1298 GrPrimitiveType primitiveType, | 1298 GrPrimitiveType primitiveType, |
1299 const GrVkRenderPass& renderPass, | 1299 const GrVkRenderPass& renderPass, |
1300 GrVkPipelineState** pipelineState) { | 1300 sk_sp<GrVkPipelineState>* pipelineState) { |
1301 *pipelineState = fResourceProvider.findOrCreateCompatiblePipelineState(pipel
ine, | 1301 *pipelineState = fResourceProvider.findOrCreateCompatiblePipelineState(pipel
ine, |
1302 primP
roc, | 1302 primP
roc, |
1303 primi
tiveType, | 1303 primi
tiveType, |
1304 rende
rPass); | 1304 rende
rPass); |
1305 if (!pipelineState) { | 1305 if (!*pipelineState) { |
1306 return false; | 1306 return false; |
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 true; |
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; | 1332 sk_sp<GrVkPipelineState> pipelineState = nullptr; |
1333 GrPrimitiveType primitiveType = meshes[0].primitiveType(); | 1333 GrPrimitiveType primitiveType = meshes[0].primitiveType(); |
1334 if (!this->prepareDrawState(pipeline, primProc, primitiveType, *renderPass,
&pipelineState)) { | 1334 if (!this->prepareDrawState(pipeline, primProc, primitiveType, *renderPass,
&pipelineState)) { |
1335 return; | 1335 return; |
1336 } | 1336 } |
1337 | 1337 |
1338 // Change layout of our render target so it can be used as the color attachm
ent | 1338 // Change layout of our render target so it can be used as the color attachm
ent |
1339 VkImageLayout layout = vkRT->currentLayout(); | 1339 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 | 1340 // Our color attachment is purely a destination and won't be read so don't n
eed to flush or |
1341 // invalidate any caches | 1341 // invalidate any caches |
1342 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(l
ayout); | 1342 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(l
ayout); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1379 |
1380 const GrMesh& mesh = meshes[i]; | 1380 const GrMesh& mesh = meshes[i]; |
1381 GrMesh::Iterator iter; | 1381 GrMesh::Iterator iter; |
1382 const GrNonInstancedMesh* nonIdxMesh = iter.init(mesh); | 1382 const GrNonInstancedMesh* nonIdxMesh = iter.init(mesh); |
1383 do { | 1383 do { |
1384 if (nonIdxMesh->primitiveType() != primitiveType) { | 1384 if (nonIdxMesh->primitiveType() != primitiveType) { |
1385 // Technically we don't have to call this here (since there is a
safety check in | 1385 // 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 | 1386 // pipelineState:setData but this will allow for quicker freeing
of resources if the |
1387 // pipelineState sits in a cache for a while. | 1387 // pipelineState sits in a cache for a while. |
1388 pipelineState->freeTempResources(this); | 1388 pipelineState->freeTempResources(this); |
1389 pipelineState->unref(); | |
1390 SkDEBUGCODE(pipelineState = nullptr); | 1389 SkDEBUGCODE(pipelineState = nullptr); |
1391 primitiveType = nonIdxMesh->primitiveType(); | 1390 primitiveType = nonIdxMesh->primitiveType(); |
1392 if (!this->prepareDrawState(pipeline, primProc, primitiveType, *
renderPass, | 1391 if (!this->prepareDrawState(pipeline, primProc, primitiveType, *
renderPass, |
1393 &pipelineState)) { | 1392 &pipelineState)) { |
1394 return; | 1393 return; |
1395 } | 1394 } |
1396 } | 1395 } |
1397 SkASSERT(pipelineState); | 1396 SkASSERT(pipelineState); |
1398 this->bindGeometry(primProc, *nonIdxMesh); | 1397 this->bindGeometry(primProc, *nonIdxMesh); |
1399 | 1398 |
(...skipping 15 matching lines...) Expand all Loading... |
1415 fStats.incNumDraws(); | 1414 fStats.incNumDraws(); |
1416 } while ((nonIdxMesh = iter.next())); | 1415 } while ((nonIdxMesh = iter.next())); |
1417 } | 1416 } |
1418 | 1417 |
1419 fCurrentCmdBuffer->endRenderPass(this); | 1418 fCurrentCmdBuffer->endRenderPass(this); |
1420 | 1419 |
1421 // Technically we don't have to call this here (since there is a safety chec
k in | 1420 // 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 | 1421 // pipelineState:setData but this will allow for quicker freeing of resource
s if the |
1423 // pipelineState sits in a cache for a while. | 1422 // pipelineState sits in a cache for a while. |
1424 pipelineState->freeTempResources(this); | 1423 pipelineState->freeTempResources(this); |
1425 pipelineState->unref(); | |
1426 | 1424 |
1427 #if SWAP_PER_DRAW | 1425 #if SWAP_PER_DRAW |
1428 glFlush(); | 1426 glFlush(); |
1429 #if defined(SK_BUILD_FOR_MAC) | 1427 #if defined(SK_BUILD_FOR_MAC) |
1430 aglSwapBuffers(aglGetCurrentContext()); | 1428 aglSwapBuffers(aglGetCurrentContext()); |
1431 int set_a_break_pt_here = 9; | 1429 int set_a_break_pt_here = 9; |
1432 aglSwapBuffers(aglGetCurrentContext()); | 1430 aglSwapBuffers(aglGetCurrentContext()); |
1433 #elif defined(SK_BUILD_FOR_WIN32) | 1431 #elif defined(SK_BUILD_FOR_WIN32) |
1434 SwapBuf(); | 1432 SwapBuf(); |
1435 int set_a_break_pt_here = 9; | 1433 int set_a_break_pt_here = 9; |
1436 SwapBuf(); | 1434 SwapBuf(); |
1437 #endif | 1435 #endif |
1438 #endif | 1436 #endif |
1439 } | 1437 } |
1440 | 1438 |
OLD | NEW |