fixes
[demo] / src / vulkan / resources.cc
1 #include <stdio.h>
2 #include <string.h>
3
4 #include "resources.h"
5 #include "vkutil.h"
6
7 ResourceVK::ResourceVK() {}
8 ResourceVK::~ResourceVK() {}
9
10 bool ResourceVK::create_ds_layout(unsigned int num, VkDescriptorType type,
11                                   VkShaderStageFlags stage, VkSampler *sampler)
12 {
13         this->type = RES_DESC_SET;
14
15         /* layout binding */
16         VkDescriptorSetLayoutBinding bind;
17
18         memset(&bind, 0, sizeof bind);
19         bind.binding = num;
20         bind.descriptorType = type;
21         bind.stageFlags = stage;
22
23         bind.pImmutableSamplers = sampler;
24
25         /* layout : for the moment:
26          * one layout per ds, (=> 1 binding point)
27          * */
28
29         VkDescriptorSetLayoutCreateInfo dslinf;
30         memset(&dslinf, 0, sizeof dslinf);
31         dslinf.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
32         dslinf.bindingCount = 1;
33         dslinf.pBindings = &bind;
34
35         if(vkCreateDescriptorSetLayout(vk_device, &dslinf, 0, &layout) != VK_SUCCESS) {
36                 fprintf(stderr, "Failed to create descriptor set layout.\n");
37                 return false;
38         }
39         return true;
40 }