From 33910297e032b9af4336bc146c7fbb0f35918de9 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 18 Apr 2017 14:38:53 -0400 Subject: Fix some bugs with read/writePixels - On both GL and Vulkan, we must draw if writing to an MSAA surface. Otherwise we just write to the resolve target texture, which gets overwritten on the next resolve. - On Vulkan, we must draw if the target isn't a texture. (This check was already present in onWritePixels). - On Vulkan, when reading from an MSAA surface as a different config, we don't need the readConfig to be renderable with MSAA - the temp surface is always created non-MSAA. - Added tests for these fixes, verified that they failed previously. Bug: skia: Change-Id: Ia2d5025d7a8f8de8630413453f83b58028dd41aa Reviewed-on: https://skia-review.googlesource.com/13691 Commit-Queue: Brian Osman Reviewed-by: Greg Daniel Reviewed-by: Robert Phillips --- tests/WritePixelsTest.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'tests/WritePixelsTest.cpp') diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index f5cdddccd0..e26e134b2d 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -14,6 +14,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrGpu.h" #endif #include @@ -410,9 +411,45 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixels_Gpu, reporter, ctxInfo) { const SkImageInfo ii = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) { - sk_sp surface(SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo, - ii, 0, origin, nullptr)); - test_write_pixels(reporter, surface.get()); + for (int sampleCnt : {0, 4}) { + sk_sp surface(SkSurface::MakeRenderTarget(ctxInfo.grContext(), + SkBudgeted::kNo, ii, sampleCnt, + origin, nullptr)); + if (!surface && sampleCnt > 0) { + // Some platforms don't support MSAA + continue; + } + test_write_pixels(reporter, surface.get()); + } + } +} + +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixelsNonTexture_Gpu, reporter, ctxInfo) { + GrContext* context = ctxInfo.grContext(); + + for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) { + for (int sampleCnt : {0, 4}) { + GrBackendTextureDesc desc; + desc.fConfig = kSkia8888_GrPixelConfig; + desc.fWidth = DEV_W; + desc.fHeight = DEV_H; + desc.fFlags = kRenderTarget_GrBackendTextureFlag; + desc.fSampleCnt = sampleCnt; + desc.fOrigin = origin; + desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture( + nullptr, DEV_W, DEV_H, kSkia8888_GrPixelConfig, true); + sk_sp surface(SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc, + nullptr)); + if (!surface) { + context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle); + continue; + } + + test_write_pixels(reporter, surface.get()); + + surface.reset(); + context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle); + } } } #endif -- cgit v1.2.3