From 7412be6aa6ad8246303ab6f85ed65a695a8cecbb Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Tue, 31 Aug 2021 15:46:53 +0200
Subject: [PATCH] [#94] Fixed suffering after merge

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 projects/first_mesh/src/main.cpp |  2 +-
 projects/saf_r/src/main.cpp      | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/projects/first_mesh/src/main.cpp b/projects/first_mesh/src/main.cpp
index 0649bdd1..5e6ba7c8 100644
--- a/projects/first_mesh/src/main.cpp
+++ b/projects/first_mesh/src/main.cpp
@@ -108,7 +108,7 @@ int main(int argc, const char** argv) {
 
 	// since we only use one descriptor set (namely, desc set 0), directly address it
 	// recreate copies of the bindings and the handles (to check whether they are properly reused instead of actually recreated)
-	std::unordered_map<uint32_t, vkcv::DescriptorBinding> set0Bindings = firstMeshProgram.getReflectedDescriptors().at(0);
+	const vkcv::DescriptorBindings& set0Bindings = firstMeshProgram.getReflectedDescriptors().at(0);
     auto set0BindingsExplicitCopy = set0Bindings;
 
 	vkcv::DescriptorSetLayoutHandle setLayoutHandle = core.createDescriptorSetLayout(set0Bindings);
diff --git a/projects/saf_r/src/main.cpp b/projects/saf_r/src/main.cpp
index e1b87366..9f6a1f1d 100644
--- a/projects/saf_r/src/main.cpp
+++ b/projects/saf_r/src/main.cpp
@@ -29,7 +29,6 @@ int main(int argc, const char** argv) {
 		applicationName,
 		VK_MAKE_VERSION(0, 0, 1),
 		{ vk::QueueFlagBits::eTransfer,vk::QueueFlagBits::eGraphics, vk::QueueFlagBits::eCompute },
-		{},
 		{ "VK_KHR_swapchain" }
 	);
 
@@ -53,7 +52,10 @@ int main(int argc, const char** argv) {
 		computeShaderProgram.addShader(shaderStage, path);
 	});
 
-	vkcv::DescriptorSetHandle computeDescriptorSet = core.createDescriptorSet(computeShaderProgram.getReflectedDescriptors()[0]);
+	const vkcv::DescriptorBindings& computeDescriptorBindings = computeShaderProgram.getReflectedDescriptors().at(0);
+	
+	vkcv::DescriptorSetLayoutHandle computeDescriptorSetLayout = core.createDescriptorSetLayout(computeDescriptorBindings);
+	vkcv::DescriptorSetHandle computeDescriptorSet = core.createDescriptorSet(computeDescriptorSetLayout);
 
 	const std::vector<vkcv::VertexAttachment> computeVertexAttachments = computeShaderProgram.getVertexAttachments();
 
@@ -74,9 +76,10 @@ int main(int argc, const char** argv) {
 			safrShaderProgram.addShader(shaderStage, path);
 		});
 
-	uint32_t setID = 0;
-	std::vector<vkcv::DescriptorBinding> descriptorBindings = { safrShaderProgram.getReflectedDescriptors()[setID] };
-	vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorBindings);
+	const vkcv::DescriptorBindings& descriptorBindings = safrShaderProgram.getReflectedDescriptors().at(0);
+	vkcv::DescriptorSetLayoutHandle descriptorSetLayout = core.createDescriptorSetLayout(descriptorBindings);
+	
+	vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorSetLayout);
 
 	//materials for the spheres
 	std::vector<safrScene::Material> materials;
@@ -176,12 +179,14 @@ int main(int argc, const char** argv) {
 			(uint32_t)windowHeight,
 			safrPass,
 			{},
-			{ core.getDescriptorSet(descriptorSet).layout },
+			{ core.getDescriptorSetLayout(descriptorSetLayout).vulkanHandle },
 			false
 	};
 
 	vkcv::PipelineHandle safrPipeline = core.createGraphicsPipeline(safrPipelineDefinition);
-	vkcv::PipelineHandle computePipeline = core.createComputePipeline(computeShaderProgram, { core.getDescriptorSet(computeDescriptorSet).layout });
+	vkcv::PipelineHandle computePipeline = core.createComputePipeline(computeShaderProgram, {
+		core.getDescriptorSetLayout(computeDescriptorSetLayout).vulkanHandle
+	});
 
 	if (!safrPipeline || !computePipeline)
 	{
-- 
GitLab