Lugdunum  0.1.0
DescriptorSetLayout.cpp
Go to the documentation of this file.
2 
4 
5 namespace lug {
6 namespace Graphics {
7 namespace Vulkan {
8 namespace API {
9 namespace Builder {
10 
11 DescriptorSetLayout::DescriptorSetLayout(const API::Device& device) : _device{device} {}
12 
13 bool DescriptorSetLayout::build(API::DescriptorSetLayout& descriptorSetLayout, VkResult* returnResult) {
14  // Create the descriptorSetLayout creation information for vkCreateDescriptorSetLayout
15  const VkDescriptorSetLayoutCreateInfo createInfo{
16  /* createInfo.sType */ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
17  /* createInfo.pNext */ nullptr,
18  /* createInfo.flags */ 0,
19  /* createInfo.bindingCount */ static_cast<uint32_t>(_bindings.size()),
20  /* createInfo.pBindings */ _bindings.data(),
21  };
22 
23  // Create the descriptorSetLayout
24  VkDescriptorSetLayout vkDescriptorSetLayout{VK_NULL_HANDLE};
25  VkResult result = vkCreateDescriptorSetLayout(static_cast<VkDevice>(_device), &createInfo, nullptr, &vkDescriptorSetLayout);
26 
27  if (returnResult) {
28  *returnResult = result;
29  }
30 
31  if (result != VK_SUCCESS) {
32  return false;
33  }
34 
35  descriptorSetLayout = API::DescriptorSetLayout(vkDescriptorSetLayout, &_device);
36 
37  return true;
38 }
39 
40 std::unique_ptr<API::DescriptorSetLayout> DescriptorSetLayout::build(VkResult* returnResult) {
41  std::unique_ptr<API::DescriptorSetLayout> descriptorSetLayout = std::make_unique<API::DescriptorSetLayout>();
42  return build(*descriptorSetLayout, returnResult) ? std::move(descriptorSetLayout) : nullptr;
43 }
44 
45 } // Builder
46 } // API
47 } // Vulkan
48 } // Graphics
49 } // lug
std::vector< VkDescriptorSetLayoutBinding > _bindings
bool build(API::DescriptorSetLayout &instance, VkResult *returnResult=nullptr)