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

Side by Side Diff: src/gpu/vk/GrVkTexture.cpp

Issue 1808263002: Implement Vulkan GrBackendObject for textures. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add GrVkTypes 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrVkTexture.h" 8 #include "GrVkTexture.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 #include "GrVkImageView.h" 10 #include "GrVkImageView.h"
11 #include "GrVkUtil.h" 11 #include "GrVkUtil.h"
12 12
13 #include "vk/GrVkTypes.h"
14
13 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 15 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
14 16
15 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor. 17 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor.
16 GrVkTexture::GrVkTexture(GrVkGpu* gpu, 18 GrVkTexture::GrVkTexture(GrVkGpu* gpu,
17 const GrSurfaceDesc& desc, 19 const GrSurfaceDesc& desc,
18 GrGpuResource::LifeCycle lifeCycle, 20 GrGpuResource::LifeCycle lifeCycle,
19 const GrVkImage::Resource* imageResource, 21 const GrVkImage::Resource* imageResource,
20 const GrVkImageView* view) 22 const GrVkImageView* view)
21 : GrSurface(gpu, lifeCycle, desc) 23 : GrSurface(gpu, lifeCycle, desc)
22 , GrVkImage(imageResource) 24 , GrVkImage(imageResource)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 GrVkTexture* texture = Create(gpu, desc, lifeCycle, imageDesc.fFormat, image Resource); 70 GrVkTexture* texture = Create(gpu, desc, lifeCycle, imageDesc.fFormat, image Resource);
69 // Create() will increment the refCount of the image resource if it succeeds 71 // Create() will increment the refCount of the image resource if it succeeds
70 imageResource->unref(gpu); 72 imageResource->unref(gpu);
71 73
72 return texture; 74 return texture;
73 } 75 }
74 76
75 GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu, const GrSurfaceDesc & desc, 77 GrVkTexture* GrVkTexture::CreateWrappedTexture(GrVkGpu* gpu, const GrSurfaceDesc & desc,
76 GrGpuResource::LifeCycle lifeCycl e, 78 GrGpuResource::LifeCycle lifeCycl e,
77 VkFormat format, 79 VkFormat format,
78 const GrVkImage::Resource* imageR esource) { 80 const GrVkTextureInfo* info) {
79 SkASSERT(imageResource); 81 // Wrapped textures require both image and allocation
82 SkASSERT(info->fImage && info->fAlloc);
80 83
81 // Note: we assume the caller will unref the imageResource 84 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi ling)
82 // Create() will increment the refCount, and we'll unref when we're done wit h it 85 ? Resource::kLinearTiling_Flag : Resource:: kNo_Flags;
83 return Create(gpu, desc, lifeCycle, format, imageResource); 86
87 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm age,
88 info->fAl loc,
89 flags);
90 if (!imageResource) {
91 return nullptr;
92 }
93
94 GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource);
95 // Create() will increment the refCount of the image resource if it succeeds
96 imageResource->unref(gpu);
97
98 return texture;
84 } 99 }
85 100
86 GrVkTexture::~GrVkTexture() { 101 GrVkTexture::~GrVkTexture() {
87 // either release or abandon should have been called by the owner of this ob ject. 102 // either release or abandon should have been called by the owner of this ob ject.
88 SkASSERT(!fTextureView); 103 SkASSERT(!fTextureView);
89 } 104 }
90 105
91 void GrVkTexture::onRelease() { 106 void GrVkTexture::onRelease() {
92 // we create this and don't hand it off, so we should always destroy it 107 // we create this and don't hand it off, so we should always destroy it
93 if (fTextureView) { 108 if (fTextureView) {
(...skipping 23 matching lines...) Expand all
117 GrBackendObject GrVkTexture::getTextureHandle() const { 132 GrBackendObject GrVkTexture::getTextureHandle() const {
118 // Currently just passing back the pointer to the Resource as the handle 133 // Currently just passing back the pointer to the Resource as the handle
119 return (GrBackendObject)&fResource; 134 return (GrBackendObject)&fResource;
120 } 135 }
121 136
122 GrVkGpu* GrVkTexture::getVkGpu() const { 137 GrVkGpu* GrVkTexture::getVkGpu() const {
123 SkASSERT(!this->wasDestroyed()); 138 SkASSERT(!this->wasDestroyed());
124 return static_cast<GrVkGpu*>(this->getGpu()); 139 return static_cast<GrVkGpu*>(this->getGpu());
125 } 140 }
126 141
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698