aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkRenderTarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/vk/GrVkRenderTarget.cpp')
-rw-r--r--src/gpu/vk/GrVkRenderTarget.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index ee45aa30e8..7ff7f26d42 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -15,6 +15,8 @@
#include "GrVkResourceProvider.h"
#include "GrVkUtil.h"
+#include "vk/GrVkTypes.h"
+
#define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
// We're virtually derived from GrSurface (via GrRenderTarget) so its
@@ -203,12 +205,29 @@ GrVkRenderTarget*
GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu,
const GrSurfaceDesc& desc,
GrGpuResource::LifeCycle lifeCycle,
- const GrVkImage::Resource* imageResource) {
- SkASSERT(imageResource);
+ const GrVkTextureInfo* info) {
+ SkASSERT(info);
+ // We can wrap a rendertarget without its allocation, as long as we don't take ownership
+ SkASSERT(VK_NULL_HANDLE != info->fImage);
+ SkASSERT(VK_NULL_HANDLE != info->fAlloc || kAdopted_LifeCycle != lifeCycle);
+
+ GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTiling)
+ ? Resource::kLinearTiling_Flag : Resource::kNo_Flags;
+
+ const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fImage,
+ info->fAlloc,
+ flags);
+ if (!imageResource) {
+ return nullptr;
+ }
- // Note: we assume the caller will unref the imageResource
- // Create() will increment the refCount, and we'll unref when we're done with it
- return GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageResource);
+ GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageResource);
+ if (rt) {
+ rt->fCurrentLayout = info->fImageLayout;
+ }
+ // Create() will increment the refCount of the image resource if it succeeds
+ imageResource->unref(gpu);
+ return rt;
}
bool GrVkRenderTarget::completeStencilAttachment() {