| 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 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_
backend_cast.h
impeller::BackendCast
Definition: backend_cast.h:11
impeller::SamplerVK
Definition: sampler_vk.h:18
impeller::Texture
Definition: texture.h:17
impeller::TextureVK
Definition: texture_vk.h:19
impeller::TextureVK::GetImageView
vk::ImageView GetImageView() const
Definition: texture_vk.cc:173
impeller::TextureVK::GetTextureSource
std::shared_ptr< const TextureSourceVK > GetTextureSource() const
Definition: texture_vk.cc:177
impeller::TextureVK::IsSwapchainImage
bool IsSwapchainImage() const
Definition: texture_vk.cc:221
impeller::TextureVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const
Definition: texture_vk.cc:195
impeller::TextureVK::SetCachedFramebuffer
void SetCachedFramebuffer(const SharedHandleVK< vk::Framebuffer > &framebuffer)
Definition: texture_vk.cc:199
impeller::TextureVK::SetMipMapGenerated
void SetMipMapGenerated()
Definition: texture_vk.cc:217
impeller::TextureVK::GetCachedRenderPass
SharedHandleVK< vk::RenderPass > GetCachedRenderPass() const
Definition: texture_vk.cc:213
impeller::TextureVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_vk.cc:185
impeller::TextureVK::GetImmutableSamplerVariant
std::shared_ptr< SamplerVK > GetImmutableSamplerVariant(const SamplerVK &sampler) const
Definition: texture_vk.cc:225
impeller::TextureVK::GetSize
ISize GetSize() const override
Definition: texture_vk.cc:165
impeller::TextureVK::TextureVK
TextureVK(std::weak_ptr< Context > context, std::shared_ptr< TextureSourceVK > source)
Definition: texture_vk.cc:14
impeller::TextureVK::GetCachedFramebuffer
SharedHandleVK< vk::Framebuffer > GetCachedFramebuffer() const
Definition: texture_vk.cc:209
impeller::TextureVK::SetLayout
bool SetLayout(const BarrierVK &barrier) const
Definition: texture_vk.cc:181
impeller::TextureVK::GetLayout
vk::ImageLayout GetLayout() const
Definition: texture_vk.cc:191
impeller::TextureVK::SetCachedRenderPass
void SetCachedRenderPass(const SharedHandleVK< vk::RenderPass > &render_pass)
Definition: texture_vk.cc:204
impeller::TextureVK::~TextureVK
~TextureVK() override
impeller::TextureVK::GetImage
vk::Image GetImage() const
Definition: texture_vk.cc:169
context_vk.h
texture.h
device_buffer_vk.h
formats_vk.h
impeller
Definition: allocation.cc:12
impeller::SharedHandleVK
std::shared_ptr< SharedObjectVKT< T > > SharedHandleVK
Definition: shared_object_vk.h:53
sampler_vk.h
impeller::BarrierVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:27
impeller::TSize
Definition: size.h:25
texture_source_vk.h
vk.h