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

Side by Side 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: 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 "GrVkRenderTarget.h" 8 #include "GrVkRenderTarget.h"
9 9
10 #include "GrRenderTargetPriv.h" 10 #include "GrRenderTargetPriv.h"
11 #include "GrVkCommandBuffer.h" 11 #include "GrVkCommandBuffer.h"
12 #include "GrVkFramebuffer.h" 12 #include "GrVkFramebuffer.h"
13 #include "GrVkGpu.h" 13 #include "GrVkGpu.h"
14 #include "GrVkImageView.h" 14 #include "GrVkImageView.h"
15 #include "GrVkResourceProvider.h" 15 #include "GrVkResourceProvider.h"
16 #include "GrVkUtil.h" 16 #include "GrVkUtil.h"
17 17
18 #include "vk/GrVkTypes.h"
19
18 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 20 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
19 21
20 // We're virtually derived from GrSurface (via GrRenderTarget) so its 22 // We're virtually derived from GrSurface (via GrRenderTarget) so its
21 // constructor must be explicitly called. 23 // constructor must be explicitly called.
22 GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu, 24 GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
23 const GrSurfaceDesc& desc, 25 const GrSurfaceDesc& desc,
24 GrGpuResource::LifeCycle lifeCycle, 26 GrGpuResource::LifeCycle lifeCycle,
25 const GrVkImage::Resource* imageResource, 27 const GrVkImage::Resource* imageResource,
26 const GrVkImage::Resource* msaaResource, 28 const GrVkImage::Resource* msaaResource,
27 const GrVkImageView* colorAttachmentView, 29 const GrVkImageView* colorAttachmentView,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageR esource); 198 GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageR esource);
197 // Create() will increment the refCount of the image resource if it succeeds 199 // Create() will increment the refCount of the image resource if it succeeds
198 imageResource->unref(gpu); 200 imageResource->unref(gpu);
199 return rt; 201 return rt;
200 } 202 }
201 203
202 GrVkRenderTarget* 204 GrVkRenderTarget*
203 GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu, 205 GrVkRenderTarget::CreateWrappedRenderTarget(GrVkGpu* gpu,
204 const GrSurfaceDesc& desc, 206 const GrSurfaceDesc& desc,
205 GrGpuResource::LifeCycle lifeCycle, 207 GrGpuResource::LifeCycle lifeCycle,
206 const GrVkImage::Resource* imageReso urce) { 208 const GrVkTextureInfo* info) {
207 SkASSERT(imageResource); 209 // We can wrap a rendertarget without its allocation, as long as we don't ta ke ownership
210 SkASSERT(info->fAlloc || kAdopted_LifeCycle != lifeCycle);
bsalomon 2016/03/17 17:19:03 Seems ok to assert here but should the onWrap**()
jvanverth1 2016/03/18 14:30:00 Done.
208 211
209 // Note: we assume the caller will unref the imageResource 212 GrVkImage::Resource::Flags flags = (VK_IMAGE_TILING_LINEAR == info->fImageTi ling)
210 // Create() will increment the refCount, and we'll unref when we're done wit h it 213 ? Resource::kLinearTiling_Flag : Resource:: kNo_Flags;
211 return GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageResource); 214
215 const GrVkImage::Resource* imageResource = new GrVkImage::Resource(info->fIm age,
216 info->fAl loc,
217 flags);
218 if (!imageResource) {
219 return nullptr;
220 }
221
222 GrVkRenderTarget* rt = GrVkRenderTarget::Create(gpu, desc, lifeCycle, imageR esource);
223 // Create() will increment the refCount of the image resource if it succeeds
224 imageResource->unref(gpu);
225 return rt;
212 } 226 }
213 227
214 bool GrVkRenderTarget::completeStencilAttachment() { 228 bool GrVkRenderTarget::completeStencilAttachment() {
215 this->createFramebuffer(this->getVkGpu()); 229 this->createFramebuffer(this->getVkGpu());
216 return true; 230 return true;
217 } 231 }
218 232
219 void GrVkRenderTarget::createFramebuffer(GrVkGpu* gpu) { 233 void GrVkRenderTarget::createFramebuffer(GrVkGpu* gpu) {
220 if (fFramebuffer) { 234 if (fFramebuffer) {
221 fFramebuffer->unref(gpu); 235 fFramebuffer->unref(gpu);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 395
382 return nullptr; 396 return nullptr;
383 } 397 }
384 398
385 399
386 GrVkGpu* GrVkRenderTarget::getVkGpu() const { 400 GrVkGpu* GrVkRenderTarget::getVkGpu() const {
387 SkASSERT(!this->wasDestroyed()); 401 SkASSERT(!this->wasDestroyed());
388 return static_cast<GrVkGpu*>(this->getGpu()); 402 return static_cast<GrVkGpu*>(this->getGpu());
389 } 403 }
390 404
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698