OLD | NEW |
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" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 imageDesc.fWidth = fDesc.fWidth; | 189 imageDesc.fWidth = fDesc.fWidth; |
190 imageDesc.fHeight = fDesc.fHeight; | 190 imageDesc.fHeight = fDesc.fHeight; |
191 imageDesc.fLevels = mipLevels; | 191 imageDesc.fLevels = mipLevels; |
192 imageDesc.fSamples = 1; | 192 imageDesc.fSamples = 1; |
193 imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL; | 193 imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL; |
194 imageDesc.fUsageFlags = usageFlags; | 194 imageDesc.fUsageFlags = usageFlags; |
195 imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; | 195 imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; |
196 | 196 |
197 GrVkImageInfo info; | 197 GrVkImageInfo info; |
198 if (!GrVkImage::InitImageInfo(gpu, imageDesc, &info)) { | 198 if (!GrVkImage::InitImageInfo(gpu, imageDesc, &info)) { |
199 return nullptr; | 199 return false; |
200 } | 200 } |
201 | 201 |
202 // have to create a new image view for new resource | 202 // have to create a new image view for new resource |
203 const GrVkImageView* oldView = fTextureView; | 203 const GrVkImageView* oldView = fTextureView; |
204 VkImage image = info.fImage; | 204 VkImage image = info.fImage; |
205 const GrVkImageView* textureView = GrVkImageView::Create(gpu, image, info.fF
ormat, | 205 const GrVkImageView* textureView = GrVkImageView::Create(gpu, image, info.fF
ormat, |
206 GrVkImageView::kCol
or_Type, mipLevels); | 206 GrVkImageView::kCol
or_Type, mipLevels); |
207 if (!textureView) { | 207 if (!textureView) { |
208 GrVkImage::DestroyImageInfo(gpu, &info); | 208 GrVkImage::DestroyImageInfo(gpu, &info); |
209 return false; | 209 return false; |
210 } | 210 } |
211 | 211 |
212 oldResource->unref(gpu); | 212 oldResource->unref(gpu); |
213 oldView->unref(gpu); | 213 oldView->unref(gpu); |
214 if (fLinearTextureView) { | 214 if (fLinearTextureView) { |
215 fLinearTextureView->unref(gpu); | 215 fLinearTextureView->unref(gpu); |
216 fLinearTextureView = nullptr; | 216 fLinearTextureView = nullptr; |
217 } | 217 } |
218 | 218 |
219 this->setNewResource(info.fImage, info.fAlloc); | 219 this->setNewResource(info.fImage, info.fAlloc); |
220 fTextureView = textureView; | 220 fTextureView = textureView; |
221 fInfo = info; | 221 fInfo = info; |
222 this->texturePriv().setMaxMipMapLevel(mipLevels); | 222 this->texturePriv().setMaxMipMapLevel(mipLevels); |
223 | 223 |
224 return true; | 224 return true; |
225 } | 225 } |
OLD | NEW |