OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "GrVkImageView.h" | 8 #include "GrVkImageView.h" |
9 #include "GrVkGpu.h" | 9 #include "GrVkGpu.h" |
10 #include "GrVkUtil.h" | 10 #include "GrVkUtil.h" |
11 | 11 |
12 const GrVkImageView* GrVkImageView::Create(const GrVkGpu* gpu, VkImage image, Vk
Format format, | 12 const GrVkImageView* GrVkImageView::Create(const GrVkGpu* gpu, VkImage image, Vk
Format format, |
13 Type viewType, uint32_t miplevels) { | 13 Type viewType, uint32_t miplevels) { |
14 VkImageView imageView; | 14 VkImageView imageView; |
15 | 15 |
16 // Create the VkImageView | 16 // Create the VkImageView |
17 VkImageViewCreateInfo viewInfo = { | 17 VkImageViewCreateInfo viewInfo = { |
18 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType | 18 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // sType |
19 NULL, // pNext | 19 NULL, // pNext |
20 0, // flags | 20 0, // flags |
21 image, // image | 21 image, // image |
22 VK_IMAGE_VIEW_TYPE_2D, // viewType | 22 VK_IMAGE_VIEW_TYPE_2D, // viewType |
23 format, // format | 23 format, // format |
24 { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, | 24 { VK_COMPONENT_SWIZZLE_IDENTITY, |
25 VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A }, // components | 25 VK_COMPONENT_SWIZZLE_IDENTITY, |
| 26 VK_COMPONENT_SWIZZLE_IDENTITY, |
| 27 VK_COMPONENT_SWIZZLE_IDENTITY }, // components |
26 { VK_IMAGE_ASPECT_COLOR_BIT, 0, miplevels, 0, 1 }, // subresourceRa
nge | 28 { VK_IMAGE_ASPECT_COLOR_BIT, 0, miplevels, 0, 1 }, // subresourceRa
nge |
27 }; | 29 }; |
28 if (kStencil_Type == viewType) { | 30 if (kStencil_Type == viewType) { |
29 viewInfo.components.r = VK_COMPONENT_SWIZZLE_ZERO; | |
30 viewInfo.components.g = VK_COMPONENT_SWIZZLE_ZERO; | |
31 viewInfo.components.b = VK_COMPONENT_SWIZZLE_ZERO; | |
32 viewInfo.components.a = VK_COMPONENT_SWIZZLE_ZERO; | |
33 viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; | 31 viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT; |
34 } | 32 } |
35 | 33 |
36 VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateImageView(gpu->device(),
&viewInfo, | 34 VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateImageView(gpu->device(),
&viewInfo, |
37 nullptr, &imag
eView)); | 35 nullptr, &imag
eView)); |
38 if (err) { | 36 if (err) { |
39 return nullptr; | 37 return nullptr; |
40 } | 38 } |
41 | 39 |
42 return new GrVkImageView(imageView); | 40 return new GrVkImageView(imageView); |
43 } | 41 } |
44 | 42 |
45 void GrVkImageView::freeGPUData(const GrVkGpu* gpu) const { | 43 void GrVkImageView::freeGPUData(const GrVkGpu* gpu) const { |
46 GR_VK_CALL(gpu->vkInterface(), DestroyImageView(gpu->device(), fImageView, n
ullptr)); | 44 GR_VK_CALL(gpu->vkInterface(), DestroyImageView(gpu->device(), fImageView, n
ullptr)); |
47 } | 45 } |
OLD | NEW |