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

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: 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 unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkTexture.h ('k') | src/gpu/vk/GrVkTextureRenderTarget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SkASSERT(info);
82 // Wrapped textures require both image and allocation (because they can be m apped)
83 SkASSERT(VK_NULL_HANDLE != info->fImage && VK_NULL_HANDLE != info->fAlloc);
80 84
81 // Note: we assume the caller will unref the imageResource 85 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 86 ? Resource::kLinearTiling_Flag : Resource:: kNo_Flags;
83 return Create(gpu, desc, lifeCycle, format, imageResource); 87
88 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm age,
89 info->fAl loc,
90 flags);
91 if (!imageResource) {
92 return nullptr;
93 }
94
95 GrVkTexture* texture = Create(gpu, desc, lifeCycle, format, imageResource);
96 if (texture) {
97 texture->fCurrentLayout = info->fImageLayout;
98 }
99 // Create() will increment the refCount of the image resource if it succeeds
100 imageResource->unref(gpu);
101
102 return texture;
84 } 103 }
85 104
86 GrVkTexture::~GrVkTexture() { 105 GrVkTexture::~GrVkTexture() {
87 // either release or abandon should have been called by the owner of this ob ject. 106 // either release or abandon should have been called by the owner of this ob ject.
88 SkASSERT(!fTextureView); 107 SkASSERT(!fTextureView);
89 } 108 }
90 109
91 void GrVkTexture::onRelease() { 110 void GrVkTexture::onRelease() {
92 // we create this and don't hand it off, so we should always destroy it 111 // we create this and don't hand it off, so we should always destroy it
93 if (fTextureView) { 112 if (fTextureView) {
(...skipping 23 matching lines...) Expand all
117 GrBackendObject GrVkTexture::getTextureHandle() const { 136 GrBackendObject GrVkTexture::getTextureHandle() const {
118 // Currently just passing back the pointer to the Resource as the handle 137 // Currently just passing back the pointer to the Resource as the handle
119 return (GrBackendObject)&fResource; 138 return (GrBackendObject)&fResource;
120 } 139 }
121 140
122 GrVkGpu* GrVkTexture::getVkGpu() const { 141 GrVkGpu* GrVkTexture::getVkGpu() const {
123 SkASSERT(!this->wasDestroyed()); 142 SkASSERT(!this->wasDestroyed());
124 return static_cast<GrVkGpu*>(this->getGpu()); 143 return static_cast<GrVkGpu*>(this->getGpu());
125 } 144 }
126 145
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkTexture.h ('k') | src/gpu/vk/GrVkTextureRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698