Flutter Impeller
khr_swapchain_image_vk.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 namespace impeller {
8 
10  const vk::Device& device,
11  vk::Image image)
12  : TextureSourceVK(desc), image_(image) {
13  vk::ImageViewCreateInfo view_info;
14  view_info.image = image_;
15  view_info.viewType = vk::ImageViewType::e2D;
16  view_info.format = ToVKImageFormat(desc.format);
17  view_info.subresourceRange.aspectMask = vk::ImageAspectFlagBits::eColor;
18  view_info.subresourceRange.baseMipLevel = 0u;
19  view_info.subresourceRange.baseArrayLayer = 0u;
20  view_info.subresourceRange.levelCount = desc.mip_count;
21  view_info.subresourceRange.layerCount = ToArrayLayerCount(desc.type);
22 
23  auto [view_result, view] = device.createImageViewUnique(view_info);
24  if (view_result != vk::Result::eSuccess) {
25  return;
26  }
27 
28  image_view_ = std::move(view);
29  is_valid_ = true;
30 }
31 
33 
35  return is_valid_;
36 }
37 
38 std::shared_ptr<Texture> KHRSwapchainImageVK::GetMSAATexture() const {
39  return msaa_texture_;
40 }
41 
42 std::shared_ptr<Texture> KHRSwapchainImageVK::GetDepthStencilTexture() const {
43  return depth_stencil_texture_;
44 }
45 
46 void KHRSwapchainImageVK::SetMSAATexture(std::shared_ptr<Texture> texture) {
47  msaa_texture_ = std::move(texture);
48 }
49 
51  std::shared_ptr<Texture> texture) {
52  depth_stencil_texture_ = std::move(texture);
53 }
54 
56  return desc_.format;
57 }
58 
60  return desc_.size;
61 }
62 
63 // |TextureSourceVK|
64 vk::Image KHRSwapchainImageVK::GetImage() const {
65  return image_;
66 }
67 
68 // |TextureSourceVK|
69 vk::ImageView KHRSwapchainImageVK::GetImageView() const {
70  return image_view_.get();
71 }
72 
73 // |TextureSourceVK|
75  return image_view_.get();
76 }
77 
78 } // namespace impeller
impeller::KHRSwapchainImageVK::GetDepthStencilTexture
std::shared_ptr< Texture > GetDepthStencilTexture() const
Definition: khr_swapchain_image_vk.cc:42
impeller::KHRSwapchainImageVK::~KHRSwapchainImageVK
~KHRSwapchainImageVK() override
impeller::TextureSourceVK
Abstract base class that represents a vkImage and an vkImageView.
Definition: texture_source_vk.h:28
impeller::TextureDescriptor::format
PixelFormat format
Definition: texture_descriptor.h:40
impeller::ToArrayLayerCount
constexpr uint32_t ToArrayLayerCount(TextureType type)
Definition: formats_vk.h:517
impeller::KHRSwapchainImageVK::GetImage
vk::Image GetImage() const override
Get the image handle for this texture source.
Definition: khr_swapchain_image_vk.cc:64
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:42
impeller::KHRSwapchainImageVK::GetImageView
vk::ImageView GetImageView() const override
Retrieve the image view used for sampling/blitting/compute with this texture source.
Definition: khr_swapchain_image_vk.cc:69
impeller::KHRSwapchainImageVK::SetMSAATexture
void SetMSAATexture(std::shared_ptr< Texture > texture)
Definition: khr_swapchain_image_vk.cc:46
khr_swapchain_image_vk.h
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:100
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:39
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:155
impeller::TSize< int64_t >
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:135
impeller::KHRSwapchainImageVK::SetDepthStencilTexture
void SetDepthStencilTexture(std::shared_ptr< Texture > texture)
Definition: khr_swapchain_image_vk.cc:50
impeller::KHRSwapchainImageVK::GetPixelFormat
PixelFormat GetPixelFormat() const
Definition: khr_swapchain_image_vk.cc:55
impeller::KHRSwapchainImageVK::IsValid
bool IsValid() const
Definition: khr_swapchain_image_vk.cc:34
impeller::KHRSwapchainImageVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const override
Retrieve the image view used for render target attachments with this texture source.
Definition: khr_swapchain_image_vk.cc:74
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:41
impeller::KHRSwapchainImageVK::KHRSwapchainImageVK
KHRSwapchainImageVK(TextureDescriptor desc, const vk::Device &device, vk::Image image)
Definition: khr_swapchain_image_vk.cc:9
impeller::KHRSwapchainImageVK::GetSize
ISize GetSize() const
Definition: khr_swapchain_image_vk.cc:59
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::KHRSwapchainImageVK::GetMSAATexture
std::shared_ptr< Texture > GetMSAATexture() const
Definition: khr_swapchain_image_vk.cc:38
impeller
Definition: aiks_blur_unittests.cc:20