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 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout, | 28 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout, |
29 VkAccessFlags dstAccessMask, | 29 VkAccessFlags dstAccessMask, |
30 VkPipelineStageFlags dstStageMask, | 30 VkPipelineStageFlags dstStageMask, |
31 bool byRegion) { | 31 bool byRegion) { |
32 SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED != newLayout && | 32 SkASSERT(VK_IMAGE_LAYOUT_UNDEFINED != newLayout && |
33 VK_IMAGE_LAYOUT_PREINITIALIZED != newLayout); | 33 VK_IMAGE_LAYOUT_PREINITIALIZED != newLayout); |
34 VkImageLayout currentLayout = this->currentLayout(); | 34 VkImageLayout currentLayout = this->currentLayout(); |
35 // Is this reasonable? Could someone want to keep the same layout but use th
e masks to force | 35 |
36 // a barrier on certain things? | 36 // If the old and new layout are the same, there is no reason to put in a ba
rrier since the |
37 if (newLayout == currentLayout) { | 37 // operations used for each layout are implicitly synchronized with eachothe
r. The one exception |
| 38 // is if the layout is GENERAL. In this case the image could have been used
for any operation so |
| 39 // we must respect the barrier. |
| 40 if (newLayout == currentLayout && VK_IMAGE_LAYOUT_GENERAL != currentLayout)
{ |
38 return; | 41 return; |
39 } | 42 } |
40 | 43 |
41 VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(currentLayou
t); | 44 VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(currentLayou
t); |
42 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(c
urrentLayout); | 45 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(c
urrentLayout); |
43 | 46 |
44 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fInfo.fFormat); | 47 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fInfo.fFormat); |
45 VkImageMemoryBarrier imageMemoryBarrier = { | 48 VkImageMemoryBarrier imageMemoryBarrier = { |
46 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType | 49 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType |
47 nullptr, // pNext | 50 nullptr, // pNext |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 152 } |
150 | 153 |
151 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { | 154 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { |
152 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); | 155 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); |
153 bool isLinear = (VK_IMAGE_TILING_LINEAR == fImageTiling); | 156 bool isLinear = (VK_IMAGE_TILING_LINEAR == fImageTiling); |
154 GrVkMemory::FreeImageMemory(gpu, isLinear, fAlloc); | 157 GrVkMemory::FreeImageMemory(gpu, isLinear, fAlloc); |
155 } | 158 } |
156 | 159 |
157 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { | 160 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { |
158 } | 161 } |
OLD | NEW |