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" |
11 #include "GrVkUtil.h" | 11 #include "GrVkUtil.h" |
12 | 12 |
13 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) | 13 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) |
14 | 14 |
15 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout, | 15 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout, |
16 VkAccessFlags srcAccessMask, | 16 VkAccessFlags srcAccessMask, |
17 VkAccessFlags dstAccessMask, | 17 VkAccessFlags dstAccessMask, |
18 VkPipelineStageFlags srcStageMask, | 18 VkPipelineStageFlags srcStageMask, |
19 VkPipelineStageFlags dstStageMask, | 19 VkPipelineStageFlags dstStageMask, |
20 bool byRegion) { | 20 bool byRegion) { |
21 SkASSERT(VK_IMAGE_LAYOUT_GENERAL != newLayout || VK_IMAGE_LAYOUT_PREINITIALI
ZED != newLayout); | 21 SkASSERT(VK_IMAGE_LAYOUT_GENERAL != newLayout || VK_IMAGE_LAYOUT_PREINITIALI
ZED != newLayout); |
22 // Is this reasonable? Could someone want to keep the same layout but use th
e masks to force | 22 // Is this reasonable? Could someone want to keep the same layout but use th
e masks to force |
23 // a barrier on certain things? | 23 // a barrier on certain things? |
24 if (newLayout == fCurrentLayout) { | 24 if (newLayout == fCurrentLayout) { |
25 return; | 25 return; |
26 } | 26 } |
27 | 27 |
28 VkImageMemoryBarrier imageMemoryBarrier = { | 28 VkImageMemoryBarrier imageMemoryBarrier = { |
29 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType | 29 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType |
30 NULL, // pNext | 30 NULL, // pNext |
31 srcAccessMask, // outputMask | 31 srcAccessMask, // outputMask |
32 dstAccessMask, // inputMask | 32 dstAccessMask, // inputMask |
33 fCurrentLayout, // oldLayout | 33 fCurrentLayout, // oldLayout |
34 newLayout, // newLayout | 34 newLayout, // newLayout |
35 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex | 35 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex |
36 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex | 36 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex |
37 fResource->fImage, // image | 37 fResource->fImage, // image |
38 { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 } // subresourceRange | 38 { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 } // subresourceRange |
39 }; | 39 }; |
40 | 40 |
41 // TODO: restrict to area of image we're interested in | 41 // TODO: restrict to area of image we're interested in |
42 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor
yBarrier); | 42 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor
yBarrier); |
43 | 43 |
44 fCurrentLayout = newLayout; | 44 fCurrentLayout = newLayout; |
45 } | 45 } |
46 | 46 |
47 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu, | 47 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu, |
48 const ImageDesc& imageDesc)
{ | 48 const ImageDesc& imageDesc)
{ |
49 VkImage image = 0; | 49 VkImage image = 0; |
50 VkDeviceMemory alloc; | 50 VkDeviceMemory alloc; |
51 | 51 |
52 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTil
ing) | 52 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTil
ing) |
53 ? VK_IMAGE_LAYOUT_PREINITIALIZED | 53 ? VK_IMAGE_LAYOUT_PREINITIALIZED |
54 : VK_IMAGE_LAYOUT_UNDEFINED; | 54 : VK_IMAGE_LAYOUT_UNDEFINED; |
55 | 55 |
56 // Create Image | 56 // Create Image |
57 VkSampleCountFlagBits vkSamples; | 57 VkSampleCountFlagBits vkSamples; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { | 112 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { |
113 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); | 113 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); |
114 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); | 114 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); |
115 } | 115 } |
116 | 116 |
117 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { | 117 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { |
118 } | 118 } |
OLD | NEW |