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

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

Issue 2146103002: Update RT views and framebuffer in vulkan after mipmaping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 "GrTexturePriv.h" 11 #include "GrTexturePriv.h"
12 #include "GrVkTextureRenderTarget.h"
12 #include "GrVkUtil.h" 13 #include "GrVkUtil.h"
13 14
14 #include "vk/GrVkTypes.h" 15 #include "vk/GrVkTypes.h"
15 16
16 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 17 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
17 18
18 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor. 19 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor.
19 GrVkTexture::GrVkTexture(GrVkGpu* gpu, 20 GrVkTexture::GrVkTexture(GrVkGpu* gpu,
20 SkBudgeted budgeted, 21 SkBudgeted budgeted,
21 const GrSurfaceDesc& desc, 22 const GrSurfaceDesc& desc,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (!fLinearTextureView) { 155 if (!fLinearTextureView) {
155 fLinearTextureView = GrVkImageView::Create(this->getVkGpu(), fInfo.fImag e, 156 fLinearTextureView = GrVkImageView::Create(this->getVkGpu(), fInfo.fImag e,
156 linearFormat, GrVkImageView:: kColor_Type, 157 linearFormat, GrVkImageView:: kColor_Type,
157 fInfo.fLevelCount); 158 fInfo.fLevelCount);
158 SkASSERT(fLinearTextureView); 159 SkASSERT(fLinearTextureView);
159 } 160 }
160 161
161 return fLinearTextureView; 162 return fLinearTextureView;
162 } 163 }
163 164
164 bool GrVkTexture::reallocForMipmap(const GrVkGpu* gpu, uint32_t mipLevels) { 165 bool GrVkTexture::reallocForMipmap(GrVkGpu* gpu, uint32_t mipLevels) {
165 if (mipLevels == 1) { 166 if (mipLevels == 1) {
166 // don't need to do anything for a 1x1 texture 167 // don't need to do anything for a 1x1 texture
167 return false; 168 return false;
168 } 169 }
169 170
170 const GrVkResource* oldResource = this->resource(); 171 const GrVkResource* oldResource = this->resource();
171 172
172 // We shouldn't realloc something that doesn't belong to us 173 // We shouldn't realloc something that doesn't belong to us
173 if (fIsBorrowed) { 174 if (fIsBorrowed) {
174 return false; 175 return false;
175 } 176 }
176 177
177 // Does this even make sense for rendertargets? 178 // Does this even make sense for rendertargets?
jvanverth1 2016/07/13 21:01:45 Remove this comment? Apparently it does make sense
egdaniel 2016/07/13 21:06:35 Done.
178 bool renderTarget = SkToBool(fDesc.fFlags & kRenderTarget_GrSurfaceFlag); 179 bool renderTarget = SkToBool(fDesc.fFlags & kRenderTarget_GrSurfaceFlag);
179 180
180 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT; 181 VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
181 if (renderTarget) { 182 if (renderTarget) {
182 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; 183 usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
183 } 184 }
184 usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_ BIT; 185 usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_ BIT;
185 186
186 GrVkImage::ImageDesc imageDesc; 187 GrVkImage::ImageDesc imageDesc;
187 imageDesc.fImageType = VK_IMAGE_TYPE_2D; 188 imageDesc.fImageType = VK_IMAGE_TYPE_2D;
(...skipping 14 matching lines...) Expand all
202 // have to create a new image view for new resource 203 // have to create a new image view for new resource
203 const GrVkImageView* oldView = fTextureView; 204 const GrVkImageView* oldView = fTextureView;
204 VkImage image = info.fImage; 205 VkImage image = info.fImage;
205 const GrVkImageView* textureView = GrVkImageView::Create(gpu, image, info.fF ormat, 206 const GrVkImageView* textureView = GrVkImageView::Create(gpu, image, info.fF ormat,
206 GrVkImageView::kCol or_Type, mipLevels); 207 GrVkImageView::kCol or_Type, mipLevels);
207 if (!textureView) { 208 if (!textureView) {
208 GrVkImage::DestroyImageInfo(gpu, &info); 209 GrVkImage::DestroyImageInfo(gpu, &info);
209 return false; 210 return false;
210 } 211 }
211 212
213 if (renderTarget) {
214 GrVkTextureRenderTarget* texRT = static_cast<GrVkTextureRenderTarget*>(t his);
215 if (!texRT->updateForMipmap(gpu, info)) {
216 GrVkImage::DestroyImageInfo(gpu, &info);
217 return false;
218 }
219 }
220
212 oldResource->unref(gpu); 221 oldResource->unref(gpu);
213 oldView->unref(gpu); 222 oldView->unref(gpu);
214 if (fLinearTextureView) { 223 if (fLinearTextureView) {
215 fLinearTextureView->unref(gpu); 224 fLinearTextureView->unref(gpu);
216 fLinearTextureView = nullptr; 225 fLinearTextureView = nullptr;
217 } 226 }
218 227
219 this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling); 228 this->setNewResource(info.fImage, info.fAlloc, info.fImageTiling);
220 fTextureView = textureView; 229 fTextureView = textureView;
221 fInfo = info; 230 fInfo = info;
222 this->texturePriv().setMaxMipMapLevel(mipLevels); 231 this->texturePriv().setMaxMipMapLevel(mipLevels);
223 232
224 return true; 233 return true;
225 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698