Flutter Engine
 
Loading...
Searching...
No Matches
render_pass_builder_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_RENDER_PASS_BUILDER_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RENDER_PASS_BUILDER_VK_H_
7
8#include <map>
9#include <optional>
10
14
15namespace impeller {
16
17static constexpr size_t kMaxColorAttachments = 16;
18static constexpr size_t kMaxAttachments =
19 (kMaxColorAttachments * 2) + 1; // MSAA + resolve plus depth/stencil
20
22 public:
24
26
28
30
32 size_t index,
33 PixelFormat format,
34 SampleCount sample_count,
35 LoadAction load_action,
36 StoreAction store_action,
37 vk::ImageLayout current_layout = vk::ImageLayout::eUndefined,
38 bool is_swapchain = false);
39
41 SampleCount sample_count,
42 LoadAction load_action,
43 StoreAction store_action);
44
46 SampleCount sample_count,
47 LoadAction load_action,
48 StoreAction store_action);
49
50 vk::UniqueRenderPass Build(const vk::Device& device) const;
51
52 // Visible for testing.
53 const std::map<size_t, vk::AttachmentDescription>& GetColorAttachments()
54 const;
55
56 // Visible for testing.
57 const std::map<size_t, vk::AttachmentDescription>& GetResolves() const;
58
59 // Visible for testing.
60 const std::optional<vk::AttachmentDescription>& GetDepthStencil() const;
61
62 // Visible for testing.
63 std::optional<vk::AttachmentDescription> GetColor0() const;
64
65 // Visible for testing.
66 std::optional<vk::AttachmentDescription> GetColor0Resolve() const;
67
68 private:
69 std::optional<vk::AttachmentDescription> color0_;
70 std::optional<vk::AttachmentDescription> color0_resolve_;
71 std::optional<vk::AttachmentDescription> depth_stencil_;
72
73 // Color attachment 0 is stored in the field above and not in these maps.
74 std::map<size_t, vk::AttachmentDescription> colors_;
75 std::map<size_t, vk::AttachmentDescription> resolves_;
76};
77
78//------------------------------------------------------------------------------
79/// @brief Inserts the appropriate barriers to ensure that subsequent
80/// commands can read from the specified image (itself a framebuffer
81/// attachment) as an input attachment.
82///
83/// Unlike most barriers, this barrier may only be inserted within a
84/// Vulkan render-pass.
85///
86/// The type of barrier inserted depends on the subpass setup and
87/// self-dependencies. Only use this utility method for inserting
88/// barriers in render passes created by `RenderPassBuilderVK`.
89///
90/// @param[in] buffer The buffer
91/// @param[in] image The image
92///
93void InsertBarrierForInputAttachmentRead(const vk::CommandBuffer& buffer,
94 const vk::Image& image);
95
96} // namespace impeller
97
98#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RENDER_PASS_BUILDER_VK_H_
std::optional< vk::AttachmentDescription > GetColor0() const
RenderPassBuilderVK & SetDepthStencilAttachment(PixelFormat format, SampleCount sample_count, LoadAction load_action, StoreAction store_action)
const std::map< size_t, vk::AttachmentDescription > & GetColorAttachments() const
const std::map< size_t, vk::AttachmentDescription > & GetResolves() const
RenderPassBuilderVK & SetStencilAttachment(PixelFormat format, SampleCount sample_count, LoadAction load_action, StoreAction store_action)
const std::optional< vk::AttachmentDescription > & GetDepthStencil() const
RenderPassBuilderVK & operator=(const RenderPassBuilderVK &)=delete
RenderPassBuilderVK & SetColorAttachment(size_t index, PixelFormat format, SampleCount sample_count, LoadAction load_action, StoreAction store_action, vk::ImageLayout current_layout=vk::ImageLayout::eUndefined, bool is_swapchain=false)
RenderPassBuilderVK(const RenderPassBuilderVK &)=delete
vk::UniqueRenderPass Build(const vk::Device &device) const
std::optional< vk::AttachmentDescription > GetColor0Resolve() const
FlutterVulkanImage * image
VkDevice device
Definition main.cc:69
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
static constexpr size_t kMaxAttachments
void InsertBarrierForInputAttachmentRead(const vk::CommandBuffer &buffer, const vk::Image &image)
Inserts the appropriate barriers to ensure that subsequent commands can read from the specified image...
static constexpr size_t kMaxColorAttachments