From f44cb487523c21b3998772458726b958c31f31be Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Tue, 27 Feb 2018 14:26:32 -0500 Subject: [PATCH] Fix unit tests that were causes vulkan unitialized memory warnings in validation Bug: skia: Change-Id: Id9df92b76c9f948f41f4108bcecdb2687233f841 Reviewed-on: https://skia-review.googlesource.com/110761 Reviewed-by: Brian Osman Commit-Queue: Greg Daniel --- src/gpu/GrContext.cpp | 3 +++ src/gpu/effects/GrConfigConversionEffect.fp | 8 ++++++++ src/gpu/effects/GrConfigConversionEffect.h | 8 ++++++++ tests/PrimitiveProcessorTest.cpp | 3 +++ tests/TessellatingPathRendererTests.cpp | 3 +++ 5 files changed, 25 insertions(+) diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index cc311b6e87..74fbe10ac1 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -871,6 +871,9 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, int left, int top, GrMipMapped::kNo, tempDrawInfo.fTempSurfaceDesc.fOrigin); if (tempRTC) { + // Adding discard to appease vulkan validation warning about loading uninitialized data + // on draw + tempRTC->discard(); SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top)); sk_sp proxy = src->asTextureProxyRef(); auto fp = GrSimpleTextureEffect::Make(std::move(proxy), textureMatrix); diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp index 856195b0bd..569011135e 100644 --- a/src/gpu/effects/GrConfigConversionEffect.fp +++ b/src/gpu/effects/GrConfigConversionEffect.fp @@ -49,6 +49,10 @@ if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) { return false; } + // Adding discard to appease vulkan validation warning about loading uninitialized data on + // draw + readRTC->discard(); + GrSurfaceDesc desc; desc.fOrigin = kTopLeft_GrSurfaceOrigin; desc.fWidth = kSize; @@ -87,6 +91,10 @@ return false; } + // Adding discard to appease vulkan validation warning about loading uninitialized data on + // draw + tempRTC->discard(); + paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), SkMatrix::I()); paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h index b3709cafc8..ec5c2b3e41 100644 --- a/src/gpu/effects/GrConfigConversionEffect.h +++ b/src/gpu/effects/GrConfigConversionEffect.h @@ -53,6 +53,10 @@ public: if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) { return false; } + // Adding discard to appease vulkan validation warning about loading uninitialized data on + // draw + readRTC->discard(); + GrSurfaceDesc desc; desc.fOrigin = kTopLeft_GrSurfaceOrigin; desc.fWidth = kSize; @@ -91,6 +95,10 @@ public: return false; } + // Adding discard to appease vulkan validation warning about loading uninitialized data on + // draw + tempRTC->discard(); + paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), SkMatrix::I()); paint2.addColorFragmentProcessor(std::move(upmToPM)); paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index d402e65f1c..089d6ce1bf 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -134,6 +134,9 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 0); REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0); #endif + // Adding discard to appease vulkan validation warning about loading uninitialized data on draw + renderTargetContext->discard(); + GrPaint grPaint; // This one should succeed. renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(attribCnt)); diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp index e24bf7a516..f6304f5b18 100644 --- a/tests/TessellatingPathRendererTests.cpp +++ b/tests/TessellatingPathRendererTests.cpp @@ -493,6 +493,9 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { } ctx->flush(); + // Adding discard to appease vulkan validation warning about loading uninitialized data on draw + rtc->discard(); + test_path(ctx, rtc.get(), create_path_0()); test_path(ctx, rtc.get(), create_path_1()); test_path(ctx, rtc.get(), create_path_2());