diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index a1311005f8..e9630270f6 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -522,10 +522,6 @@ enum GrSurfaceFlags { * GrTexture::asRenderTarget() to access. */ kRenderTarget_GrSurfaceFlag = 0x1, - /** - * Placeholder for managing zero-copy textures - */ - kZeroCopy_GrSurfaceFlag = 0x2, }; GR_MAKE_BITFIELD_OPS(GrSurfaceFlags) diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 968902bf0e..7fbca9f9da 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -696,21 +696,6 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget return nullptr; } - bool linearTiling = false; - if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) { - // we can't have a linear texture with a mipmap - if (texels.count() > 1) { - SkDebugf("Trying to create linear tiled texture with mipmap"); - return nullptr; - } - if (fVkCaps->isConfigTexturableLinearly(desc.fConfig) && - (!renderTarget || fVkCaps->isConfigRenderableLinearly(desc.fConfig, false))) { - linearTiling = true; - } else { - return nullptr; - } - } - VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; if (renderTarget) { usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; @@ -724,9 +709,6 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget // texture. usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; - VkFlags memProps = (!texels.empty() && linearTiling) ? VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT : - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - // This ImageDesc refers to the texture that will be read by the client. Thus even if msaa is // requested, this ImageDesc describes the resolved texture. Therefore we always have samples set // to 1. @@ -736,11 +718,11 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget imageDesc.fFormat = pixelFormat; imageDesc.fWidth = desc.fWidth; imageDesc.fHeight = desc.fHeight; - imageDesc.fLevels = linearTiling ? 1 : mipLevels; + imageDesc.fLevels = mipLevels; imageDesc.fSamples = 1; - imageDesc.fImageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL; + imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL; imageDesc.fUsageFlags = usageFlags; - imageDesc.fMemProps = memProps; + imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; GrVkTexture* tex; if (renderTarget) { @@ -756,15 +738,8 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget if (!texels.empty()) { SkASSERT(texels.begin()->fPixels); - bool success; - if (linearTiling) { - success = this->uploadTexDataLinear(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig, - texels.begin()->fPixels, texels.begin()->fRowBytes); - } else { - success = this->uploadTexDataOptimal(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig, - texels); - } - if (!success) { + if (!this->uploadTexDataOptimal(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig, + texels)) { tex->unref(); return nullptr; } diff --git a/tests/VkUploadPixelsTests.cpp b/tests/VkUploadPixelsTests.cpp index 417457e1a2..7f5001c17e 100644 --- a/tests/VkUploadPixelsTests.cpp +++ b/tests/VkUploadPixelsTests.cpp @@ -52,7 +52,7 @@ bool does_full_buffer_contain_correct_color(GrColor* srcBuffer, } void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixelConfig config, - bool renderTarget, bool linearTiling) { + bool renderTarget) { const int kWidth = 16; const int kHeight = 16; SkAutoTMalloc srcBuffer(kWidth*kHeight); @@ -60,23 +60,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe fill_pixel_data(kWidth, kHeight, srcBuffer.get()); - const GrVkCaps* caps = reinterpret_cast(context->caps()); - - bool canCreate = true; - // the expectation is that the given config is texturable/renderable with optimal tiling - // but may not be with linear tiling - if (linearTiling) { - if (!caps->isConfigTexturableLinearly(config) || - (renderTarget && !caps->isConfigRenderableLinearly(config, false))) { - canCreate = false; - } - } - GrSurfaceDesc surfDesc; surfDesc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags; - if (linearTiling) { - surfDesc.fFlags |= kZeroCopy_GrSurfaceFlag; - } surfDesc.fOrigin = kTopLeft_GrSurfaceOrigin; surfDesc.fWidth = kWidth; surfDesc.fHeight = kHeight; @@ -89,10 +74,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe sk_sp proxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(), surfDesc, SkBudgeted::kNo, srcBuffer, 0); - + REPORTER_ASSERT(reporter, proxy); if (proxy) { - REPORTER_ASSERT(reporter, canCreate); - sk_sp sContext = context->contextPriv().makeWrappedSurfaceContext( proxy, nullptr); @@ -118,8 +101,6 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe dstBuffer, 10, 2)); - } else { - REPORTER_ASSERT(reporter, !canCreate); } surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; @@ -127,9 +108,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe proxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(), surfDesc, SkBudgeted::kNo, srcBuffer, 0); + REPORTER_ASSERT(reporter, proxy); if (proxy) { - REPORTER_ASSERT(reporter, canCreate); - sk_sp sContext = context->contextPriv().makeWrappedSurfaceContext( proxy, nullptr); @@ -156,23 +136,17 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe 4, 5)); - } else { - REPORTER_ASSERT(reporter, !canCreate); } } DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkUploadPixelsTests, reporter, ctxInfo) { // RGBA - basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false, false); - basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true, false); - basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false, true); - basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true, true); + basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false); + basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true); // BGRA - basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false, false); - basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true, false); - basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false, true); - basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true, true); + basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false); + basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true); } #endif