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

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

Issue 2093943002: Have gpu createTestingOlyBackendTexture know if it is a render target or not (Closed) Base URL: https://skia.googlesource.com/skia.git@moreUnitTests
Patch Set: Have gpu createTestingOlyBackendTexture know if it is a render target or not Created 4 years, 6 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') | tests/SurfaceTest.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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 VkFormat pixelFormat; 534 VkFormat pixelFormat;
535 if (!GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat)) { 535 if (!GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat)) {
536 return nullptr; 536 return nullptr;
537 } 537 }
538 538
539 if (!fVkCaps->isConfigTexturable(desc.fConfig)) { 539 if (!fVkCaps->isConfigTexturable(desc.fConfig)) {
540 return nullptr; 540 return nullptr;
541 } 541 }
542 542
543 if (renderTarget && !fVkCaps->isConfigRenderable(desc.fConfig, false)) {
544 return nullptr;
545 }
546
543 bool linearTiling = false; 547 bool linearTiling = false;
544 if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) { 548 if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) {
545 // we can't have a linear texture with a mipmap 549 // we can't have a linear texture with a mipmap
546 if (texels.count() > 1) { 550 if (texels.count() > 1) {
547 SkDebugf("Trying to create linear tiled texture with mipmap"); 551 SkDebugf("Trying to create linear tiled texture with mipmap");
548 return nullptr; 552 return nullptr;
549 } 553 }
550 if (fVkCaps->isConfigTexurableLinearly(desc.fConfig) && 554 if (fVkCaps->isConfigTexurableLinearly(desc.fConfig) &&
551 (!renderTarget || fVkCaps->isConfigRenderableLinearly(desc.fConfig, false))) { 555 (!renderTarget || fVkCaps->isConfigRenderableLinearly(desc.fConfig, false))) {
552 linearTiling = true; 556 linearTiling = true;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 height, 839 height,
836 samples, 840 samples,
837 sFmt)); 841 sFmt));
838 fStats.incStencilAttachmentCreates(); 842 fStats.incStencilAttachmentCreates();
839 return stencil; 843 return stencil;
840 } 844 }
841 845
842 //////////////////////////////////////////////////////////////////////////////// 846 ////////////////////////////////////////////////////////////////////////////////
843 847
844 GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i nt h, 848 GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i nt h,
845 GrPixelConfig config) { 849 GrPixelConfig config,
850 bool isRenderTarget) {
846 851
847 VkFormat pixelFormat; 852 VkFormat pixelFormat;
848 if (!GrPixelConfigToVkFormat(config, &pixelFormat)) { 853 if (!GrPixelConfigToVkFormat(config, &pixelFormat)) {
849 return 0; 854 return 0;
850 } 855 }
851 856
852 bool linearTiling = false; 857 bool linearTiling = false;
853 if (!fVkCaps->isConfigTexturable(config)) { 858 if (!fVkCaps->isConfigTexturable(config)) {
854 return 0; 859 return 0;
855 } 860 }
856 861
857 if (fVkCaps->isConfigTexurableLinearly(config)) { 862 if (isRenderTarget && !fVkCaps->isConfigRenderable(config, false)) {
863 return 0;
864 }
865
866 if (fVkCaps->isConfigTexurableLinearly(config) &&
867 (!isRenderTarget || fVkCaps->isConfigRenderableLinearly(config, false))) {
858 linearTiling = true; 868 linearTiling = true;
859 } 869 }
860 870
861 // Currently this is not supported since it requires a copy which has not ye t been implemented. 871 // Currently this is not supported since it requires a copy which has not ye t been implemented.
862 if (srcData && !linearTiling) { 872 if (srcData && !linearTiling) {
863 return 0; 873 return 0;
864 } 874 }
865 875
866 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; 876 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
867 usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; 877 usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
868 usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; 878 usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
879 if (isRenderTarget) {
880 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
881 }
869 882
870 VkImage image = VK_NULL_HANDLE; 883 VkImage image = VK_NULL_HANDLE;
871 GrVkAlloc alloc = { VK_NULL_HANDLE, 0, 0 }; 884 GrVkAlloc alloc = { VK_NULL_HANDLE, 0, 0 };
872 885
873 VkImageTiling imageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE _TILING_OPTIMAL; 886 VkImageTiling imageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE _TILING_OPTIMAL;
874 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageTiling) 887 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageTiling)
875 ? VK_IMAGE_LAYOUT_PREINITIALIZED 888 ? VK_IMAGE_LAYOUT_PREINITIALIZED
876 : VK_IMAGE_LAYOUT_UNDEFINED; 889 : VK_IMAGE_LAYOUT_UNDEFINED;
877 890
878 // Create Image 891 // Create Image
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 GrVkRenderTarget* target, 1429 GrVkRenderTarget* target,
1417 const SkIRect& bounds) { 1430 const SkIRect& bounds) {
1418 // Currently it is fine for us to always pass in 1 for the clear count even if no attachment 1431 // Currently it is fine for us to always pass in 1 for the clear count even if no attachment
1419 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment 1432 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment
1420 // which is always at the first attachment. 1433 // which is always at the first attachment.
1421 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, bounds, true); 1434 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, bounds, true);
1422 fCurrentCmdBuffer->executeCommands(this, buffer); 1435 fCurrentCmdBuffer->executeCommands(this, buffer);
1423 fCurrentCmdBuffer->endRenderPass(this); 1436 fCurrentCmdBuffer->endRenderPass(this);
1424 } 1437 }
1425 1438
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698