backup - missing some
[demo] / src / vulkan / resources.cc
diff --git a/src/vulkan/resources.cc b/src/vulkan/resources.cc
new file mode 100644 (file)
index 0000000..22932a6
--- /dev/null
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "resources.h"
+#include "vkutil.h"
+
+ResourceVK::ResourceVK() {}
+ResourceVK::~ResourceVK() {}
+
+bool ResourceVK::create_ds_layout(unsigned int num, VkDescriptorType type,
+                                  VkShaderStageFlags stage, VkSampler *sampler)
+{
+       res_type = RES_DESC_SET;
+
+       /* layout binding */
+       VkDescriptorSetLayoutBinding bind;
+
+       memset(&bind, 0, sizeof bind);
+       bind.binding = num;
+       bind.descriptorType = type;
+       bind.stageFlags = stage;
+
+       bind.pImmutableSamplers = sampler;
+
+       /* layout : for the moment:
+        * one layout per ds, (=> 1 binding point)
+        * */
+
+       VkDescriptorSetLayoutCreateInfo dslinf;
+       memset(&dslinf, 0, sizeof dslinf);
+       dslinf.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+       dslinf.bindingCount = 1;
+       dslinf.pBindings = &bind;
+
+       if(vkCreateDescriptorSetLayout(vk_device, &dslinf, 0, &layout) != VK_SUCCESS) {
+               fprintf(stderr, "Failed to create descriptor set layout.\n");
+               return false;
+       }
+       return true;
+}