From f402639c8f1dfac0a25f145c607abb0d4761a1ac Mon Sep 17 00:00:00 2001
From: Alexander Gauggel <agauggel@uni-koblenz.de>
Date: Sun, 30 May 2021 11:57:27 +0200
Subject: [PATCH] [#52] Add check to only reflect vertex input when reflecting
 vertex shader

---
 src/vkcv/ShaderProgram.cpp | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/vkcv/ShaderProgram.cpp b/src/vkcv/ShaderProgram.cpp
index dabd5ab1..5185b8b4 100644
--- a/src/vkcv/ShaderProgram.cpp
+++ b/src/vkcv/ShaderProgram.cpp
@@ -110,22 +110,24 @@ namespace vkcv {
         spirv_cross::Compiler comp(move(shaderCode));
         spirv_cross::ShaderResources resources = comp.get_shader_resources();
 
-        std::vector<VertexInputAttachment> inputVec;
-        uint32_t offset = 0;
-
-        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,
-                                                                convertFormat(base_type.basetype, base_type.vecsize),
-                                                                offset);
-            inputVec.push_back(input);
-            offset += base_type.vecsize * base_type.width/8;
-        }
-
-        m_VertexLayout = VertexLayout(inputVec);
+		if (shaderStage == ShaderStage::VERTEX) {
+			std::vector<VertexInputAttachment> inputVec;
+			uint32_t offset = 0;
+
+			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,
+					convertFormat(base_type.basetype, base_type.vecsize),
+					offset);
+				inputVec.push_back(input);
+				offset += base_type.vecsize * base_type.width / 8;
+			}
+
+			m_VertexLayout = VertexLayout(inputVec);
+		}
     }
 
     const VertexLayout& ShaderProgram::getVertexLayout() const{
-- 
GitLab