Chromium Code Reviews| Index: src/gpu/vk/GrVkGpu.cpp |
| diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp |
| index 85bfce87679c696ba720e6ff84f6747a5207b6d2..5f1395f51bd7dc71d0e973fe72ffa52b4769368a 100644 |
| --- a/src/gpu/vk/GrVkGpu.cpp |
| +++ b/src/gpu/vk/GrVkGpu.cpp |
| @@ -284,7 +284,8 @@ bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| return true; |
| } |
| - if (renderTarget && this->vkCaps().isConfigRenderable(renderTarget->config(), false)) { |
| + if (renderTarget && this->vkCaps().isConfigRenderable(renderTarget->config(), |
| + renderTarget->numColorSamples() > 1)) { |
| ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); |
| bool configsAreRBSwaps = GrPixelConfigSwapRAndB(srcConfig) == dstSurface->config(); |
| @@ -366,7 +367,8 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, |
| } |
| void GrVkGpu::onResolveRenderTarget(GrRenderTarget* target) { |
| - if (target->needsResolve() && target->numColorSamples() > 1) { |
| + if (target->needsResolve()) { |
| + SkASSERT(target->numColorSamples() > 1); |
|
egdaniel
2016/08/05 19:07:15
going back to this. Returning getResolveType as au
|
| GrVkRenderTarget* rt = static_cast<GrVkRenderTarget*>(target); |
| SkASSERT(rt->msaaImage()); |
| @@ -817,12 +819,6 @@ void GrVkGpu::generateMipmap(GrVkTexture* tex) { |
| return; |
| } |
| - // We currently don't support generating mipmaps for images that are multisampled. |
| - // TODO: Add support for mipmapping the resolve target of a multisampled image |
| - if (tex->asRenderTarget() && tex->asRenderTarget()->numColorSamples() > 1) { |
| - return; |
| - } |
| - |
| // determine if we can blit to and from this format |
| const GrVkCaps& caps = this->vkCaps(); |
| if (!caps.configCanBeDstofBlit(tex->config(), false) || |
| @@ -831,6 +827,12 @@ void GrVkGpu::generateMipmap(GrVkTexture* tex) { |
| return; |
| } |
| + // We may need to resolve the texture first if it is also a render target |
| + GrVkRenderTarget* texRT = static_cast<GrVkRenderTarget*>(tex->asRenderTarget()); |
| + if (texRT) { |
| + this->onResolveRenderTarget(texRT); |
| + } |
| + |
| int width = tex->width(); |
| int height = tex->height(); |
| VkImageBlit blitRegion; |
| @@ -1262,7 +1264,7 @@ inline bool can_copy_as_blit(const GrSurface* dst, |
| const GrVkImage* dstImage, |
| const GrVkImage* srcImage, |
| const GrVkGpu* gpu) { |
| - // We require that all vulkan GrSurfaces have been created with transfer_dst and transfer_src |
| + // We require that all vulkan GrSurfaces have been created with transfer_dst and transfer_src |
| // as image usage flags. |
| const GrVkCaps& caps = gpu->vkCaps(); |
| if (!caps.configCanBeDstofBlit(dst->config(), dstImage->isLinearTiled()) || |
| @@ -1444,7 +1446,7 @@ bool GrVkGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height, |
| return true; |
| } |
| - if (this->vkCaps().isConfigRenderable(readConfig, false)) { |
| + if (this->vkCaps().isConfigRenderable(readConfig, srcSurface->desc().fSampleCnt > 1)) { |
| ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); |
| tempDrawInfo->fTempSurfaceDesc.fConfig = readConfig; |
| tempDrawInfo->fReadConfig = readConfig; |
| @@ -1464,17 +1466,36 @@ bool GrVkGpu::onReadPixels(GrSurface* surface, |
| return false; |
| } |
| - GrVkTexture* tgt = static_cast<GrVkTexture*>(surface->asTexture()); |
| - if (!tgt) { |
| + GrVkImage* image = nullptr; |
| + GrVkRenderTarget* rt = static_cast<GrVkRenderTarget*>(surface->asRenderTarget()); |
|
Brian Osman
2016/08/18 13:28:22
This is the only place where you're doing the extr
egdaniel
2016/08/18 13:31:39
Yeah I can move it up there. I was actually just c
egdaniel
2016/08/18 13:36:23
Actually I see the reasoning now. onResolveRenderT
|
| + if (rt) { |
| + // resolve the render target if necessary |
| + switch (rt->getResolveType()) { |
| + case GrVkRenderTarget::kCantResolve_ResolveType: |
| + return false; |
| + case GrVkRenderTarget::kAutoResolves_ResolveType: |
| + break; |
| + case GrVkRenderTarget::kCanResolve_ResolveType: |
| + this->onResolveRenderTarget(rt); |
| + break; |
| + default: |
| + SkFAIL("Unknown resolve type"); |
| + } |
| + image = rt; |
| + } else { |
| + image = static_cast<GrVkTexture*>(surface->asTexture()); |
| + } |
| + |
| + if (!image) { |
| return false; |
| } |
| // Change layout of our target so it can be used as copy |
| - tgt->setImageLayout(this, |
| - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| - VK_ACCESS_TRANSFER_READ_BIT, |
| - VK_PIPELINE_STAGE_TRANSFER_BIT, |
| - false); |
| + image->setImageLayout(this, |
| + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| + VK_ACCESS_TRANSFER_READ_BIT, |
| + VK_PIPELINE_STAGE_TRANSFER_BIT, |
| + false); |
| GrVkTransferBuffer* transferBuffer = |
| static_cast<GrVkTransferBuffer*>(this->createBuffer(rowBytes * height, |
| @@ -1499,7 +1520,7 @@ bool GrVkGpu::onReadPixels(GrSurface* surface, |
| region.imageExtent = { (uint32_t)width, (uint32_t)height, 1 }; |
| fCurrentCmdBuffer->copyImageToBuffer(this, |
| - tgt, |
| + image, |
| VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| transferBuffer, |
| 1, |
| @@ -1607,5 +1628,7 @@ void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer, |
| fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, *pBounds, true); |
| fCurrentCmdBuffer->executeCommands(this, buffer); |
| fCurrentCmdBuffer->endRenderPass(this); |
| + |
| + this->didWriteToSurface(target, pBounds); |
| } |