aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkGpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/vk/GrVkGpu.cpp')
-rw-r--r--src/gpu/vk/GrVkGpu.cpp67
1 files changed, 44 insertions, 23 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index cf7a39bb9d..c9f590397a 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -295,27 +295,28 @@ bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
if (dstSurface->config() == srcConfig) {
+ // We only support writing pixels to textures. Forcing a draw lets us write to pure RTs.
+ if (!dstSurface->asTexture()) {
+ ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
+ }
+ // If the dst is MSAA, we have to draw, or we'll just be writing to the resolve target.
+ if (renderTarget && renderTarget->numColorSamples() > 1) {
+ ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
+ }
return true;
}
- if (renderTarget && this->vkCaps().isConfigRenderable(renderTarget->config(),
- renderTarget->numColorSamples() > 1)) {
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
+ // Any config change requires a draw
+ ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- bool configsAreRBSwaps = GrPixelConfigSwapRAndB(srcConfig) == dstSurface->config();
+ bool configsAreRBSwaps = GrPixelConfigSwapRAndB(srcConfig) == dstSurface->config();
- if (!this->vkCaps().isConfigTexturable(srcConfig) && configsAreRBSwaps) {
- if (!this->vkCaps().isConfigTexturable(dstSurface->config())) {
- return false;
- }
- tempDrawInfo->fTempSurfaceDesc.fConfig = dstSurface->config();
- tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
- tempDrawInfo->fWriteConfig = dstSurface->config();
- }
- return true;
+ if (!this->vkCaps().isConfigTexturable(srcConfig) && configsAreRBSwaps) {
+ tempDrawInfo->fTempSurfaceDesc.fConfig = dstSurface->config();
+ tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
+ tempDrawInfo->fWriteConfig = dstSurface->config();
}
-
- return false;
+ return true;
}
bool GrVkGpu::onWritePixels(GrSurface* surface,
@@ -848,6 +849,28 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
return tgt;
}
+sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendTextureAsRenderTarget(
+ const GrBackendTextureDesc& wrapDesc){
+
+ const GrVkImageInfo* info =
+ reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fTextureHandle);
+ if (VK_NULL_HANDLE == info->fImage) {
+ return nullptr;
+ }
+
+ GrSurfaceDesc desc;
+ desc.fFlags = (GrSurfaceFlags) wrapDesc.fFlags;
+ desc.fConfig = wrapDesc.fConfig;
+ desc.fWidth = wrapDesc.fWidth;
+ desc.fHeight = wrapDesc.fHeight;
+ desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount());
+
+ desc.fOrigin = resolve_origin(wrapDesc.fOrigin);
+
+ sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
+ return tgt;
+}
+
void GrVkGpu::generateMipmap(GrVkTexture* tex) {
// don't do anything for linearly tiled textures (can't have mipmaps)
if (tex->isLinearTiled()) {
@@ -1653,7 +1676,7 @@ bool GrVkGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height,
// Depends on why we need/want a temp draw. Start off assuming no change, the surface we read
// from will be srcConfig and we will read readConfig pixels from it.
- // Not that if we require a draw and return a non-renderable format for the temp surface the
+ // Note that if we require a draw and return a non-renderable format for the temp surface the
// base class will fail for us.
tempDrawInfo->fTempSurfaceDesc.fConfig = srcSurface->config();
tempDrawInfo->fReadConfig = readConfig;
@@ -1662,14 +1685,12 @@ bool GrVkGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height,
return true;
}
- if (this->vkCaps().isConfigRenderable(readConfig, srcSurface->desc().fSampleCnt > 1)) {
- ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
- tempDrawInfo->fTempSurfaceDesc.fConfig = readConfig;
- tempDrawInfo->fReadConfig = readConfig;
- return true;
- }
+ // Any config change requires a draw
+ ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
+ tempDrawInfo->fTempSurfaceDesc.fConfig = readConfig;
+ tempDrawInfo->fReadConfig = readConfig;
- return false;
+ return true;
}
bool GrVkGpu::onReadPixels(GrSurface* surface,