From 996a1ffb326ef5a0b52f851e1dd6389cc1b66f4a Mon Sep 17 00:00:00 2001
From: Simeon Hermann <shermann04@uni-koblenz.de>
Date: Tue, 8 Jun 2021 17:07:37 +0200
Subject: [PATCH] [#36] add names of the reflected vertex inputs

---
 include/vkcv/VertexLayout.hpp |  4 +++-
 src/vkcv/ShaderProgram.cpp    | 12 ++++++------
 src/vkcv/VertexLayout.cpp     |  3 ++-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/vkcv/VertexLayout.hpp b/include/vkcv/VertexLayout.hpp
index ee0ad8ef..aae43910 100644
--- a/include/vkcv/VertexLayout.hpp
+++ b/include/vkcv/VertexLayout.hpp
@@ -3,6 +3,7 @@
 #include <unordered_map>
 #include <vector>
 #include <iostream>
+#include <string>
 
 namespace vkcv{
 
@@ -38,10 +39,11 @@ namespace vkcv{
 
     struct VertexInputAttachment{
         VertexInputAttachment() = delete;
-        VertexInputAttachment(uint32_t location, uint32_t binding, VertexFormat format, uint32_t offset) noexcept;
+        VertexInputAttachment(uint32_t location, uint32_t binding, std::string name, VertexFormat format, uint32_t offset) noexcept;
 
         uint32_t location;
         uint32_t binding;
+        std::string name;
         VertexFormat format;
         uint32_t offset;
     };
diff --git a/src/vkcv/ShaderProgram.cpp b/src/vkcv/ShaderProgram.cpp
index 59f8163c..0a3ce87b 100644
--- a/src/vkcv/ShaderProgram.cpp
+++ b/src/vkcv/ShaderProgram.cpp
@@ -119,9 +119,9 @@ namespace vkcv {
 			for (uint32_t i = 0; i < resources.stage_inputs.size(); i++) {
 				auto& u = resources.stage_inputs[i];
 				const spirv_cross::SPIRType& base_type = comp.get_type(u.base_type_id);
-
 				VertexInputAttachment input = VertexInputAttachment(comp.get_decoration(u.id, spv::DecorationLocation),
 					0,
+                    u.name,
 					convertFormat(base_type.basetype, base_type.vecsize),
 					offset);
 				inputVec.push_back(input);
@@ -133,10 +133,10 @@ namespace vkcv {
 		//Descriptor Sets
 		//Storage buffer, uniform Buffer, storage image, sampled image, sampler (?)
 
-        std::vector<uint32_t> sampledImageVec;
-        for (uint32_t i = 0; i < resources.sampled_images.size(); i++) {
-            auto &u = resources.sampled_images[i];
-            sampledImageVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
+        std::vector<uint32_t> separateImageVec;
+        for (uint32_t i = 0; i < resources.separate_images.size(); i++) {
+            auto &u = resources.separate_images[i];
+            separateImageVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
         }
 
         std::vector<uint32_t> storageImageVec;
@@ -163,7 +163,7 @@ namespace vkcv {
             samplerVec.push_back(comp.get_decoration(u.id, spv::DecorationDescriptorSet));
         }
 
-        m_DescriptorSetLayout = DescriptorSetLayout(sampledImageVec, storageImageVec, uniformBufferVec, storageBufferVec, samplerVec);
+        m_DescriptorSetLayout = DescriptorSetLayout(separateImageVec, storageImageVec, uniformBufferVec, storageBufferVec, samplerVec);
 
 		for (const auto &pushConstantBuffer : resources.push_constant_buffers) {
 			for (const auto &range : comp.get_active_buffer_ranges(pushConstantBuffer.id)) {
diff --git a/src/vkcv/VertexLayout.cpp b/src/vkcv/VertexLayout.cpp
index b06c6743..3a524d97 100644
--- a/src/vkcv/VertexLayout.cpp
+++ b/src/vkcv/VertexLayout.cpp
@@ -30,9 +30,10 @@ namespace vkcv {
         return 0;
     }
 
-    VertexInputAttachment::VertexInputAttachment(uint32_t location, uint32_t binding, VertexFormat format, uint32_t offset) noexcept:
+    VertexInputAttachment::VertexInputAttachment(uint32_t location, uint32_t binding, std::string name, VertexFormat format, uint32_t offset) noexcept:
             location{location},
             binding{binding},
+            name{name},
             format{format},
             offset{offset}
             {}
-- 
GitLab