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

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

Issue 1916563002: Add automatic generation of mipmaps to Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 4 years, 8 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.cpp ('k') | no next file » | 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 "GrVkTextureRenderTarget.h" 8 #include "GrVkTextureRenderTarget.h"
9 9
10 #include "GrRenderTargetPriv.h" 10 #include "GrRenderTargetPriv.h"
11 #include "GrVkGpu.h" 11 #include "GrVkGpu.h"
12 #include "GrVkImageView.h" 12 #include "GrVkImageView.h"
13 #include "GrVkUtil.h" 13 #include "GrVkUtil.h"
14 14
15 #include "SkMipmap.h"
16
15 #include "vk/GrVkTypes.h" 17 #include "vk/GrVkTypes.h"
16 18
17 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 19 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
18 20
19 template<typename ResourceType> 21 template<typename ResourceType>
20 GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu, 22 GrVkTextureRenderTarget* GrVkTextureRenderTarget::Create(GrVkGpu* gpu,
21 ResourceType resourceTy pe, 23 ResourceType resourceTy pe,
22 const GrSurfaceDesc& de sc, 24 const GrSurfaceDesc& de sc,
23 VkFormat format, 25 VkFormat format,
24 const GrVkImage::Resour ce* imageResource) { 26 const GrVkImage::Resour ce* imageResource) {
25 VkImage image = imageResource->fImage; 27 VkImage image = imageResource->fImage;
26 // Create the texture ImageView 28 // Create the texture ImageView
29 uint32_t mipLevels = 1;
30 //TODO: does a mipmapped textureRenderTarget make sense?
31 //if (desc.fIsMipMapped) {
32 // mipLevels = SkMipMap::ComputeLevelCount(this->width(), this->height()) ;
33 //}
27 const GrVkImageView* imageView = GrVkImageView::Create(gpu, image, format, 34 const GrVkImageView* imageView = GrVkImageView::Create(gpu, image, format,
28 GrVkImageView::kColor _Type); 35 GrVkImageView::kColor _Type, mipLevels);
29 if (!imageView) { 36 if (!imageView) {
30 return nullptr; 37 return nullptr;
31 } 38 }
32 39
33 VkFormat pixelFormat; 40 VkFormat pixelFormat;
34 GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat); 41 GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat);
35 42
36 VkImage colorImage; 43 VkImage colorImage;
37 44
38 // create msaa surface if necessary 45 // create msaa surface if necessary
(...skipping 21 matching lines...) Expand all
60 // Set color attachment image 67 // Set color attachment image
61 colorImage = msaaImageResource->fImage; 68 colorImage = msaaImageResource->fImage;
62 69
63 // Create resolve attachment view if necessary. 70 // Create resolve attachment view if necessary.
64 // If the format matches, this is the same as the texture imageView. 71 // If the format matches, this is the same as the texture imageView.
65 if (pixelFormat == format) { 72 if (pixelFormat == format) {
66 resolveAttachmentView = imageView; 73 resolveAttachmentView = imageView;
67 resolveAttachmentView->ref(); 74 resolveAttachmentView->ref();
68 } else { 75 } else {
69 resolveAttachmentView = GrVkImageView::Create(gpu, image, pixelForma t, 76 resolveAttachmentView = GrVkImageView::Create(gpu, image, pixelForma t,
70 GrVkImageView::kColor_ Type); 77 GrVkImageView::kColor_ Type, 1);
71 if (!resolveAttachmentView) { 78 if (!resolveAttachmentView) {
72 msaaImageResource->unref(gpu); 79 msaaImageResource->unref(gpu);
73 imageView->unref(gpu); 80 imageView->unref(gpu);
74 return nullptr; 81 return nullptr;
75 } 82 }
76 } 83 }
77 } else { 84 } else {
78 // Set color attachment image 85 // Set color attachment image
79 colorImage = imageResource->fImage; 86 colorImage = imageResource->fImage;
80 } 87 }
81 88
82 const GrVkImageView* colorAttachmentView; 89 const GrVkImageView* colorAttachmentView;
83 // Get color attachment view. 90 // Get color attachment view.
84 // If the format matches and there's no multisampling, 91 // If the format matches and there's no multisampling,
85 // this is the same as the texture imageView 92 // this is the same as the texture imageView
86 if (pixelFormat == format && !resolveAttachmentView) { 93 if (pixelFormat == format && !resolveAttachmentView) {
87 colorAttachmentView = imageView; 94 colorAttachmentView = imageView;
88 colorAttachmentView->ref(); 95 colorAttachmentView->ref();
89 } else { 96 } else {
90 colorAttachmentView = GrVkImageView::Create(gpu, colorImage, pixelFormat , 97 colorAttachmentView = GrVkImageView::Create(gpu, colorImage, pixelFormat ,
91 GrVkImageView::kColor_Type); 98 GrVkImageView::kColor_Type, 1);
92 if (!colorAttachmentView) { 99 if (!colorAttachmentView) {
93 if (msaaImageResource) { 100 if (msaaImageResource) {
94 resolveAttachmentView->unref(gpu); 101 resolveAttachmentView->unref(gpu);
95 msaaImageResource->unref(gpu); 102 msaaImageResource->unref(gpu);
96 } 103 }
97 imageView->unref(gpu); 104 imageView->unref(gpu);
98 return nullptr; 105 return nullptr;
99 } 106 }
100 } 107 }
101 GrVkTextureRenderTarget* texRT; 108 GrVkTextureRenderTarget* texRT;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 169 }
163 GrVkTextureRenderTarget* trt = Create(gpu, kWrapped, desc, format, imageReso urce); 170 GrVkTextureRenderTarget* trt = Create(gpu, kWrapped, desc, format, imageReso urce);
164 if (trt) { 171 if (trt) {
165 trt->fCurrentLayout = info->fImageLayout; 172 trt->fCurrentLayout = info->fImageLayout;
166 } 173 }
167 // Create() will increment the refCount of the image resource if it succeeds 174 // Create() will increment the refCount of the image resource if it succeeds
168 imageResource->unref(gpu); 175 imageResource->unref(gpu);
169 176
170 return trt; 177 return trt;
171 } 178 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkTexture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698