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 
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.
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.
71 
72  /// Retrieve the last render pass object used with this texture.
73  ///
74  /// May be nullptr if no previous render pass existed.
76 
77  private:
78  std::weak_ptr<Context> context_;
79  std::shared_ptr<TextureSourceVK> source_;
80  bool has_validation_layers_ = false;
81 
82  // |Texture|
83  void SetLabel(std::string_view label) override;
84 
85  // |Texture|
86  void SetLabel(std::string_view label, std::string_view trailing) override;
87 
88  // |Texture|
89  bool OnSetContents(const uint8_t* contents,
90  size_t length,
91  size_t slice) override;
92 
93  // |Texture|
94  bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
95  size_t slice) override;
96 
97  // |Texture|
98  bool IsValid() const override;
99 
100  TextureVK(const TextureVK&) = delete;
101 
102  TextureVK& operator=(const TextureVK&) = delete;
103 };
104 
105 } // namespace impeller
106 
107 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_VK_H_
vk::ImageView GetImageView() const
Definition: texture_vk.cc:173
std::shared_ptr< const TextureSourceVK > GetTextureSource() const
Definition: texture_vk.cc:177
bool IsSwapchainImage() const
Definition: texture_vk.cc:221
vk::ImageView GetRenderTargetView() const
Definition: texture_vk.cc:195
void SetCachedFramebuffer(const SharedHandleVK< vk::Framebuffer > &framebuffer)
Definition: texture_vk.cc:199
SharedHandleVK< vk::RenderPass > GetCachedRenderPass() const
Definition: texture_vk.cc:213
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_vk.cc:185
std::shared_ptr< SamplerVK > GetImmutableSamplerVariant(const SamplerVK &sampler) const
Definition: texture_vk.cc:225
ISize GetSize() const override
Definition: texture_vk.cc:165
TextureVK(std::weak_ptr< Context > context, std::shared_ptr< TextureSourceVK > source)
Definition: texture_vk.cc:14
SharedHandleVK< vk::Framebuffer > GetCachedFramebuffer() const
Definition: texture_vk.cc:209
bool SetLayout(const BarrierVK &barrier) const
Definition: texture_vk.cc:181
vk::ImageLayout GetLayout() const
Definition: texture_vk.cc:191
void SetCachedRenderPass(const SharedHandleVK< vk::RenderPass > &render_pass)
Definition: texture_vk.cc:204
~TextureVK() override
vk::Image GetImage() const
Definition: texture_vk.cc:169
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:27