| Flutter Impeller |

texture_vk.h
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
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
7
8 #include "impeller/base/backend_cast.h"
9 #include "impeller/core/texture.h"
10 #include "impeller/renderer/backend/vulkan/context_vk.h"
11 #include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
12 #include "impeller/renderer/backend/vulkan/formats_vk.h"
13 #include "impeller/renderer/backend/vulkan/sampler_vk.h"
14 #include "impeller/renderer/backend/vulkan/texture_source_vk.h"
15 #include "impeller/renderer/backend/vulkan/vk.h"
16
17 namespace impeller {
18
19 class TextureVK final : public Texture, public BackendCast<TextureVK, Texture> {
20 public:
21 TextureVK(std::weak_ptr<Context> context,
22 std::shared_ptr<TextureSourceVK> source);
23
24 // |Texture|
25 ~TextureVK() override;
26
27 vk::Image GetImage() const;
28
29 vk::ImageView GetImageView() const;
30
31 vk::ImageView GetRenderTargetView() const;
32
33 bool SetLayout(const BarrierVK& barrier) const;
34
35 vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const;
36
37 vk::ImageLayout GetLayout() const;
38
39 std::shared_ptr<const TextureSourceVK> GetTextureSource() const;
40
41 // |Texture|
42 ISize GetSize() const override;
43
44 void SetMipMapGenerated();
45
46 bool IsSwapchainImage() const;
47
48 std::shared_ptr<SamplerVK> GetImmutableSamplerVariant(
49 const SamplerVK& sampler) const;
50
51 // These methods should only be used by render_pass_vk.h
52
53 /// Store the last framebuffer object used with this texture.
54 ///
55 /// This field is only set if this texture is used as the resolve texture
56 /// of a render pass. By construction, this framebuffer should be compatible
57 /// with any future render passes.
58 void SetCachedFramebuffer(const SharedHandleVK<vk::Framebuffer>& framebuffer);
59
60 /// Store the last render pass object used with this texture.
61 ///
62 /// This field is only set if this texture is used as the resolve texture
63 /// of a render pass. By construction, this framebuffer should be compatible
64 /// with any future render passes.
65 void SetCachedRenderPass(const SharedHandleVK<vk::RenderPass>& render_pass);
66
67 /// Retrieve the last framebuffer object used with this texture.
68 ///
69 /// May be nullptr if no previous framebuffer existed.
70 SharedHandleVK<vk::Framebuffer> GetCachedFramebuffer() const;
71
72 /// Retrieve the last render pass object used with this texture.
73 ///
74 /// May be nullptr if no previous render pass existed.
75 SharedHandleVK<vk::RenderPass> GetCachedRenderPass() const;
76
77 private:
78 std::weak_ptr<Context> context_;
79 std::shared_ptr<TextureSourceVK> source_;
80
81 // |Texture|
82 void SetLabel(std::string_view label) override;
83
84 // |Texture|
85 bool OnSetContents(const uint8_t* contents,
86 size_t length,
87 size_t slice) override;
88
89 // |Texture|
90 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
91 size_t slice) override;
92
93 // |Texture|
94 bool IsValid() const override;
95
96 TextureVK(const TextureVK&) = delete;
97
98 TextureVK& operator=(const TextureVK&) = delete;
99 };
100
101 } // namespace impeller
102
103 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
impeller::TextureVK::GetCachedFramebuffer
SharedHandleVK< vk::Framebuffer > GetCachedFramebuffer() const
Definition: texture_vk.cc:186
texture_source_vk.h
impeller::TextureVK::SetMipMapGenerated
void SetMipMapGenerated()
Definition: texture_vk.cc:194
formats_vk.h
impeller::SamplerVK
Definition: sampler_vk.h:18
impeller::TextureVK::GetTextureSource
std::shared_ptr< const TextureSourceVK > GetTextureSource() const
Definition: texture_vk.cc:154
vk.h
impeller::TextureVK::SetLayout
bool SetLayout(const BarrierVK &barrier) const
Definition: texture_vk.cc:158
impeller::Texture
Definition: texture.h:17
impeller::TSize
Definition: size.h:19
impeller::TextureVK::GetImage
vk::Image GetImage() const
Definition: texture_vk.cc:146
impeller::BarrierVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:27
impeller::TextureVK::IsSwapchainImage
bool IsSwapchainImage() const
Definition: texture_vk.cc:198
impeller::TextureVK::GetImageView
vk::ImageView GetImageView() const
Definition: texture_vk.cc:150
impeller::TextureVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const
Definition: texture_vk.cc:172
impeller::TextureVK::SetCachedFramebuffer
void SetCachedFramebuffer(const SharedHandleVK< vk::Framebuffer > &framebuffer)
Definition: texture_vk.cc:176
impeller::TextureVK::~TextureVK
~TextureVK() override
backend_cast.h
impeller::TextureVK::GetLayout
vk::ImageLayout GetLayout() const
Definition: texture_vk.cc:168
impeller::TextureVK
Definition: texture_vk.h:19
impeller::TextureVK::GetSize
ISize GetSize() const override
Definition: texture_vk.cc:142
impeller::BackendCast
Definition: backend_cast.h:11
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:53
device_buffer_vk.h
impeller::TextureVK::GetCachedRenderPass
SharedHandleVK< vk::RenderPass > GetCachedRenderPass() const
Definition: texture_vk.cc:190
texture.h
sampler_vk.h
impeller::TextureVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_vk.cc:162
impeller::TextureVK::GetImmutableSamplerVariant
std::shared_ptr< SamplerVK > GetImmutableSamplerVariant(const SamplerVK &sampler) const
Definition: texture_vk.cc:202
context_vk.h
impeller::TextureVK::TextureVK
TextureVK(std::weak_ptr< Context > context, std::shared_ptr< TextureSourceVK > source)
Definition: texture_vk.cc:13
impeller
Definition: allocation.cc:12
impeller::TextureVK::SetCachedRenderPass
void SetCachedRenderPass(const SharedHandleVK< vk::RenderPass > &render_pass)
Definition: texture_vk.cc:181