Jeremy Gebben | 610d3a6 | 2022-01-01 12:53:17 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2022 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2022 Valve Corporation |
| 3 | * Copyright (c) 2015-2022 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2022 Google Inc. |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 5 | * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * |
| 19 | * Author: Courtney Goeltzenleuchter <courtneygo@google.com> |
| 20 | * Author: Tobin Ehlis <tobine@google.com> |
| 21 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 22 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 23 | * Author: Dave Houlton <daveh@lunarg.com> |
| 24 | * Author: John Zulauf <jzulauf@lunarg.com> |
| 25 | * Author: Tobias Hector <tobias.hector@amd.com> |
| 26 | * Author: Jeremy Gebben <jeremyg@lunarg.com> |
| 27 | */ |
| 28 | #include "render_pass_state.h" |
| 29 | #include "convert_to_renderpass2.h" |
| 30 | #include "image_state.h" |
| 31 | |
| 32 | static const VkImageLayout kInvalidLayout = VK_IMAGE_LAYOUT_MAX_ENUM; |
| 33 | |
John Zulauf | bdcc9c6 | 2021-10-01 14:57:26 -0600 | [diff] [blame] | 34 | static VkSubpassDependency2 ImplicitDependencyFromExternal(uint32_t subpass) { |
| 35 | VkSubpassDependency2 from_external = {VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2, |
| 36 | nullptr, |
| 37 | VK_SUBPASS_EXTERNAL, |
| 38 | subpass, |
| 39 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, |
| 40 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 41 | 0, |
| 42 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | |
| 43 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | |
| 44 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, |
| 45 | 0, |
| 46 | 0}; |
| 47 | return from_external; |
| 48 | } |
| 49 | |
| 50 | static VkSubpassDependency2 ImplicitDependencyToExternal(uint32_t subpass) { |
| 51 | VkSubpassDependency2 to_external = {VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2, |
| 52 | nullptr, |
| 53 | subpass, |
| 54 | VK_SUBPASS_EXTERNAL, |
| 55 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 56 | VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, |
| 57 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | |
| 58 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | |
| 59 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, |
| 60 | 0, |
| 61 | 0, |
| 62 | 0}; |
| 63 | return to_external; |
| 64 | } |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 65 | // NOTE: The functions below are only called from the RENDER_PASS_STATE constructor, and use const_cast<> to set up |
| 66 | // members that never change after construction is finished. |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 67 | static void RecordRenderPassDAG(const VkRenderPassCreateInfo2 *pCreateInfo, RENDER_PASS_STATE *render_pass) { |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 68 | auto &subpass_to_node = const_cast<RENDER_PASS_STATE::DAGNodeVec &>(render_pass->subpass_to_node); |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 69 | subpass_to_node.resize(pCreateInfo->subpassCount); |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 70 | auto &self_dependencies = const_cast<RENDER_PASS_STATE::SelfDepVec &>(render_pass->self_dependencies); |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 71 | self_dependencies.resize(pCreateInfo->subpassCount); |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 72 | auto &subpass_dependencies = const_cast<RENDER_PASS_STATE::SubpassGraphVec &>(render_pass->subpass_dependencies); |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 73 | subpass_dependencies.resize(pCreateInfo->subpassCount); |
| 74 | |
| 75 | for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { |
| 76 | subpass_to_node[i].pass = i; |
| 77 | self_dependencies[i].clear(); |
| 78 | subpass_dependencies[i].pass = i; |
| 79 | } |
| 80 | for (uint32_t i = 0; i < pCreateInfo->dependencyCount; ++i) { |
| 81 | const auto &dependency = pCreateInfo->pDependencies[i]; |
| 82 | const auto src_subpass = dependency.srcSubpass; |
| 83 | const auto dst_subpass = dependency.dstSubpass; |
| 84 | if ((dependency.srcSubpass != VK_SUBPASS_EXTERNAL) && (dependency.dstSubpass != VK_SUBPASS_EXTERNAL)) { |
| 85 | if (dependency.srcSubpass == dependency.dstSubpass) { |
| 86 | self_dependencies[dependency.srcSubpass].push_back(i); |
| 87 | } else { |
| 88 | subpass_to_node[dependency.dstSubpass].prev.push_back(dependency.srcSubpass); |
| 89 | subpass_to_node[dependency.srcSubpass].next.push_back(dependency.dstSubpass); |
| 90 | } |
| 91 | } |
| 92 | if (src_subpass == VK_SUBPASS_EXTERNAL) { |
| 93 | assert(dst_subpass != VK_SUBPASS_EXTERNAL); // this is invalid per VUID-VkSubpassDependency-srcSubpass-00865 |
| 94 | subpass_dependencies[dst_subpass].barrier_from_external.emplace_back(&dependency); |
| 95 | } else if (dst_subpass == VK_SUBPASS_EXTERNAL) { |
| 96 | subpass_dependencies[src_subpass].barrier_to_external.emplace_back(&dependency); |
| 97 | } else if (dependency.srcSubpass != dependency.dstSubpass) { |
| 98 | // ignore self dependencies in prev and next |
| 99 | subpass_dependencies[src_subpass].next[&subpass_dependencies[dst_subpass]].emplace_back(&dependency); |
| 100 | subpass_dependencies[dst_subpass].prev[&subpass_dependencies[src_subpass]].emplace_back(&dependency); |
| 101 | } |
| 102 | } |
| 103 | |
John Zulauf | bdcc9c6 | 2021-10-01 14:57:26 -0600 | [diff] [blame] | 104 | // If no barriers to external are provided for a given subpass, add them. |
| 105 | for (auto &subpass_dep : subpass_dependencies) { |
| 106 | const uint32_t pass = subpass_dep.pass; |
| 107 | if (subpass_dep.barrier_from_external.size() == 0) { |
| 108 | // Add implicit from barrier if they're aren't any |
| 109 | subpass_dep.implicit_barrier_from_external = |
| 110 | layer_data::make_unique<VkSubpassDependency2>(ImplicitDependencyFromExternal(pass)); |
| 111 | subpass_dep.barrier_from_external.emplace_back(subpass_dep.implicit_barrier_from_external.get()); |
| 112 | } |
| 113 | if (subpass_dep.barrier_to_external.size() == 0) { |
| 114 | // Add implicit to barrier if they're aren't any |
| 115 | subpass_dep.implicit_barrier_to_external = |
| 116 | layer_data::make_unique<VkSubpassDependency2>(ImplicitDependencyToExternal(pass)); |
| 117 | subpass_dep.barrier_to_external.emplace_back(subpass_dep.implicit_barrier_to_external.get()); |
| 118 | } |
| 119 | } |
| 120 | |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 121 | // |
| 122 | // Determine "asynchrononous" subpassess |
| 123 | // syncronization is only interested in asyncronous stages *earlier* that the current one... so we'll only look towards those. |
| 124 | // NOTE: This is O(N^3), which we could shrink to O(N^2logN) using sets instead of arrays, but given that N is likely to be |
| 125 | // small and the K for |= from the prev is must less than for set, we'll accept the brute force. |
| 126 | std::vector<std::vector<bool>> pass_depends(pCreateInfo->subpassCount); |
| 127 | for (uint32_t i = 1; i < pCreateInfo->subpassCount; ++i) { |
| 128 | auto &depends = pass_depends[i]; |
| 129 | depends.resize(i); |
| 130 | auto &subpass_dep = subpass_dependencies[i]; |
| 131 | for (const auto &prev : subpass_dep.prev) { |
| 132 | const auto prev_pass = prev.first->pass; |
| 133 | const auto &prev_depends = pass_depends[prev_pass]; |
| 134 | for (uint32_t j = 0; j < prev_pass; j++) { |
Nico Weber | 5127939 | 2021-10-08 11:19:55 -0400 | [diff] [blame] | 135 | depends[j] = depends[j] || prev_depends[j]; |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 136 | } |
| 137 | depends[prev_pass] = true; |
| 138 | } |
| 139 | for (uint32_t pass = 0; pass < subpass_dep.pass; pass++) { |
| 140 | if (!depends[pass]) { |
| 141 | subpass_dep.async.push_back(pass); |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 147 | struct AttachmentTracker { // This is really only of local interest, but a bit big for a lambda |
| 148 | RENDER_PASS_STATE *const rp; |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 149 | RENDER_PASS_STATE::SubpassVec &first; |
| 150 | RENDER_PASS_STATE::FirstIsTransitionVec &first_is_transition; |
| 151 | RENDER_PASS_STATE::SubpassVec &last; |
| 152 | RENDER_PASS_STATE::TransitionVec &subpass_transitions; |
| 153 | RENDER_PASS_STATE::FirstReadMap &first_read; |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 154 | const uint32_t attachment_count; |
| 155 | std::vector<VkImageLayout> attachment_layout; |
| 156 | std::vector<std::vector<VkImageLayout>> subpass_attachment_layout; |
| 157 | explicit AttachmentTracker(RENDER_PASS_STATE *render_pass) |
| 158 | : rp(render_pass), |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 159 | first(const_cast<RENDER_PASS_STATE::SubpassVec &>(rp->attachment_first_subpass)), |
| 160 | first_is_transition(const_cast<RENDER_PASS_STATE::FirstIsTransitionVec &>(rp->attachment_first_is_transition)), |
| 161 | last(const_cast<RENDER_PASS_STATE::SubpassVec &>(rp->attachment_last_subpass)), |
| 162 | subpass_transitions(const_cast<RENDER_PASS_STATE::TransitionVec &>(rp->subpass_transitions)), |
| 163 | first_read(const_cast<RENDER_PASS_STATE::FirstReadMap &>(rp->attachment_first_read)), |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 164 | attachment_count(rp->createInfo.attachmentCount), |
| 165 | attachment_layout(), |
| 166 | subpass_attachment_layout() { |
| 167 | first.resize(attachment_count, VK_SUBPASS_EXTERNAL); |
| 168 | first_is_transition.resize(attachment_count, false); |
| 169 | last.resize(attachment_count, VK_SUBPASS_EXTERNAL); |
| 170 | subpass_transitions.resize(rp->createInfo.subpassCount + 1); // Add an extra for EndRenderPass |
| 171 | attachment_layout.reserve(attachment_count); |
| 172 | subpass_attachment_layout.resize(rp->createInfo.subpassCount); |
| 173 | for (auto &subpass_layouts : subpass_attachment_layout) { |
| 174 | subpass_layouts.resize(attachment_count, kInvalidLayout); |
| 175 | } |
| 176 | |
| 177 | for (uint32_t j = 0; j < attachment_count; j++) { |
| 178 | attachment_layout.push_back(rp->createInfo.pAttachments[j].initialLayout); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | void Update(uint32_t subpass, const VkAttachmentReference2 *attach_ref, uint32_t count, bool is_read) { |
| 183 | if (nullptr == attach_ref) return; |
| 184 | for (uint32_t j = 0; j < count; ++j) { |
| 185 | const auto attachment = attach_ref[j].attachment; |
| 186 | if (attachment != VK_ATTACHMENT_UNUSED) { |
| 187 | const auto layout = attach_ref[j].layout; |
| 188 | // Take advantage of the fact that insert won't overwrite, so we'll only write the first time. |
| 189 | first_read.emplace(attachment, is_read); |
| 190 | if (first[attachment] == VK_SUBPASS_EXTERNAL) { |
| 191 | first[attachment] = subpass; |
| 192 | const auto initial_layout = rp->createInfo.pAttachments[attachment].initialLayout; |
| 193 | if (initial_layout != layout) { |
| 194 | subpass_transitions[subpass].emplace_back(VK_SUBPASS_EXTERNAL, attachment, initial_layout, layout); |
| 195 | first_is_transition[attachment] = true; |
| 196 | } |
| 197 | } |
| 198 | last[attachment] = subpass; |
| 199 | |
| 200 | for (const auto &prev : rp->subpass_dependencies[subpass].prev) { |
| 201 | const auto prev_pass = prev.first->pass; |
| 202 | const auto prev_layout = subpass_attachment_layout[prev_pass][attachment]; |
| 203 | if ((prev_layout != kInvalidLayout) && (prev_layout != layout)) { |
| 204 | subpass_transitions[subpass].emplace_back(prev_pass, attachment, prev_layout, layout); |
| 205 | } |
| 206 | } |
| 207 | attachment_layout[attachment] = layout; |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | void FinalTransitions() { |
| 212 | auto &final_transitions = subpass_transitions[rp->createInfo.subpassCount]; |
| 213 | |
| 214 | for (uint32_t attachment = 0; attachment < attachment_count; ++attachment) { |
| 215 | const auto final_layout = rp->createInfo.pAttachments[attachment].finalLayout; |
| 216 | // Add final transitions for attachments that were used and change layout. |
| 217 | if ((last[attachment] != VK_SUBPASS_EXTERNAL) && final_layout != attachment_layout[attachment]) { |
| 218 | final_transitions.emplace_back(last[attachment], attachment, attachment_layout[attachment], final_layout); |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | }; |
| 223 | |
| 224 | static void InitRenderPassState(RENDER_PASS_STATE *render_pass) { |
| 225 | auto create_info = render_pass->createInfo.ptr(); |
| 226 | |
| 227 | RecordRenderPassDAG(create_info, render_pass); |
| 228 | |
| 229 | AttachmentTracker attachment_tracker(render_pass); |
| 230 | |
| 231 | for (uint32_t subpass_index = 0; subpass_index < create_info->subpassCount; ++subpass_index) { |
| 232 | const VkSubpassDescription2 &subpass = create_info->pSubpasses[subpass_index]; |
| 233 | attachment_tracker.Update(subpass_index, subpass.pColorAttachments, subpass.colorAttachmentCount, false); |
| 234 | attachment_tracker.Update(subpass_index, subpass.pResolveAttachments, subpass.colorAttachmentCount, false); |
| 235 | attachment_tracker.Update(subpass_index, subpass.pDepthStencilAttachment, 1, false); |
| 236 | attachment_tracker.Update(subpass_index, subpass.pInputAttachments, subpass.inputAttachmentCount, true); |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 237 | |
| 238 | // From the spec |
| 239 | // If the VkSubpassDescription2::viewMask member of any element of pSubpasses is not zero, multiview functionality is |
| 240 | // considered to be enabled for this render pass. |
| 241 | (*const_cast<bool *>(&render_pass->has_multiview_enabled)) |= (subpass.viewMask != 0); |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 242 | } |
| 243 | attachment_tracker.FinalTransitions(); |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | RENDER_PASS_STATE::RENDER_PASS_STATE(VkRenderPass rp, VkRenderPassCreateInfo2 const *pCreateInfo) |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 247 | : BASE_NODE(rp, kVulkanObjectTypeRenderPass), |
| 248 | use_dynamic_rendering(false), |
| 249 | use_dynamic_rendering_inherited(false), |
| 250 | has_multiview_enabled(false), |
| 251 | createInfo(pCreateInfo) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 252 | InitRenderPassState(this); |
| 253 | } |
| 254 | |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 255 | static safe_VkRenderPassCreateInfo2 ConvertCreateInfo(const VkRenderPassCreateInfo &create_info) { |
| 256 | safe_VkRenderPassCreateInfo2 create_info_2; |
| 257 | ConvertVkRenderPassCreateInfoToV2KHR(create_info, &create_info_2); |
| 258 | return create_info_2; |
| 259 | } |
| 260 | |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 261 | RENDER_PASS_STATE::RENDER_PASS_STATE(VkRenderPass rp, VkRenderPassCreateInfo const *pCreateInfo) |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 262 | : BASE_NODE(rp, kVulkanObjectTypeRenderPass), |
| 263 | use_dynamic_rendering(false), |
| 264 | use_dynamic_rendering_inherited(false), |
| 265 | has_multiview_enabled(false), |
| 266 | createInfo(ConvertCreateInfo(*pCreateInfo)) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 267 | InitRenderPassState(this); |
| 268 | } |
| 269 | |
Tony-LunarG | 40b3388 | 2021-12-02 12:40:11 -0700 | [diff] [blame] | 270 | const VkPipelineRenderingCreateInfo VkPipelineRenderingCreateInfo_default = { |
| 271 | VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO, |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 272 | nullptr, |
| 273 | 0, |
| 274 | 0, |
| 275 | nullptr, |
| 276 | VK_FORMAT_UNDEFINED, |
| 277 | VK_FORMAT_UNDEFINED |
| 278 | }; |
| 279 | |
Tony-LunarG | 40b3388 | 2021-12-02 12:40:11 -0700 | [diff] [blame] | 280 | RENDER_PASS_STATE::RENDER_PASS_STATE(VkPipelineRenderingCreateInfo const *pPipelineRenderingCreateInfo) |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 281 | : BASE_NODE(static_cast<VkRenderPass>(VK_NULL_HANDLE), kVulkanObjectTypeRenderPass), |
| 282 | use_dynamic_rendering(true), |
| 283 | use_dynamic_rendering_inherited(false), |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 284 | has_multiview_enabled(false), |
Aaron Hagan | 92a44f8 | 2021-11-19 09:34:56 -0500 | [diff] [blame] | 285 | dynamic_rendering_pipeline_create_info(pPipelineRenderingCreateInfo ? pPipelineRenderingCreateInfo |
Tony-LunarG | 40b3388 | 2021-12-02 12:40:11 -0700 | [diff] [blame] | 286 | : &VkPipelineRenderingCreateInfo_default) {} |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 287 | |
Jeremy Gebben | 11af979 | 2021-08-20 10:20:09 -0600 | [diff] [blame] | 288 | bool RENDER_PASS_STATE::UsesColorAttachment(uint32_t subpass_num) const { |
| 289 | bool result = false; |
| 290 | |
| 291 | if (subpass_num < createInfo.subpassCount) { |
| 292 | const auto &subpass = createInfo.pSubpasses[subpass_num]; |
| 293 | |
| 294 | for (uint32_t i = 0; i < subpass.colorAttachmentCount; ++i) { |
| 295 | if (subpass.pColorAttachments[i].attachment != VK_ATTACHMENT_UNUSED) { |
| 296 | result = true; |
| 297 | break; |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | return result; |
| 302 | } |
| 303 | |
| 304 | bool RENDER_PASS_STATE::UsesDepthStencilAttachment(uint32_t subpass_num) const { |
| 305 | bool result = false; |
| 306 | if (subpass_num < createInfo.subpassCount) { |
| 307 | const auto &subpass = createInfo.pSubpasses[subpass_num]; |
| 308 | if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { |
| 309 | result = true; |
| 310 | } |
| 311 | } |
| 312 | return result; |
| 313 | } |
| 314 | |
Tony-LunarG | 40b3388 | 2021-12-02 12:40:11 -0700 | [diff] [blame] | 315 | RENDER_PASS_STATE::RENDER_PASS_STATE(VkRenderingInfo const *pRenderingInfo) |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 316 | : BASE_NODE(static_cast<VkRenderPass>(VK_NULL_HANDLE), kVulkanObjectTypeRenderPass), |
| 317 | use_dynamic_rendering(true), |
| 318 | use_dynamic_rendering_inherited(false), |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 319 | has_multiview_enabled(false), |
Aaron Hagan | 92a44f8 | 2021-11-19 09:34:56 -0500 | [diff] [blame] | 320 | dynamic_rendering_begin_rendering_info(pRenderingInfo) {} |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 321 | |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 322 | RENDER_PASS_STATE::RENDER_PASS_STATE(VkCommandBufferInheritanceRenderingInfo const *pInheritanceRenderingInfo) |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 323 | : BASE_NODE(static_cast<VkRenderPass>(VK_NULL_HANDLE), kVulkanObjectTypeRenderPass), |
aitor-lunarg | a131fca | 2022-02-17 22:55:55 +0100 | [diff] [blame^] | 324 | use_dynamic_rendering(false), |
| 325 | use_dynamic_rendering_inherited(true), |
| 326 | has_multiview_enabled(false), |
| 327 | inheritance_rendering_info(pInheritanceRenderingInfo) {} |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 328 | |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 329 | FRAMEBUFFER_STATE::FRAMEBUFFER_STATE(VkFramebuffer fb, const VkFramebufferCreateInfo *pCreateInfo, |
| 330 | std::shared_ptr<RENDER_PASS_STATE> &&rpstate, |
| 331 | std::vector<std::shared_ptr<IMAGE_VIEW_STATE>> &&attachments) |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 332 | : BASE_NODE(fb, kVulkanObjectTypeFramebuffer), |
| 333 | createInfo(pCreateInfo), |
| 334 | rp_state(rpstate), |
Jeremy Gebben | 610d3a6 | 2022-01-01 12:53:17 -0700 | [diff] [blame] | 335 | attachments_view_state(std::move(attachments)) {} |
| 336 | |
| 337 | void FRAMEBUFFER_STATE::LinkChildNodes() { |
| 338 | // Connect child node(s), which cannot safely be done in the constructor. |
Jeremy Gebben | e83bd44 | 2021-09-02 11:18:03 -0600 | [diff] [blame] | 339 | for (auto &a : attachments_view_state) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 340 | a->AddParent(this); |
| 341 | } |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | void FRAMEBUFFER_STATE::Destroy() { |
amhagan | a448ea5 | 2021-11-02 14:09:14 -0400 | [diff] [blame] | 345 | for (auto &view : attachments_view_state) { |
Jeremy Gebben | 88f5814 | 2021-06-01 10:07:52 -0600 | [diff] [blame] | 346 | view->RemoveParent(this); |
| 347 | } |
| 348 | attachments_view_state.clear(); |
| 349 | BASE_NODE::Destroy(); |
| 350 | } |