Disable use of directly wrapping msaa RTs on Vulkan Currently the Vulkan backend is set up to always treat the "resolve" target as the main VkImage in a render target and the msaa is a side cart image. This makes it difficult to just wrap an msaa image that we don't own. However, unlike GL the equivalent FBO 0 will never be multisampled so there isn't much use for the functionality. Once we find a need for it we can find a way to refactor to make it work. Bug: skia: Change-Id: I121e9c72a70c2a6f1aaddba2dbae19d8bddc3998 Reviewed-on: https://skia-review.googlesource.com/13980 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 12d9876..3d30e35 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp
@@ -822,6 +822,13 @@ } sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDesc& wrapDesc){ + // Currently the Vulkan backend does not support wrapping of msaa render targets directly. In + // general this is not an issue since swapchain images in vulkan are never multisampled. Thus if + // you want a multisampled RT it is best to wrap the swapchain images and then let Skia handle + // creating and owning the MSAA images. + if (wrapDesc.fSampleCnt) { + return nullptr; + } const GrVkImageInfo* info = reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fRenderTargetHandle); @@ -834,7 +841,7 @@ desc.fFlags = kCheckAllocation_GrSurfaceFlag | kRenderTarget_GrSurfaceFlag; desc.fWidth = wrapDesc.fWidth; desc.fHeight = wrapDesc.fHeight; - desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()); + desc.fSampleCnt = 0; desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp index 0749978..831c7ae 100644 --- a/tools/viewer/sk_app/VulkanWindowContext.cpp +++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -6,6 +6,7 @@ * found in the LICENSE file. */ +#include "GrBackendSurface.h" #include "GrContext.h" #include "GrRenderTarget.h" #include "SkAutoMalloc.h" @@ -264,7 +265,6 @@ for (uint32_t i = 0; i < fImageCount; ++i) { fImageLayouts[i] = VK_IMAGE_LAYOUT_UNDEFINED; - GrBackendRenderTargetDesc desc; GrVkImageInfo info; info.fImage = fImages[i]; info.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; @@ -272,17 +272,14 @@ info.fImageTiling = VK_IMAGE_TILING_OPTIMAL; info.fFormat = format; info.fLevelCount = 1; - desc.fWidth = fWidth; - desc.fHeight = fHeight; - desc.fConfig = fPixelConfig; - desc.fOrigin = kTopLeft_GrSurfaceOrigin; - desc.fSampleCnt = fSampleCount; - desc.fStencilBits = fStencilBits; - desc.fRenderTargetHandle = (GrBackendObject) &info; - fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(fContext, desc, - fDisplayParams.fColorSpace, - &fSurfaceProps); + GrBackendTexture backendTex(fWidth, fHeight, &info); + + fSurfaces[i] = SkSurface::MakeFromBackendTextureAsRenderTarget(fContext, backendTex, + kTopLeft_GrSurfaceOrigin, + fSampleCount, + fDisplayParams.fColorSpace, + &fSurfaceProps); } // create the command pool for the command buffers