Lugdunum  0.1.0
DescriptorSet.cpp
Go to the documentation of this file.
2 
6 
7 namespace lug {
8 namespace Graphics {
9 namespace Vulkan {
10 namespace API {
11 
12 DescriptorSet::DescriptorSet(VkDescriptorSet descriptorSet, const Device* device) : _descriptorSet(descriptorSet), _device(device) {}
13 
15  _descriptorSet = descriptorSet._descriptorSet;
16  _device = descriptorSet._device;
17 
18  descriptorSet._descriptorSet = VK_NULL_HANDLE;
19  descriptorSet._device = nullptr;
20 
21 }
22 
24  destroy();
25 
26  _descriptorSet = descriptorSet._descriptorSet;
27  _device = descriptorSet._device;
28 
29  descriptorSet._descriptorSet = VK_NULL_HANDLE;
30  descriptorSet._device = nullptr;
31 
32  return *this;
33 }
34 
36  destroy();
37 }
38 
40  uint32_t dstBinding,
41  uint32_t dstArrayElement,
42  VkDescriptorType descriptorType,
43  const std::vector<VkDescriptorBufferInfo>& bufferInfos
44 ) const {
45  VkWriteDescriptorSet write{
46  /* write.sType */ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
47  /* write.pNext */ nullptr,
48  /* write.dstSet */ _descriptorSet,
49  /* write.dstBinding */ dstBinding,
50  /* write.dstArrayElement */ dstArrayElement,
51  /* write.descriptorCount */ static_cast<uint32_t>(bufferInfos.size()),
52  /* write.descriptorType */ descriptorType,
53  /* write.pImageInfo */ nullptr,
54  /* write.pBufferInfo */ bufferInfos.data(),
55  /* write.pTexelBufferView */ nullptr
56  };
57 
58  vkUpdateDescriptorSets(static_cast<VkDevice>(*_device), 1, &write, 0, nullptr);
59 }
60 
62  uint32_t dstBinding,
63  uint32_t dstArrayElement,
64  VkDescriptorType descriptorType,
65  const std::vector<VkDescriptorImageInfo>& imageInfos
66 ) const {
67  VkWriteDescriptorSet write{
68  /* write.sType */ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
69  /* write.pNext */ nullptr,
70  /* write.dstSet */ _descriptorSet,
71  /* write.dstBinding */ dstBinding,
72  /* write.dstArrayElement */ dstArrayElement,
73  /* write.descriptorCount */ static_cast<uint32_t>(imageInfos.size()),
74  /* write.descriptorType */ descriptorType,
75  /* write.pImageInfo */ imageInfos.data(),
76  /* write.pBufferInfo */ nullptr,
77  /* write.pTexelBufferView */ nullptr
78  };
79 
80  vkUpdateDescriptorSets(static_cast<VkDevice>(*_device), 1, &write, 0, nullptr);
81 }
82 
84  if (_descriptorSet != VK_NULL_HANDLE) {
85  _descriptorSet = VK_NULL_HANDLE;
86  }
87 }
88 
89 } // API
90 } // Vulkan
91 } // Graphics
92 } // lug
DescriptorSet & operator=(const DescriptorSet &)=delete
void updateBuffers(uint32_t dstBinding, uint32_t dstArrayElement, VkDescriptorType descriptorType, const std::vector< VkDescriptorBufferInfo > &bufferInfos) const
Update the descriptor set buffers.
void updateImages(uint32_t dstBinding, uint32_t dstArrayElement, VkDescriptorType descriptorType, const std::vector< VkDescriptorImageInfo > &imageInfos) const
Update the descriptor set images.