From: Greg Daniel Date: Tue, 18 Apr 2017 17:32:10 +0000 (-0400) Subject: Allow the dst of vulkan resolves to be a non RT X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~36^2~734 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc26c392b2f2e27ea554347dfdb5f994b6dc54f2;p=platform%2Fupstream%2FlibSkiaSharp.git Allow the dst of vulkan resolves to be a non RT Bug: skia: Change-Id: I79884127719b2364c2a986beda8856bee0583a5b Reviewed-on: https://skia-review.googlesource.com/13724 Commit-Queue: Greg Daniel Reviewed-by: Brian Osman --- diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index b3401e1..cf7a39b 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -380,7 +380,7 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, return success; } -void GrVkGpu::resolveImage(GrVkRenderTarget* dst, GrVkRenderTarget* src, const SkIRect& srcRect, +void GrVkGpu::resolveImage(GrSurface* dst, GrVkRenderTarget* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { SkASSERT(dst); SkASSERT(src && src->numColorSamples() > 1 && src->msaaImage()); @@ -407,11 +407,21 @@ void GrVkGpu::resolveImage(GrVkRenderTarget* dst, GrVkRenderTarget* src, const S resolveInfo.dstOffset = { dstPoint.fX, dstY, 0 }; resolveInfo.extent = { (uint32_t)srcVkRect.width(), (uint32_t)srcVkRect.height(), 1 }; - dst->setImageLayout(this, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - VK_ACCESS_TRANSFER_WRITE_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, - false); + GrVkImage* dstImage; + GrRenderTarget* dstRT = dst->asRenderTarget(); + if (dstRT) { + GrVkRenderTarget* vkRT = static_cast(dstRT); + SkASSERT(vkRT->numColorSamples() <= 1); + dstImage = vkRT; + } else { + SkASSERT(dst->asTexture()); + dstImage = static_cast(dst->asTexture()); + } + dstImage->setImageLayout(this, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_ACCESS_TRANSFER_WRITE_BIT, + VK_PIPELINE_STAGE_TRANSFER_BIT, + false); src->msaaImage()->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, @@ -419,7 +429,7 @@ void GrVkGpu::resolveImage(GrVkRenderTarget* dst, GrVkRenderTarget* src, const S VK_PIPELINE_STAGE_TRANSFER_BIT, false); - fCurrentCmdBuffer->resolveImage(this, *src->msaaImage(), *dst, 1, &resolveInfo); + fCurrentCmdBuffer->resolveImage(this, *src->msaaImage(), *dstImage, 1, &resolveInfo); } void GrVkGpu::internalResolveRenderTarget(GrRenderTarget* target, bool requiresSubmit) { @@ -430,7 +440,7 @@ void GrVkGpu::internalResolveRenderTarget(GrRenderTarget* target, bool requiresS const SkIRect& srcRect = rt->getResolveRect(); - this->resolveImage(rt, rt, srcRect, SkIPoint::Make(srcRect.fLeft, srcRect.fTop)); + this->resolveImage(target, rt, srcRect, SkIPoint::Make(srcRect.fLeft, srcRect.fTop)); rt->flagAsResolved(); @@ -1550,8 +1560,8 @@ inline bool can_copy_as_resolve(const GrSurface* dst, return false; } - // The dst must be a render target but not multisampled - if (!dst->asRenderTarget() || dst->asRenderTarget()->numColorSamples() > 1) { + // The dst must not be a multisampled render target + if (dst->asRenderTarget() && dst->asRenderTarget()->numColorSamples() > 1) { return false; } @@ -1567,10 +1577,8 @@ void GrVkGpu::copySurfaceAsResolve(GrSurface* dst, GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { - GrVkRenderTarget* dstRT = static_cast(dst->asRenderTarget()); GrVkRenderTarget* srcRT = static_cast(src->asRenderTarget()); - SkASSERT(dstRT && dstRT->numColorSamples() <= 1); - this->resolveImage(dstRT, srcRT, srcRect, dstPoint); + this->resolveImage(dst, srcRT, srcRect, dstPoint); } bool GrVkGpu::onCopySurface(GrSurface* dst, diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index db77443..914a2ba 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -243,7 +243,7 @@ private: GrPixelConfig dataConfig, const SkTArray&); - void resolveImage(GrVkRenderTarget* dst, + void resolveImage(GrSurface* dst, GrVkRenderTarget* src, const SkIRect& srcRect, const SkIPoint& dstPoint);