| Flutter Impeller |

texture_source_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_SOURCE_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_SOURCE_VK_H_
7
8 #include "flutter/fml/macros.h"
9 #include "flutter/fml/status.h"
10 #include "impeller/base/thread.h"
11 #include "impeller/core/texture_descriptor.h"
12 #include "impeller/renderer/backend/vulkan/barrier_vk.h"
13 #include "impeller/renderer/backend/vulkan/formats_vk.h"
14 #include "impeller/renderer/backend/vulkan/vk.h"
15
16 namespace impeller {
17
18 /// Abstract base class that represents a vkImage and an vkImageView.
19 ///
20 /// This is intended to be used with an impeller::TextureVK. Example
21 /// implementations represent swapchain images or uploaded textures.
22 class TextureSourceVK {
23 public:
24 virtual ~TextureSourceVK();
25
26 const TextureDescriptor& GetTextureDescriptor() const;
27
28 virtual vk::Image GetImage() const = 0;
29
30 virtual vk::ImageView GetImageView() const = 0;
31
32 /// Encodes the layout transition `barrier` to `barrier.cmd_buffer` for the
33 /// image.
34 ///
35 /// The transition is from the layout stored via `SetLayoutWithoutEncoding` to
36 /// `barrier.new_layout`.
37 fml::Status SetLayout(const BarrierVK& barrier) const;
38
39 /// Store the layout of the image.
40 ///
41 /// This just is bookkeeping on the CPU, to actually set the layout use
42 /// `SetLayout`.
43 ///
44 /// @param layout The new layout.
45 /// @return The old layout.
46 vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const;
47
48 /// Get the last layout assigned to the TextureSourceVK.
49 ///
50 /// This value is synchronized with the GPU via SetLayout so it may not
51 /// reflect the actual layout.
52 vk::ImageLayout GetLayout() const;
53
54 protected:
55 const TextureDescriptor desc_;
56
57 explicit TextureSourceVK(TextureDescriptor desc);
58
59 private:
60 mutable RWMutex layout_mutex_;
61 mutable vk::ImageLayout layout_ IPLR_GUARDED_BY(layout_mutex_) =
62 vk::ImageLayout::eUndefined;
63 };
64
65 } // namespace impeller
66
67 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_TEXTURE_SOURCE_VK_H_
impeller::TextureSourceVK
Definition: texture_source_vk.h:22
impeller::TextureSourceVK::TextureSourceVK
TextureSourceVK(TextureDescriptor desc)
Definition: texture_source_vk.cc:9
barrier_vk.h
texture_descriptor.h
formats_vk.h
impeller::TextureSourceVK::GetImageView
virtual vk::ImageView GetImageView() const =0
vk.h
impeller::TextureSourceVK::desc_
const TextureDescriptor desc_
Definition: texture_source_vk.h:55
impeller::TextureSourceVK::SetLayoutWithoutEncoding
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const
Definition: texture_source_vk.cc:22
impeller::BarrierVK
Defines an operations and memory access barrier on a resource.
Definition: barrier_vk.h:21
impeller::TextureSourceVK::~TextureSourceVK
virtual ~TextureSourceVK()
impeller::TextureSourceVK::GetLayout
vk::ImageLayout GetLayout() const
Definition: texture_source_vk.cc:17
impeller::TextureSourceVK::GetImage
virtual vk::Image GetImage() const =0
impeller::TextureSourceVK::SetLayout
fml::Status SetLayout(const BarrierVK &barrier) const
Definition: texture_source_vk.cc:30
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::TextureSourceVK::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture_source_vk.cc:13
thread.h
impeller
Definition: aiks_context.cc:10