| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 dst += trimRowBytes; | 526 dst += trimRowBytes; |
| 527 } | 527 } |
| 528 } else if (trimRowBytes == rowBytes) { | 528 } else if (trimRowBytes == rowBytes) { |
| 529 memcpy(dst, src, trimRowBytes * currentHeight); | 529 memcpy(dst, src, trimRowBytes * currentHeight); |
| 530 } else { | 530 } else { |
| 531 SkRectMemcpy(dst, trimRowBytes, src, rowBytes, trimRowBytes, current
Height); | 531 SkRectMemcpy(dst, trimRowBytes, src, rowBytes, trimRowBytes, current
Height); |
| 532 } | 532 } |
| 533 | 533 |
| 534 VkBufferImageCopy& region = regions.push_back(); | 534 VkBufferImageCopy& region = regions.push_back(); |
| 535 memset(®ion, 0, sizeof(VkBufferImageCopy)); | 535 memset(®ion, 0, sizeof(VkBufferImageCopy)); |
| 536 region.bufferOffset = individualMipOffsets[currentMipLevel]; | 536 region.bufferOffset = transferBuffer->offset() + individualMipOffsets[cu
rrentMipLevel]; |
| 537 region.bufferRowLength = currentWidth; | 537 region.bufferRowLength = currentWidth; |
| 538 region.bufferImageHeight = currentHeight; | 538 region.bufferImageHeight = currentHeight; |
| 539 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, SkToU32(currentMi
pLevel), 0, 1 }; | 539 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, SkToU32(currentMi
pLevel), 0, 1 }; |
| 540 region.imageOffset = { left, flipY ? tex->height() - top - currentHeight
: top, 0 }; | 540 region.imageOffset = { left, flipY ? tex->height() - top - currentHeight
: top, 0 }; |
| 541 region.imageExtent = { (uint32_t)currentWidth, (uint32_t)currentHeight,
1 }; | 541 region.imageExtent = { (uint32_t)currentWidth, (uint32_t)currentHeight,
1 }; |
| 542 | 542 |
| 543 currentWidth = SkTMax(1, currentWidth/2); | 543 currentWidth = SkTMax(1, currentWidth/2); |
| 544 currentHeight = SkTMax(1, currentHeight/2); | 544 currentHeight = SkTMax(1, currentHeight/2); |
| 545 } | 545 } |
| 546 | 546 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 tex->unref(); | 663 tex->unref(); |
| 664 return nullptr; | 664 return nullptr; |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 | 667 |
| 668 return tex; | 668 return tex; |
| 669 } | 669 } |
| 670 | 670 |
| 671 //////////////////////////////////////////////////////////////////////////////// | 671 //////////////////////////////////////////////////////////////////////////////// |
| 672 | 672 |
| 673 bool GrVkGpu::updateBuffer(GrVkBuffer* buffer, const void* src, size_t srcSizeIn
Bytes) { | 673 bool GrVkGpu::updateBuffer(GrVkBuffer* buffer, const void* src, |
| 674 VkDeviceSize offset, VkDeviceSize size) { |
| 674 | 675 |
| 675 // Update the buffer | 676 // Update the buffer |
| 676 fCurrentCmdBuffer->updateBuffer(this, buffer, 0, srcSizeInBytes, src); | 677 fCurrentCmdBuffer->updateBuffer(this, buffer, offset, size, src); |
| 677 | 678 |
| 678 return true; | 679 return true; |
| 679 } | 680 } |
| 680 | 681 |
| 681 //////////////////////////////////////////////////////////////////////////////// | 682 //////////////////////////////////////////////////////////////////////////////// |
| 682 | 683 |
| 683 static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin) { | 684 static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin) { |
| 684 // By default, all textures in Vk use TopLeft | 685 // By default, all textures in Vk use TopLeft |
| 685 if (kDefault_GrSurfaceOrigin == origin) { | 686 if (kDefault_GrSurfaceOrigin == origin) { |
| 686 return kTopLeft_GrSurfaceOrigin; | 687 return kTopLeft_GrSurfaceOrigin; |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); | 1439 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); |
| 1439 VkOffset3D offset = { | 1440 VkOffset3D offset = { |
| 1440 left, | 1441 left, |
| 1441 flipY ? surface->height() - top - height : top, | 1442 flipY ? surface->height() - top - height : top, |
| 1442 0 | 1443 0 |
| 1443 }; | 1444 }; |
| 1444 | 1445 |
| 1445 // Copy the image to a buffer so we can map it to cpu memory | 1446 // Copy the image to a buffer so we can map it to cpu memory |
| 1446 VkBufferImageCopy region; | 1447 VkBufferImageCopy region; |
| 1447 memset(®ion, 0, sizeof(VkBufferImageCopy)); | 1448 memset(®ion, 0, sizeof(VkBufferImageCopy)); |
| 1448 region.bufferOffset = 0; | 1449 region.bufferOffset = transferBuffer->offset(); |
| 1449 region.bufferRowLength = 0; // Forces RowLength to be width. We handle the r
owBytes below. | 1450 region.bufferRowLength = 0; // Forces RowLength to be width. We handle the r
owBytes below. |
| 1450 region.bufferImageHeight = 0; // Forces height to be tightly packed. Only us
eful for 3d images. | 1451 region.bufferImageHeight = 0; // Forces height to be tightly packed. Only us
eful for 3d images. |
| 1451 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; | 1452 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; |
| 1452 region.imageOffset = offset; | 1453 region.imageOffset = offset; |
| 1453 region.imageExtent = { (uint32_t)width, (uint32_t)height, 1 }; | 1454 region.imageExtent = { (uint32_t)width, (uint32_t)height, 1 }; |
| 1454 | 1455 |
| 1455 fCurrentCmdBuffer->copyImageToBuffer(this, | 1456 fCurrentCmdBuffer->copyImageToBuffer(this, |
| 1456 tgt, | 1457 tgt, |
| 1457 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, | 1458 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 1458 transferBuffer, | 1459 transferBuffer, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 } | 1512 } |
| 1512 | 1513 |
| 1513 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment | 1514 // 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 | 1515 // 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. | 1516 // which is always at the first attachment. |
| 1516 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); | 1517 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); |
| 1517 fCurrentCmdBuffer->executeCommands(this, buffer); | 1518 fCurrentCmdBuffer->executeCommands(this, buffer); |
| 1518 fCurrentCmdBuffer->endRenderPass(this); | 1519 fCurrentCmdBuffer->endRenderPass(this); |
| 1519 } | 1520 } |
| 1520 | 1521 |
| OLD | NEW |