Flutter Engine
The Flutter Engine
GrVkImageView.cpp
Go to the documentation of this file.
1/*
2* Copyright 2016 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
8
12
14 VkImage image,
16 Type viewType,
17 uint32_t miplevels,
18 const skgpu::VulkanYcbcrConversionInfo& ycbcrInfo) {
19 void* pNext = nullptr;
20 VkSamplerYcbcrConversionInfo conversionInfo;
21 GrVkSamplerYcbcrConversion* ycbcrConversion = nullptr;
22
23 if (ycbcrInfo.isValid()) {
24 SkASSERT(gpu->vkCaps().supportsYcbcrConversion() && format == ycbcrInfo.fFormat);
25
26 ycbcrConversion =
28 if (!ycbcrConversion) {
29 return nullptr;
30 }
31
33 conversionInfo.pNext = nullptr;
34 conversionInfo.conversion = ycbcrConversion->ycbcrConversion();
35 pNext = &conversionInfo;
36 }
37
38 VkImageView imageView;
39 // Create the VkImageView
40 VkImageViewCreateInfo viewInfo = {
42 pNext, // pNext
43 0, // flags
44 image, // image
45 VK_IMAGE_VIEW_TYPE_2D, // viewType
46 format, // format
50 VK_COMPONENT_SWIZZLE_IDENTITY }, // components
51 { VK_IMAGE_ASPECT_COLOR_BIT, 0, miplevels, 0, 1 }, // subresourceRange
52 };
53 if (kStencil_Type == viewType) {
55 }
56
57 VkResult err;
58 GR_VK_CALL_RESULT(gpu, err, CreateImageView(gpu->device(), &viewInfo, nullptr, &imageView));
59 if (err) {
60 return nullptr;
61 }
62
63 return sk_sp<const GrVkImageView>(new GrVkImageView(gpu, imageView, ycbcrConversion));
64}
65
66void GrVkImageView::freeGPUData() const {
67 GR_VK_CALL(fGpu->vkInterface(), DestroyImageView(fGpu->device(), fImageView, nullptr));
68
69 if (fYcbcrConversion) {
70 fYcbcrConversion->unref();
71 }
72}
73
#define GR_VK_CALL(IFACE, X)
Definition: GrVkUtil.h:24
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
Definition: GrVkUtil.h:35
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool supportsYcbcrConversion() const
Definition: GrVkCaps.h:153
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61
const skgpu::VulkanInterface * vkInterface() const
Definition: GrVkGpu.h:60
VkDevice device() const
Definition: GrVkGpu.h:71
GrVkResourceProvider & resourceProvider()
Definition: GrVkGpu.h:83
VkImageView imageView() const
Definition: GrVkImageView.h:33
static sk_sp< const GrVkImageView > Make(GrVkGpu *gpu, VkImage image, VkFormat format, Type viewType, uint32_t miplevels, const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
GrVkSamplerYcbcrConversion * findOrCreateCompatibleSamplerYcbcrConversion(const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
VkSamplerYcbcrConversion ycbcrConversion() const
uint32_t uint32_t * format
sk_sp< const SkImage > image
Definition: SkRecords.h:269
VkImageAspectFlags aspectMask
Definition: vulkan_core.h:2928
VkImageSubresourceRange subresourceRange
Definition: vulkan_core.h:3474
VkSamplerYcbcrConversion conversion
Definition: vulkan_core.h:5438
@ VK_IMAGE_VIEW_TYPE_2D
Definition: vulkan_core.h:1831
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan_core.h:2238
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan_core.h:2240
@ VK_COMPONENT_SWIZZLE_IDENTITY
Definition: vulkan_core.h:1819
VkResult
Definition: vulkan_core.h:140
VkFormat
Definition: vulkan_core.h:1458
@ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO
Definition: vulkan_core.h:293
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Definition: vulkan_core.h:217