| Flutter Impeller |

Public Member Functions | List of all members
impeller::RenderPassBuilderVK Class Reference

`#include <render_pass_builder_vk.h>`

## Public Member Functions
| RenderPassBuilderVK ()
| ~RenderPassBuilderVK ()
| RenderPassBuilderVK (const RenderPassBuilderVK &)=delete
RenderPassBuilderVK & | operator= (const RenderPassBuilderVK &)=delete
RenderPassBuilderVK & | SetColorAttachment (size_t index, PixelFormat format, SampleCount sample_count, LoadAction load_action, StoreAction store_action)
RenderPassBuilderVK & | SetDepthStencilAttachment (PixelFormat format, SampleCount sample_count, LoadAction load_action, StoreAction store_action)
RenderPassBuilderVK & | SetStencilAttachment (PixelFormat format, SampleCount sample_count, LoadAction load_action, StoreAction store_action)
vk::UniqueRenderPass | Build (const vk::Device &device) const
const std::map< size_t, vk::AttachmentDescription > & | GetColorAttachments () const
const std::map< size_t, vk::AttachmentDescription > & | GetResolves () const
const std::optional< vk::AttachmentDescription > & | GetDepthStencil () const

## Detailed Description

Definition at line 17 of file render_pass_builder_vk.h.

## Constructor & Destructor Documentation

## ◆ RenderPassBuilderVK() [1/2]

impeller::RenderPassBuilderVK::RenderPassBuilderVK | ( |  | ) |
| default

## ◆ ~RenderPassBuilderVK()

impeller::RenderPassBuilderVK::~RenderPassBuilderVK | ( |  | ) |
| default

## ◆ RenderPassBuilderVK() [2/2]

impeller::RenderPassBuilderVK::RenderPassBuilderVK | ( | const RenderPassBuilderVK & |  | ) |
| delete

## Member Function Documentation

## ◆ Build()

vk::UniqueRenderPass impeller::RenderPassBuilderVK::Build | ( | const vk::Device & | device | ) | const

Definition at line 92 of file render_pass_builder_vk.cc.

93 {
94 // This must be less than `VkPhysicalDeviceLimits::maxColorAttachments` but we
95 // are not checking.
96 const auto color_attachments_count =
97 colors_.empty() ? 0u : colors_.rbegin()->first + 1u;
98
99 std::vector<vk::AttachmentDescription> attachments;
100
101 std::vector<vk::AttachmentReference> color_refs(color_attachments_count,
102 kUnusedAttachmentReference);
103 std::vector<vk::AttachmentReference> resolve_refs(color_attachments_count,
104 kUnusedAttachmentReference);
105 vk::AttachmentReference depth_stencil_ref = kUnusedAttachmentReference;
106
107 for (const auto& color : colors_) {
108 vk::AttachmentReference color_ref;
109 color_ref.attachment = attachments.size();
110 color_ref.layout = vk::ImageLayout::eGeneral;
111 color_refs[color.first] = color_ref;
112 attachments.push_back(color.second);
113
114 if (auto found = resolves_.find(color.first); found != resolves_.end()) {
115 vk::AttachmentReference resolve_ref;
116 resolve_ref.attachment = attachments.size();
117 resolve_ref.layout = vk::ImageLayout::eGeneral;
118 resolve_refs[color.first] = resolve_ref;
119 attachments.push_back(found->second);
120 }
121 }
122
123 if (depth_stencil_.has_value()) {
124 depth_stencil_ref.attachment = attachments.size();
125 depth_stencil_ref.layout = vk::ImageLayout::eGeneral;
126 attachments.push_back(depth_stencil_.value());
127 }
128
129 vk::SubpassDescription subpass0;
130 subpass0.pipelineBindPoint = vk::PipelineBindPoint::eGraphics;
131 subpass0.setInputAttachments(color_refs);
132 subpass0.setColorAttachments(color_refs);
133 subpass0.setResolveAttachments(resolve_refs);
134 subpass0.setPDepthStencilAttachment(&depth_stencil_ref);
135
136 vk::SubpassDependency self_dep;
137 self_dep.srcSubpass = 0u; // first subpass
138 self_dep.dstSubpass = 0u; // to itself
139 self_dep.srcStageMask = kSelfDependencySrcStageMask;
140 self_dep.srcAccessMask = kSelfDependencySrcAccessMask;
141 self_dep.dstStageMask = kSelfDependencyDstStageMask;
142 self_dep.dstAccessMask = kSelfDependencyDstAccessMask;
143 self_dep.dependencyFlags = kSelfDependencyFlags;
144
145 vk::RenderPassCreateInfo render_pass_desc;
146 render_pass_desc.setAttachments(attachments);
147 render_pass_desc.setSubpasses(subpass0);
148 render_pass_desc.setDependencies(self_dep);
149
150 auto [result, pass] = device.createRenderPassUnique(render_pass_desc);
151 if (result != vk::Result::eSuccess) {
152 VALIDATION_LOG << "Failed to create render pass: " << vk::to_string(result);
153 return {};
154 }
155 return std::move(pass);
156 }

References color, impeller::kSelfDependencyDstAccessMask, impeller::kSelfDependencyDstStageMask, impeller::kSelfDependencyFlags, impeller::kSelfDependencySrcAccessMask, impeller::kSelfDependencySrcStageMask, impeller::kUnusedAttachmentReference, and VALIDATION_LOG.

Referenced by impeller::CreateCompatRenderPassForPipeline(), impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded(), and impeller::testing::TEST().

## ◆ GetColorAttachments()

const std::map< size_t, vk::AttachmentDescription > & impeller::RenderPassBuilderVK::GetColorAttachments | ( |  | ) | const

Definition at line 189 of file render_pass_builder_vk.cc.

189 {
190 return colors_;
191 }

Referenced by impeller::testing::TEST().

## ◆ GetDepthStencil()

const std::optional< vk::AttachmentDescription > & impeller::RenderPassBuilderVK::GetDepthStencil | ( |  | ) | const

Definition at line 199 of file render_pass_builder_vk.cc.

199 {
200 return depth_stencil_;
201 }

Referenced by impeller::testing::TEST().

## ◆ GetResolves()

const std::map< size_t, vk::AttachmentDescription > & impeller::RenderPassBuilderVK::GetResolves | ( |  | ) | const

Definition at line 194 of file render_pass_builder_vk.cc.

194 {
195 return resolves_;
196 }

Referenced by impeller::testing::TEST().

## ◆ operator=()

RenderPassBuilderVK& impeller::RenderPassBuilderVK::operator= | ( | const RenderPassBuilderVK & |  | ) |
| delete

## ◆ SetColorAttachment()

RenderPassBuilderVK & impeller::RenderPassBuilderVK::SetColorAttachment | ( | size_t | index,
|  | PixelFormat | format,
|  | SampleCount | sample_count,
|  | LoadAction | load_action,
|  | StoreAction | store_action
| ) |  |

Definition at line 29 of file render_pass_builder_vk.cc.

34 {
35 vk::AttachmentDescription desc;
36 desc.format = ToVKImageFormat(format);
37 desc.samples = ToVKSampleCount(sample_count);
38 desc.loadOp = ToVKAttachmentLoadOp(load_action);
39 desc.storeOp = ToVKAttachmentStoreOp(store_action, false);
40 desc.stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
41 desc.stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
42 desc.initialLayout = vk::ImageLayout::eGeneral;
43 desc.finalLayout = vk::ImageLayout::eGeneral;
44 colors_[index] = desc;
45
46 if (StoreActionPerformsResolve(store_action)) {
47 desc.storeOp = ToVKAttachmentStoreOp(store_action, true);
48 desc.samples = vk::SampleCountFlagBits::e1;
49 resolves_[index] = desc;
50 } else {
51 resolves_.erase(index);
52 }
53 return *this;
54 }

References impeller::StoreActionPerformsResolve(), impeller::ToVKAttachmentLoadOp(), impeller::ToVKAttachmentStoreOp(), impeller::ToVKImageFormat(), and impeller::ToVKSampleCount().

Referenced by impeller::CreateCompatRenderPassForPipeline(), impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded(), and impeller::testing::TEST().

## ◆ SetDepthStencilAttachment()

RenderPassBuilderVK & impeller::RenderPassBuilderVK::SetDepthStencilAttachment | ( | PixelFormat | format,
|  | SampleCount | sample_count,
|  | LoadAction | load_action,
|  | StoreAction | store_action
| ) |  |

Definition at line 56 of file render_pass_builder_vk.cc.

60 {
61 vk::AttachmentDescription desc;
62 desc.format = ToVKImageFormat(format);
63 desc.samples = ToVKSampleCount(sample_count);
64 desc.loadOp = ToVKAttachmentLoadOp(load_action);
65 desc.storeOp = ToVKAttachmentStoreOp(store_action, false);
66 desc.stencilLoadOp = desc.loadOp; // Not separable in Impeller.
67 desc.stencilStoreOp = desc.storeOp; // Not separable in Impeller.
68 desc.initialLayout = vk::ImageLayout::eUndefined;
69 desc.finalLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal;
70 depth_stencil_ = desc;
71 return *this;
72 }

References impeller::ToVKAttachmentLoadOp(), impeller::ToVKAttachmentStoreOp(), impeller::ToVKImageFormat(), and impeller::ToVKSampleCount().

Referenced by impeller::CreateCompatRenderPassForPipeline(), impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded(), and impeller::testing::TEST().

## ◆ SetStencilAttachment()

RenderPassBuilderVK & impeller::RenderPassBuilderVK::SetStencilAttachment | ( | PixelFormat | format,
|  | SampleCount | sample_count,
|  | LoadAction | load_action,
|  | StoreAction | store_action
| ) |  |

Definition at line 74 of file render_pass_builder_vk.cc.

78 {
79 vk::AttachmentDescription desc;
80 desc.format = ToVKImageFormat(format);
81 desc.samples = ToVKSampleCount(sample_count);
82 desc.loadOp = vk::AttachmentLoadOp::eDontCare;
83 desc.storeOp = vk::AttachmentStoreOp::eDontCare;
84 desc.stencilLoadOp = ToVKAttachmentLoadOp(load_action);
85 desc.stencilStoreOp = ToVKAttachmentStoreOp(store_action, false);
86 desc.initialLayout = vk::ImageLayout::eUndefined;
87 desc.finalLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal;
88 depth_stencil_ = desc;
89 return *this;
90 }

References impeller::ToVKAttachmentLoadOp(), impeller::ToVKAttachmentStoreOp(), impeller::ToVKImageFormat(), and impeller::ToVKSampleCount().

Referenced by impeller::CreateCompatRenderPassForPipeline(), impeller::ContextVK::InitializeCommonlyUsedShadersIfNeeded(), and impeller::testing::TEST().

The documentation for this class was generated from the following files:

- impeller/renderer/backend/vulkan/render_pass_builder_vk.h
- impeller/renderer/backend/vulkan/render_pass_builder_vk.cc

impeller::ToVKSampleCount
constexpr vk::SampleCountFlagBits ToVKSampleCount(SampleCount sample_count)
Definition: formats_vk.h:201
impeller::kSelfDependencyDstAccessMask
constexpr auto kSelfDependencyDstAccessMask
Definition: render_pass_builder_vk.cc:20
impeller::kSelfDependencySrcStageMask
constexpr auto kSelfDependencySrcStageMask
Definition: render_pass_builder_vk.cc:13
impeller::kSelfDependencyFlags
constexpr auto kSelfDependencyFlags
Definition: render_pass_builder_vk.cc:23
impeller::ToVKAttachmentStoreOp
constexpr vk::AttachmentStoreOp ToVKAttachmentStoreOp(StoreAction store_action, bool is_resolve_texture)
Definition: formats_vk.h:313
impeller::ToVKImageFormat
constexpr vk::Format ToVKImageFormat(PixelFormat format)
Definition: formats_vk.h:133
impeller::kSelfDependencyDstStageMask
constexpr auto kSelfDependencyDstStageMask
Definition: render_pass_builder_vk.cc:18
impeller::ToVKAttachmentLoadOp
constexpr vk::AttachmentLoadOp ToVKAttachmentLoadOp(LoadAction load_action)
Definition: formats_vk.h:300
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
impeller::kUnusedAttachmentReference
static constexpr vk::AttachmentReference kUnusedAttachmentReference
Definition: formats_vk.h:415
color
DlColor color
Definition: dl_golden_blur_unittests.cc:23
impeller::kSelfDependencySrcAccessMask
constexpr auto kSelfDependencySrcAccessMask
Definition: render_pass_builder_vk.cc:15
impeller::StoreActionPerformsResolve
constexpr bool StoreActionPerformsResolve(StoreAction store_action)
Definition: formats_vk.h:337