Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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*/
7
12
14 VkImage image,
16 Type viewType, uint32_t miplevels,
17 const GrVkYcbcrConversionInfo& ycbcrInfo) {
18
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
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
static sk_sp< const GrVkImageView > Make(GrVkGpu *gpu, VkImage image, VkFormat format, Type viewType, uint32_t miplevels, const GrVkYcbcrConversionInfo &ycbcrInfo)
VkImageView imageView() const
void freeGPUData() const override
GrVkSamplerYcbcrConversion * findOrCreateCompatibleSamplerYcbcrConversion(const GrVkYcbcrConversionInfo &ycbcrInfo)
VkSamplerYcbcrConversion ycbcrConversion() const
sk_sp< SkImage > image
Definition examples.cpp:29
uint32_t uint32_t * format
VkImageAspectFlags aspectMask
VkImageSubresourceRange subresourceRange
VkSamplerYcbcrConversion conversion
@ VK_IMAGE_VIEW_TYPE_2D
@ VK_IMAGE_ASPECT_COLOR_BIT
@ VK_IMAGE_ASPECT_STENCIL_BIT
@ VK_COMPONENT_SWIZZLE_IDENTITY
VkResult
VkFormat
@ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO