| 140 | |
| 141 | template <typename T_SubpassDescription, typename T_AttachmentDescription, typename T_AttachmentReference> |
| 142 | void set_attachment_layouts(std::vector<T_SubpassDescription> &subpass_descriptions, std::vector<T_AttachmentDescription> &attachment_descriptions) |
| 143 | { |
| 144 | // Make the initial layout same as in the first subpass using that attachment |
| 145 | for (auto &subpass : subpass_descriptions) |
| 146 | { |
| 147 | for (size_t k = 0U; k < subpass.colorAttachmentCount; ++k) |
| 148 | { |
| 149 | auto &reference = subpass.pColorAttachments[k]; |
| 150 | // Set it only if not defined yet |
| 151 | if (attachment_descriptions[reference.attachment].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) |
| 152 | { |
| 153 | attachment_descriptions[reference.attachment].initialLayout = reference.layout; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | for (size_t k = 0U; k < subpass.inputAttachmentCount; ++k) |
| 158 | { |
| 159 | auto &reference = subpass.pInputAttachments[k]; |
| 160 | // Set it only if not defined yet |
| 161 | if (attachment_descriptions[reference.attachment].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) |
| 162 | { |
| 163 | attachment_descriptions[reference.attachment].initialLayout = reference.layout; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (subpass.pDepthStencilAttachment) |
| 168 | { |
| 169 | auto &reference = *subpass.pDepthStencilAttachment; |
| 170 | // Set it only if not defined yet |
| 171 | if (attachment_descriptions[reference.attachment].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) |
| 172 | { |
| 173 | attachment_descriptions[reference.attachment].initialLayout = reference.layout; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if (subpass.pResolveAttachments) |
| 178 | { |
| 179 | for (size_t k = 0U; k < subpass.colorAttachmentCount; ++k) |
| 180 | { |
| 181 | auto &reference = subpass.pResolveAttachments[k]; |
| 182 | // Set it only if not defined yet |
| 183 | if (attachment_descriptions[reference.attachment].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) |
| 184 | { |
| 185 | attachment_descriptions[reference.attachment].initialLayout = reference.layout; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | if (const auto depth_resolve = get_depth_resolve_reference(subpass)) |
| 191 | { |
| 192 | // Set it only if not defined yet |
| 193 | if (attachment_descriptions[depth_resolve->attachment].initialLayout == VK_IMAGE_LAYOUT_UNDEFINED) |
| 194 | { |
| 195 | attachment_descriptions[depth_resolve->attachment].initialLayout = depth_resolve->layout; |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 |
nothing calls this directly
no test coverage detected