Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Unified Diff: src/gpu/vk/GrVkRenderTarget.cpp

Issue 1808263002: Implement Vulkan GrBackendObject for textures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Tweaks Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkRenderTarget.h ('k') | src/gpu/vk/GrVkTexture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkRenderTarget.cpp
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index ee45aa30e87cf44fe4a918cca779f83ef3c94de8..7ff7f26d42e929afd1911c3dd96a17b739f08ef0 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() {
« no previous file with comments | « src/gpu/vk/GrVkRenderTarget.h ('k') | src/gpu/vk/GrVkTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698