| 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/formats.h"
10 #include "impeller/core/texture.h"
11 #include "impeller/renderer/backend/vulkan/context_vk.h"
12 #include "impeller/renderer/backend/vulkan/device_buffer_vk.h"
13 #include "impeller/renderer/backend/vulkan/formats_vk.h"
14 #include "impeller/renderer/backend/vulkan/sampler_vk.h"
15 #include "impeller/renderer/backend/vulkan/texture_source_vk.h"
16 #include "impeller/renderer/backend/vulkan/vk.h"
17
18 namespace impeller {
19
20 class TextureVK final : public Texture, public BackendCast<TextureVK, Texture> {
21 public:
22 TextureVK(std::weak_ptr<Context> context,
23 std::shared_ptr<TextureSourceVK> source);
24
25 // |Texture|
26 ~TextureVK() override;
27
28 vk::Image GetImage() const;
29
30 vk::ImageView GetImageView() const;
31
32 vk::ImageView GetRenderTargetView() const;
33
34 bool SetLayout(const BarrierVK& barrier) const;
35
36 vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const;
37
38 vk::ImageLayout GetLayout() const;
39
40 std::shared_ptr<const TextureSourceVK> GetTextureSource() const;
41
42 // |Texture|
43 ISize GetSize() const override;
44
45 void SetMipMapGenerated();
46
47 bool IsSwapchainImage() const;
48
49 std::shared_ptr<SamplerVK> GetImmutableSamplerVariant(
50 const SamplerVK& sampler) const;
51
52 /// Store the last framebuffer and render pass object used with this texture.
53 ///
54 /// This method is only called if this texture is used as the resolve texture
55 /// of a render pass. By construction, this framebuffer should be compatible
56 /// with any future render passes.
57 void SetCachedFrameData(const FramebufferAndRenderPass& data,
58 SampleCount sample_count);
59
60 /// Retrieve the last framebuffer and render pass object used with this
61 /// texture.
62 ///
63 /// An empty FramebufferAndRenderPass is returned if there is no cached data
64 /// for a particular sample count.
65 const FramebufferAndRenderPass& GetCachedFrameData(
66 SampleCount sample_count) const;
67
68 private:
69 std::weak_ptr<Context> context_;
70 std::shared_ptr<TextureSourceVK> source_;
71 bool has_validation_layers_ = false;
72
73 // |Texture|
74 void SetLabel(std::string_view label) override;
75
76 // |Texture|
77 void SetLabel(std::string_view label, std::string_view trailing) override;
78
79 // |Texture|
80 bool OnSetContents(const uint8_t* contents,
81 size_t length,
82 size_t slice) override;
83
84 // |Texture|
85 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
86 size_t slice) override;
87
88 // |Texture|
89 bool IsValid() const override;
90
91 TextureVK(const TextureVK&) = delete;
92
93 TextureVK& operator=(const TextureVK&) = delete;
94 };
95
96 } // namespace impeller
97
98 #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:20
impeller::TextureVK::GetImageView
vk::ImageView GetImageView() const
Definition: texture_vk.cc:174
impeller::TextureVK::GetTextureSource
std::shared_ptr< const TextureSourceVK > GetTextureSource() const
Definition: texture_vk.cc:178
impeller::TextureVK::IsSwapchainImage
bool IsSwapchainImage() const
Definition: texture_vk.cc:214
impeller::TextureVK::GetRenderTargetView
vk::ImageView GetRenderTargetView() const
Definition: texture_vk.cc:196
impeller::TextureVK::GetCachedFrameData
const FramebufferAndRenderPass & GetCachedFrameData(SampleCount sample_count) const
Definition: texture_vk.cc:205
impeller::TextureVK::SetMipMapGenerated
void SetMipMapGenerated()
Definition: texture_vk.cc:210
impeller::TextureVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_vk.cc:186
impeller::TextureVK::GetImmutableSamplerVariant
std::shared_ptr< SamplerVK > GetImmutableSamplerVariant(const SamplerVK &sampler) const
Definition: texture_vk.cc:218
impeller::TextureVK::GetSize
ISize GetSize() const override
Definition: texture_vk.cc:166
impeller::TextureVK::TextureVK
TextureVK(std::weak_ptr< Context > context, std::shared_ptr< TextureSourceVK > source)
Definition: texture_vk.cc:15
impeller::TextureVK::SetLayout
bool SetLayout(const BarrierVK &barrier) const
Definition: texture_vk.cc:182
impeller::TextureVK::GetLayout
vk::ImageLayout GetLayout() const
Definition: texture_vk.cc:192
impeller::TextureVK::~TextureVK
~TextureVK() override
impeller::TextureVK::GetImage
vk::Image GetImage() const
Definition: texture_vk.cc:170
impeller::TextureVK::SetCachedFrameData
void SetCachedFrameData(const FramebufferAndRenderPass &data, SampleCount sample_count)
Definition: texture_vk.cc:200
formats.h
texture.h
device_buffer_vk.h
formats_vk.h
impeller
Definition: allocation.cc:12
impeller::SampleCount
SampleCount
Definition: formats.h:298
context_vk.h
sampler_vk.h
impeller::BarrierVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:27
impeller::FramebufferAndRenderPass
Definition: texture_source_vk.h:20
impeller::TSize
Definition: size.h:25
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:69
texture_source_vk.h
vk.h