| 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 return nullptr; | 631 return nullptr; |
| 632 } | 632 } |
| 633 | 633 |
| 634 bool linearTiling = false; | 634 bool linearTiling = false; |
| 635 if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) { | 635 if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) { |
| 636 // we can't have a linear texture with a mipmap | 636 // we can't have a linear texture with a mipmap |
| 637 if (texels.count() > 1) { | 637 if (texels.count() > 1) { |
| 638 SkDebugf("Trying to create linear tiled texture with mipmap"); | 638 SkDebugf("Trying to create linear tiled texture with mipmap"); |
| 639 return nullptr; | 639 return nullptr; |
| 640 } | 640 } |
| 641 if (fVkCaps->isConfigTexurableLinearly(desc.fConfig) && | 641 if (fVkCaps->isConfigTexturableLinearly(desc.fConfig) && |
| 642 (!renderTarget || fVkCaps->isConfigRenderableLinearly(desc.fConfig,
false))) { | 642 (!renderTarget || fVkCaps->isConfigRenderableLinearly(desc.fConfig,
false))) { |
| 643 linearTiling = true; | 643 linearTiling = true; |
| 644 } else { | 644 } else { |
| 645 return nullptr; | 645 return nullptr; |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 | 648 |
| 649 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; | 649 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 650 if (renderTarget) { | 650 if (renderTarget) { |
| 651 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | 651 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 | 985 |
| 986 bool linearTiling = false; | 986 bool linearTiling = false; |
| 987 if (!fVkCaps->isConfigTexturable(config)) { | 987 if (!fVkCaps->isConfigTexturable(config)) { |
| 988 return 0; | 988 return 0; |
| 989 } | 989 } |
| 990 | 990 |
| 991 if (isRenderTarget && !fVkCaps->isConfigRenderable(config, false)) { | 991 if (isRenderTarget && !fVkCaps->isConfigRenderable(config, false)) { |
| 992 return 0; | 992 return 0; |
| 993 } | 993 } |
| 994 | 994 |
| 995 if (fVkCaps->isConfigTexurableLinearly(config) && | 995 if (fVkCaps->isConfigTexturableLinearly(config) && |
| 996 (!isRenderTarget || fVkCaps->isConfigRenderableLinearly(config, false)))
{ | 996 (!isRenderTarget || fVkCaps->isConfigRenderableLinearly(config, false)))
{ |
| 997 linearTiling = true; | 997 linearTiling = true; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; | 1000 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1001 usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | 1001 usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1002 usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; | 1002 usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 1003 if (isRenderTarget) { | 1003 if (isRenderTarget) { |
| 1004 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | 1004 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 1005 } | 1005 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 VK_PIPELINE_STAGE_TRANSFER_BIT, | 1168 VK_PIPELINE_STAGE_TRANSFER_BIT, |
| 1169 0, | 1169 0, |
| 1170 0, nullptr, | 1170 0, nullptr, |
| 1171 1, &bufBarrier, | 1171 1, &bufBarrier, |
| 1172 0, nullptr)); | 1172 0, nullptr)); |
| 1173 | 1173 |
| 1174 // Submit copy command | 1174 // Submit copy command |
| 1175 VkBufferImageCopy region; | 1175 VkBufferImageCopy region; |
| 1176 memset(®ion, 0, sizeof(VkBufferImageCopy)); | 1176 memset(®ion, 0, sizeof(VkBufferImageCopy)); |
| 1177 region.bufferOffset = 0; | 1177 region.bufferOffset = 0; |
| 1178 region.bufferRowLength = (uint32_t)rowCopyBytes; | 1178 region.bufferRowLength = w; |
| 1179 region.bufferImageHeight = h; | 1179 region.bufferImageHeight = h; |
| 1180 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; | 1180 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; |
| 1181 region.imageOffset = { 0, 0, 0 }; | 1181 region.imageOffset = { 0, 0, 0 }; |
| 1182 region.imageExtent = { (uint32_t)w, (uint32_t)h, 1 }; | 1182 region.imageExtent = { (uint32_t)w, (uint32_t)h, 1 }; |
| 1183 | 1183 |
| 1184 VK_CALL(CmdCopyBufferToImage(cmdBuffer, buffer, image, initialLayout
, 1, ®ion)); | 1184 VK_CALL(CmdCopyBufferToImage(cmdBuffer, buffer, image, initialLayout
, 1, ®ion)); |
| 1185 | 1185 |
| 1186 // End CommandBuffer | 1186 // End CommandBuffer |
| 1187 err = VK_CALL(EndCommandBuffer(cmdBuffer)); | 1187 err = VK_CALL(EndCommandBuffer(cmdBuffer)); |
| 1188 SkASSERT(!err); | 1188 SkASSERT(!err); |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1772 } | 1772 } |
| 1773 | 1773 |
| 1774 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment | 1774 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment |
| 1775 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment | 1775 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment |
| 1776 // which is always at the first attachment. | 1776 // which is always at the first attachment. |
| 1777 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); | 1777 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); |
| 1778 fCurrentCmdBuffer->executeCommands(this, buffer); | 1778 fCurrentCmdBuffer->executeCommands(this, buffer); |
| 1779 fCurrentCmdBuffer->endRenderPass(this); | 1779 fCurrentCmdBuffer->endRenderPass(this); |
| 1780 } | 1780 } |
| 1781 | 1781 |
| OLD | NEW |