vsg  1.1.0
VulkanSceneGraph library
DescriptorSetLayout.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <vsg/vk/Device.h>
16 #include <vsg/vk/vk_buffer.h>
17 
18 namespace vsg
19 {
20  // forward declare
21  class Context;
22 
23  using DescriptorSetLayoutBindings = std::vector<VkDescriptorSetLayoutBinding>;
24  using DescriptorPoolSizes = std::vector<VkDescriptorPoolSize>;
25 
27  class VSG_DECLSPEC DescriptorSetLayout : public Inherit<Object, DescriptorSetLayout>
28  {
29  public:
31  explicit DescriptorSetLayout(const DescriptorSetLayoutBindings& descriptorSetLayoutBindings);
32 
34  virtual VkDescriptorSetLayout vk(uint32_t deviceID) const { return _implementation[deviceID]->_descriptorSetLayout; }
35 
37  DescriptorSetLayoutBindings bindings;
38 
40  void getDescriptorPoolSizes(DescriptorPoolSizes& descriptorPoolSizes);
41 
42  int compare(const Object& rhs_object) const override;
43 
44  void read(Input& input) override;
45  void write(Output& output) const override;
46 
47  // compile the Vulkan object, context parameter used for Device
48  virtual void compile(Context& context);
49 
50  // remove the local reference to the Vulkan implementation
51  void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
52  void release() { _implementation.clear(); }
53 
54  protected:
55  virtual ~DescriptorSetLayout();
56 
57  struct Implementation : public Inherit<Object, Implementation>
58  {
59  Implementation(Device* device, const DescriptorSetLayoutBindings& descriptorSetLayoutBindings);
60 
61  virtual ~Implementation();
62 
63  ref_ptr<Device> _device;
64  VkDescriptorSetLayout _descriptorSetLayout;
65  };
66 
67  vk_buffer<ref_ptr<Implementation>> _implementation;
68  };
69  VSG_type_name(vsg::DescriptorSetLayout);
70 
71  using DescriptorSetLayouts = std::vector<vsg::ref_ptr<vsg::DescriptorSetLayout>>;
72 
73 } // namespace vsg
Definition: Context.h:67
DescriptorSetLayout encapsulates VkDescriptorSetLayout and VkDescriptorSetLayoutCreateInfo settings u...
Definition: DescriptorSetLayout.h:28
void getDescriptorPoolSizes(DescriptorPoolSizes &descriptorPoolSizes)
map the descriptor bindings to the descriptor pool sizes that will be required to represent them.
virtual VkDescriptorSetLayout vk(uint32_t deviceID) const
Vulkan VkDescriptorSetLayout handle.
Definition: DescriptorSetLayout.h:34
DescriptorSetLayoutBindings bindings
VkDescriptorSetLayoutCreateInfo settings.
Definition: DescriptorSetLayout.h:37
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition: Device.h:37
Definition: Inherit.h:28
Definition: Input.h:44
Definition: Object.h:42
Definition: Output.h:41
Definition: ref_ptr.h:22
Definition: DescriptorSetLayout.h:58
vk_buffer that manages a single logical device supported.
Definition: vk_buffer.h:28