From b4ea70f5ef1ab4fa0bb75be065b76aea4d643279 Mon Sep 17 00:00:00 2001
From: Alexander Gauggel <agauggel@uni-koblenz.de>
Date: Sun, 16 May 2021 11:21:23 +0200
Subject: [PATCH] [18]fix renderpass creation validation error if no depth pass
 is used

---
 src/vkcv/Core.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/vkcv/Core.cpp b/src/vkcv/Core.cpp
index bc316d68..2756cbc7 100644
--- a/src/vkcv/Core.cpp
+++ b/src/vkcv/Core.cpp
@@ -575,6 +575,7 @@ namespace vkcv
         std::vector<vk::AttachmentReference> colorAttachmentReferences{};
         // individual reference to depth attachment (of a subpass)
         vk::AttachmentReference depthAttachmentReference{};
+		vk::AttachmentReference *pDepthAttachment = nullptr;	//stays nullptr if no depth attachment used
 
         for(uint32_t i = 0; i < pass.attachments.size(); i++)
         {
@@ -587,6 +588,7 @@ namespace vkcv
 
                 depthAttachmentReference.attachment = i;
                 depthAttachmentReference.layout = getVkLayoutFromAttachLayout(pass.attachments[i].layout_in_pass);
+				pDepthAttachment = &depthAttachmentReference;
             }
             else
             {
@@ -608,15 +610,15 @@ namespace vkcv
         }
 
         vk::SubpassDescription subpassDescription({},
-                                           vk::PipelineBindPoint::eGraphics,
-                                           0,
-                                           {},
-                                           static_cast<uint32_t>(colorAttachmentReferences.size()),
-                                           colorAttachmentReferences.data(),
-                                           {},
-                                           &depthAttachmentReference,
-                                           0,
-                                           {});
+			vk::PipelineBindPoint::eGraphics,
+			0,
+			{},
+			static_cast<uint32_t>(colorAttachmentReferences.size()),
+			colorAttachmentReferences.data(),
+			{},
+			pDepthAttachment,
+			0,
+			{});
 
         vk::RenderPassCreateInfo passInfo({},
                                           static_cast<uint32_t>(attachmentDescriptions.size()),
-- 
GitLab