| 325 | |
| 326 | template <typename T_SubpassDescription, typename T_AttachmentDescription, typename T_AttachmentReference, typename T_SubpassDependency, typename T_RenderPassCreateInfo> |
| 327 | void RenderPass::create_renderpass(const std::vector<vkb::rendering::AttachmentC> &attachments, const std::vector<LoadStoreInfo> &load_store_infos, const std::vector<SubpassInfo> &subpasses) |
| 328 | { |
| 329 | if (attachments.size() != load_store_infos.size()) |
| 330 | { |
| 331 | LOGW("Render Pass creation: size of attachment list and load/store info list does not match: {} vs {}", attachments.size(), load_store_infos.size()); |
| 332 | } |
| 333 | |
| 334 | auto attachment_descriptions = get_attachment_descriptions<T_AttachmentDescription>(attachments, load_store_infos); |
| 335 | |
| 336 | // Store attachments for every subpass |
| 337 | std::vector<std::vector<T_AttachmentReference>> input_attachments{subpass_count}; |
| 338 | std::vector<std::vector<T_AttachmentReference>> color_attachments{subpass_count}; |
| 339 | std::vector<std::vector<T_AttachmentReference>> depth_stencil_attachments{subpass_count}; |
| 340 | std::vector<std::vector<T_AttachmentReference>> color_resolve_attachments{subpass_count}; |
| 341 | std::vector<std::vector<T_AttachmentReference>> depth_resolve_attachments{subpass_count}; |
| 342 | |
| 343 | std::string new_debug_name{}; |
| 344 | const bool needs_debug_name = get_debug_name().empty(); |
| 345 | if (needs_debug_name) |
| 346 | { |
| 347 | new_debug_name = fmt::format("RP with {} subpasses:\n", subpasses.size()); |
| 348 | } |
| 349 | |
| 350 | for (size_t i = 0; i < subpasses.size(); ++i) |
| 351 | { |
| 352 | auto &subpass = subpasses[i]; |
| 353 | |
| 354 | if (needs_debug_name) |
| 355 | { |
| 356 | new_debug_name += fmt::format("\t[{}]: {}\n", i, subpass.debug_name); |
| 357 | } |
| 358 | |
| 359 | // Fill color attachments references |
| 360 | for (auto o_attachment : subpass.output_attachments) |
| 361 | { |
| 362 | auto initial_layout = attachments[o_attachment].initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : attachments[o_attachment].initial_layout; |
| 363 | auto &description = attachment_descriptions[o_attachment]; |
| 364 | if (!is_depth_format(description.format)) |
| 365 | { |
| 366 | color_attachments[i].push_back(get_attachment_reference<T_AttachmentReference>(o_attachment, initial_layout)); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | // Fill input attachments references |
| 371 | for (auto i_attachment : subpass.input_attachments) |
| 372 | { |
| 373 | auto initial_layout = vkb::is_depth_format(attachments[i_attachment].format) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 374 | input_attachments[i].push_back(get_attachment_reference<T_AttachmentReference>(i_attachment, initial_layout)); |
| 375 | } |
| 376 | |
| 377 | for (auto r_attachment : subpass.color_resolve_attachments) |
| 378 | { |
| 379 | auto initial_layout = attachments[r_attachment].initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : attachments[r_attachment].initial_layout; |
| 380 | color_resolve_attachments[i].push_back(get_attachment_reference<T_AttachmentReference>(r_attachment, initial_layout)); |
| 381 | } |
| 382 | |
| 383 | if (!subpass.disable_depth_stencil_attachment) |
| 384 | { |
nothing calls this directly
no test coverage detected