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