93 {
94
95
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,
103 std::vector<vk::AttachmentReference> resolve_refs(color_attachments_count,
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;
138 self_dep.dstSubpass = 0u;
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) {
153 return {};
154 }
155 return std::move(pass);
156}
static constexpr vk::AttachmentReference kUnusedAttachmentReference
constexpr auto kSelfDependencyDstAccessMask
constexpr auto kSelfDependencySrcAccessMask
constexpr auto kSelfDependencySrcStageMask
constexpr auto kSelfDependencyDstStageMask
constexpr auto kSelfDependencyFlags
static SkString to_string(int n)