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

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

Issue 1974983002: Refactor Vulkan image, texture, RTs so that create and getter handles match. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixLayerVersion
Patch Set: nits Created 4 years, 7 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/GrVkStencilAttachment.h ('k') | src/gpu/vk/GrVkTexture.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 "GrVkStencilAttachment.h" 8 #include "GrVkStencilAttachment.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 #include "GrVkImage.h" 10 #include "GrVkImage.h"
11 #include "GrVkImageView.h" 11 #include "GrVkImageView.h"
12 #include "GrVkUtil.h" 12 #include "GrVkUtil.h"
13 13
14 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 14 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
15 15
16 GrVkStencilAttachment::GrVkStencilAttachment(GrVkGpu* gpu, 16 GrVkStencilAttachment::GrVkStencilAttachment(GrVkGpu* gpu,
17 const Format& format, 17 const Format& format,
18 const GrVkImage::ImageDesc& desc, 18 const GrVkImage::ImageDesc& desc,
19 const GrVkImage::Resource* imageRes ource, 19 const GrVkImageInfo& info,
20 const GrVkImageView* stencilView) 20 const GrVkImageView* stencilView)
21 : GrStencilAttachment(gpu, desc.fWidth, desc.fHeight, 21 : GrStencilAttachment(gpu, desc.fWidth, desc.fHeight,
22 format.fStencilBits, desc.fSamples) 22 format.fStencilBits, desc.fSamples)
23 , GrVkImage(imageResource) 23 , GrVkImage(info, GrVkImage::kNot_Wrapped)
24 , fFormat(format) 24 , fFormat(format)
25 , fStencilView(stencilView) { 25 , fStencilView(stencilView) {
26 this->registerWithCache(SkBudgeted::kYes); 26 this->registerWithCache(SkBudgeted::kYes);
27 stencilView->ref(); 27 stencilView->ref();
28 } 28 }
29 29
30 GrVkStencilAttachment* GrVkStencilAttachment::Create(GrVkGpu* gpu, 30 GrVkStencilAttachment* GrVkStencilAttachment::Create(GrVkGpu* gpu,
31 int width, 31 int width,
32 int height, 32 int height,
33 int sampleCnt, 33 int sampleCnt,
34 const Format& format) { 34 const Format& format) {
35 GrVkImage::ImageDesc imageDesc; 35 GrVkImage::ImageDesc imageDesc;
36 imageDesc.fImageType = VK_IMAGE_TYPE_2D; 36 imageDesc.fImageType = VK_IMAGE_TYPE_2D;
37 imageDesc.fFormat = format.fInternalFormat; 37 imageDesc.fFormat = format.fInternalFormat;
38 imageDesc.fWidth = width; 38 imageDesc.fWidth = width;
39 imageDesc.fHeight = height; 39 imageDesc.fHeight = height;
40 imageDesc.fLevels = 1; 40 imageDesc.fLevels = 1;
41 imageDesc.fSamples = sampleCnt; 41 imageDesc.fSamples = sampleCnt;
42 imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL; 42 imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
43 imageDesc.fUsageFlags = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | 43 imageDesc.fUsageFlags = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
44 VK_IMAGE_USAGE_TRANSFER_DST_BIT; 44 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
45 imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; 45 imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
46 46
47 const GrVkImage::Resource* imageResource = GrVkImage::CreateResource(gpu, im ageDesc); 47 GrVkImageInfo info;
48 if (!imageResource) { 48 if (!GrVkImage::InitImageInfo(gpu, imageDesc, &info)) {
49 return nullptr; 49 return nullptr;
50 } 50 }
51 51
52 const GrVkImageView* imageView = GrVkImageView::Create(gpu, imageResource->f Image, 52 const GrVkImageView* imageView = GrVkImageView::Create(gpu, info.fImage,
53 format.fInternalForma t, 53 format.fInternalForma t,
54 GrVkImageView::kStenc il_Type, 1); 54 GrVkImageView::kStenc il_Type, 1);
55 if (!imageView) { 55 if (!imageView) {
56 imageResource->unref(gpu); 56 VK_CALL(gpu, DestroyImage(gpu->device(), info.fImage, nullptr));
57 VK_CALL(gpu, FreeMemory(gpu->device(), info.fAlloc, nullptr));
57 return nullptr; 58 return nullptr;
58 } 59 }
59 60
60 GrVkStencilAttachment* stencil = new GrVkStencilAttachment(gpu, format, imag eDesc, 61 GrVkStencilAttachment* stencil = new GrVkStencilAttachment(gpu, format, imag eDesc,
61 imageResource, im ageView); 62 info, imageView);
62 imageResource->unref(gpu);
63 imageView->unref(gpu); 63 imageView->unref(gpu);
64 64
65 return stencil; 65 return stencil;
66 } 66 }
67 67
68 GrVkStencilAttachment::~GrVkStencilAttachment() { 68 GrVkStencilAttachment::~GrVkStencilAttachment() {
69 // should have been released or abandoned first 69 // should have been released or abandoned first
70 SkASSERT(!fStencilView); 70 SkASSERT(!fStencilView);
71 } 71 }
72 72
(...skipping 19 matching lines...) Expand all
92 this->abandonImage(); 92 this->abandonImage();
93 fStencilView->unrefAndAbandon(); 93 fStencilView->unrefAndAbandon();
94 fStencilView = nullptr; 94 fStencilView = nullptr;
95 GrStencilAttachment::onAbandon(); 95 GrStencilAttachment::onAbandon();
96 } 96 }
97 97
98 GrVkGpu* GrVkStencilAttachment::getVkGpu() const { 98 GrVkGpu* GrVkStencilAttachment::getVkGpu() const {
99 SkASSERT(!this->wasDestroyed()); 99 SkASSERT(!this->wasDestroyed());
100 return static_cast<GrVkGpu*>(this->getGpu()); 100 return static_cast<GrVkGpu*>(this->getGpu());
101 } 101 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkStencilAttachment.h ('k') | src/gpu/vk/GrVkTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698