From 8363c9c19b11e380e40843fdbdedd324eb50158a Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Tue, 28 Sep 2021 17:01:56 +0200
Subject: [PATCH] [#105] Fixed attribute order by sorting

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 projects/indirect_draw/src/main.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/projects/indirect_draw/src/main.cpp b/projects/indirect_draw/src/main.cpp
index 2514145d..45de9ad0 100644
--- a/projects/indirect_draw/src/main.cpp
+++ b/projects/indirect_draw/src/main.cpp
@@ -93,6 +93,13 @@ void interleaveScene(vkcv::asset::Scene scene,
     {
         for(auto vertexGroupIndex : mesh.vertexGroups)
         {
+			// Sort attributes to fix it!
+			auto& attributes = scene.vertexGroups[vertexGroupIndex].vertexBuffer.attributes;
+	
+			std::sort(attributes.begin(), attributes.end(), [](const vkcv::asset::VertexAttribute& x, const vkcv::asset::VertexAttribute& y) {
+				return static_cast<uint32_t>(x.type) < static_cast<uint32_t>(y.type);
+			});
+			
             const auto &vertexGroup = scene.vertexGroups[vertexGroupIndex];
 
             const vkcv::asset::VertexAttribute positionAttribute = vertexGroup.vertexBuffer.attributes[0];
-- 
GitLab