| 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 "GrVkGpu.h" | 8 #include "GrVkGpu.h" |
| 9 #include "GrVkImage.h" | 9 #include "GrVkImage.h" |
| 10 #include "GrVkMemory.h" | 10 #include "GrVkMemory.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 { aspectFlags, 0, fInfo.fLevelCount, 0, 1 } // subresourceRange | 55 { aspectFlags, 0, fInfo.fLevelCount, 0, 1 } // subresourceRange |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor
yBarrier); | 58 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor
yBarrier); |
| 59 | 59 |
| 60 fInfo.fImageLayout = newLayout; | 60 fInfo.fImageLayout = newLayout; |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr
VkImageInfo* info) { | 63 bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr
VkImageInfo* info) { |
| 64 VkImage image = 0; | 64 VkImage image = 0; |
| 65 VkDeviceMemory alloc; | 65 GrVkAlloc alloc; |
| 66 | 66 |
| 67 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTil
ing) | 67 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTil
ing) |
| 68 ? VK_IMAGE_LAYOUT_PREINITIALIZED | 68 ? VK_IMAGE_LAYOUT_PREINITIALIZED |
| 69 : VK_IMAGE_LAYOUT_UNDEFINED; | 69 : VK_IMAGE_LAYOUT_UNDEFINED; |
| 70 | 70 |
| 71 // Create Image | 71 // Create Image |
| 72 VkSampleCountFlagBits vkSamples; | 72 VkSampleCountFlagBits vkSamples; |
| 73 if (!GrSampleCountToVkSampleCount(imageDesc.fSamples, &vkSamples)) { | 73 if (!GrSampleCountToVkSampleCount(imageDesc.fSamples, &vkSamples)) { |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 info->fAlloc = alloc; | 111 info->fAlloc = alloc; |
| 112 info->fImageTiling = imageDesc.fImageTiling; | 112 info->fImageTiling = imageDesc.fImageTiling; |
| 113 info->fImageLayout = initialLayout; | 113 info->fImageLayout = initialLayout; |
| 114 info->fFormat = imageDesc.fFormat; | 114 info->fFormat = imageDesc.fFormat; |
| 115 info->fLevelCount = imageDesc.fLevels; | 115 info->fLevelCount = imageDesc.fLevels; |
| 116 return true; | 116 return true; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void GrVkImage::DestroyImageInfo(const GrVkGpu* gpu, GrVkImageInfo* info) { | 119 void GrVkImage::DestroyImageInfo(const GrVkGpu* gpu, GrVkImageInfo* info) { |
| 120 VK_CALL(gpu, DestroyImage(gpu->device(), info->fImage, nullptr)); | 120 VK_CALL(gpu, DestroyImage(gpu->device(), info->fImage, nullptr)); |
| 121 VK_CALL(gpu, FreeMemory(gpu->device(), info->fAlloc, nullptr)); | 121 GrVkMemory::FreeImageMemory(gpu, info->fAlloc); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void GrVkImage::setNewResource(VkImage image, VkDeviceMemory alloc) { | 124 void GrVkImage::setNewResource(VkImage image, const GrVkAlloc& alloc) { |
| 125 fResource = new Resource(image, alloc); | 125 fResource = new Resource(image, alloc); |
| 126 } | 126 } |
| 127 | 127 |
| 128 GrVkImage::~GrVkImage() { | 128 GrVkImage::~GrVkImage() { |
| 129 // should have been released or abandoned first | 129 // should have been released or abandoned first |
| 130 SkASSERT(!fResource); | 130 SkASSERT(!fResource); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void GrVkImage::releaseImage(const GrVkGpu* gpu) { | 133 void GrVkImage::releaseImage(const GrVkGpu* gpu) { |
| 134 if (fResource) { | 134 if (fResource) { |
| 135 fResource->unref(gpu); | 135 fResource->unref(gpu); |
| 136 fResource = nullptr; | 136 fResource = nullptr; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 void GrVkImage::abandonImage() { | 140 void GrVkImage::abandonImage() { |
| 141 if (fResource) { | 141 if (fResource) { |
| 142 fResource->unrefAndAbandon(); | 142 fResource->unrefAndAbandon(); |
| 143 fResource = nullptr; | 143 fResource = nullptr; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { | 147 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { |
| 148 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); | 148 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); |
| 149 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); | 149 GrVkMemory::FreeImageMemory(gpu, fAlloc); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { | 152 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { |
| 153 } | 153 } |
| OLD | NEW |