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 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 SkRectMemcpy(buffer, rowBytes, mappedMemory, tightRowBytes, tightRow Bytes, height); | 1489 SkRectMemcpy(buffer, rowBytes, mappedMemory, tightRowBytes, tightRow Bytes, height); |
1490 } | 1490 } |
1491 } | 1491 } |
1492 | 1492 |
1493 transferBuffer->unmap(); | 1493 transferBuffer->unmap(); |
1494 transferBuffer->unref(); | 1494 transferBuffer->unref(); |
1495 | 1495 |
1496 return true; | 1496 return true; |
1497 } | 1497 } |
1498 | 1498 |
1499 // The RenderArea bounds we pass into BeginRenderPass must have a start x value that is a multiple | |
1500 // of the granularity. The width must also be a multiple of the granularity or e aqual to the width | |
1501 // the the entire attachment. Similar requirements for the y and height componen ts. | |
1502 void adjust_bounds_to_granularity(SkIRect* dstBounds, const SkIRect& srcBounds, | |
1503 const VkExtent2D& granularity, int maxWidth, i nt maxHeight) { | |
1504 // Adjust Width | |
1505 // Start with the right side of rect so we know if we end up going pass the maxWidth. | |
1506 int rightAdj = srcBounds.fRight % granularity.width; | |
jvanverth1
2016/07/07 18:05:34
This looks correct. But it seems like it should be
egdaniel
2016/07/07 18:44:59
I would imagine in practice the granularity (if th
| |
1507 if (rightAdj != 0) { | |
1508 rightAdj = granularity.width - rightAdj; | |
1509 } | |
1510 dstBounds->fRight = srcBounds.fRight + rightAdj; | |
1511 if (dstBounds->fRight > maxWidth) { | |
1512 dstBounds->fRight = maxWidth; | |
1513 dstBounds->fLeft = 0; | |
1514 } else { | |
1515 dstBounds->fLeft = srcBounds.fLeft - srcBounds.fLeft % granularity.width; | |
1516 } | |
1517 | |
1518 // Adjust height | |
1519 // Start with the bottom side of rect so we know if we end up going pass the maxHeight. | |
1520 int bottomAdj = srcBounds.fBottom % granularity.height; | |
1521 if (bottomAdj != 0) { | |
1522 bottomAdj = granularity.height - bottomAdj; | |
1523 } | |
1524 dstBounds->fBottom = srcBounds.fBottom + bottomAdj; | |
1525 if (dstBounds->fBottom > maxHeight) { | |
1526 dstBounds->fBottom = maxHeight; | |
1527 dstBounds->fTop = 0; | |
1528 } else { | |
1529 dstBounds->fTop = srcBounds.fTop - srcBounds.fTop % granularity.height; | |
1530 } | |
1531 } | |
1532 | |
1499 void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer, | 1533 void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer, |
1500 const GrVkRenderPass* renderPass, | 1534 const GrVkRenderPass* renderPass, |
1501 const VkClearValue* colorClear, | 1535 const VkClearValue* colorClear, |
1502 GrVkRenderTarget* target, | 1536 GrVkRenderTarget* target, |
1503 const SkIRect& bounds) { | 1537 const SkIRect& bounds) { |
1504 const SkIRect* pBounds = &bounds; | 1538 const SkIRect* pBounds = &bounds; |
1505 SkIRect flippedBounds; | 1539 SkIRect flippedBounds; |
1506 if (kBottomLeft_GrSurfaceOrigin == target->origin()) { | 1540 if (kBottomLeft_GrSurfaceOrigin == target->origin()) { |
1507 flippedBounds = bounds; | 1541 flippedBounds = bounds; |
1508 flippedBounds.fTop = target->height() - bounds.fBottom; | 1542 flippedBounds.fTop = target->height() - bounds.fBottom; |
1509 flippedBounds.fBottom = target->height() - bounds.fTop; | 1543 flippedBounds.fBottom = target->height() - bounds.fTop; |
1510 pBounds = &flippedBounds; | 1544 pBounds = &flippedBounds; |
1511 } | 1545 } |
1512 | 1546 |
1547 // The bounds we use for the render pass should be of the granularity suppor ted | |
1548 // by the device. | |
1549 const VkExtent2D& granularity = renderPass->granularity(); | |
1550 SkIRect adjustedBounds; | |
1551 if ((0 != granularity.width && 1 != granularity.width) || | |
1552 (0 != granularity.height && 1 != granularity.height)) { | |
1553 adjust_bounds_to_granularity(&adjustedBounds, *pBounds, granularity, | |
1554 target->width(), target->height()); | |
1555 pBounds = &adjustedBounds; | |
1556 } | |
1557 | |
1513 // Currently it is fine for us to always pass in 1 for the clear count even if no attachment | 1558 // Currently it is fine for us to always pass in 1 for the clear count even if no attachment |
1514 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment | 1559 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment |
1515 // which is always at the first attachment. | 1560 // which is always at the first attachment. |
1516 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, *pBounds, true); | 1561 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, *pBounds, true); |
1517 fCurrentCmdBuffer->executeCommands(this, buffer); | 1562 fCurrentCmdBuffer->executeCommands(this, buffer); |
1518 fCurrentCmdBuffer->endRenderPass(this); | 1563 fCurrentCmdBuffer->endRenderPass(this); |
1519 } | 1564 } |
1520 | 1565 |
OLD | NEW |