vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
DescriptorSet.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission 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
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE 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/state/Descriptor.h>
16#include <vsg/state/DescriptorSetLayout.h>
17
18namespace vsg
19{
20
21 // forward declare
22 class DescriptorPool;
23
25 class VSG_DECLSPEC DescriptorSet : public Inherit<Object, DescriptorSet>
26 {
27 public:
29 DescriptorSet(const DescriptorSet& rhs, const CopyOp& copyop = {});
30 DescriptorSet(ref_ptr<DescriptorSetLayout> in_descriptorSetLayout, const Descriptors& in_descriptors);
31
34 Descriptors descriptors;
35
36 // compile the Vulkan object, context parameter used for Device
37 void compile(Context& context);
38
39 // remove the local reference to the Vulkan implementation
40 void release(uint32_t deviceID);
41 void release();
42
44 VkDescriptorSet vk(uint32_t deviceID) const;
45
46 public:
47 ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return DescriptorSet::create(*this, copyop); }
48 int compare(const Object& rhs_object) const override;
49
50 template<class N, class V>
51 static void t_traverse(N& ds, V& visitor)
52 {
53 if (ds.setLayout) ds.setLayout->accept(visitor);
54 for (auto& descriptor : ds.descriptors) descriptor->accept(visitor);
55 }
56
57 void traverse(Visitor& visitor) override { t_traverse(*this, visitor); }
58 void traverse(ConstVisitor& visitor) const override { t_traverse(*this, visitor); }
59
60 void read(Input& input) override;
61 void write(Output& output) const override;
62
63 public:
67 class VSG_DECLSPEC Implementation : public Inherit<Object, Implementation>
68 {
69 public:
70 Implementation(DescriptorPool* descriptorPool, DescriptorSetLayout* descriptorSetLayout);
71
72 void assign(Context& context, const Descriptors& descriptors);
73
74 VkDescriptorSet _descriptorSet;
75
76 static void recycle(ref_ptr<DescriptorSet::Implementation>& dsi);
77
78 protected:
79 virtual ~Implementation();
80
81 friend DescriptorPool;
82
83 ref_ptr<DescriptorPool> _descriptorPool;
84 ref_ptr<DescriptorSetLayout> _descriptorSetLayout;
85 };
86
87 protected:
88 virtual ~DescriptorSet();
89
90 vk_buffer<ref_ptr<Implementation>> _implementation;
91 };
92 VSG_type_name(vsg::DescriptorSet);
94
95 using DescriptorSets = std::vector<ref_ptr<DescriptorSet>>;
96
97} // namespace vsg
Definition Context.h:67
Definition Object.h:42
DescriptorPool encapsulates management of VkDescriptorPool.
Definition DescriptorPool.h:22
Definition DescriptorSet.h:68
DescriptorSet encapsulates VkDescriptorSet and VkDescriptorSetAllocateInfo settings used to describe ...
Definition DescriptorSet.h:26
ref_ptr< Object > clone(const CopyOp &copyop={}) const override
Definition DescriptorSet.h:47
VkDescriptorSet vk(uint32_t deviceID) const
get the Vulkan handle to the descriptor set for specified device
ref_ptr< DescriptorSetLayout > setLayout
VkDescriptorSetAllocateInfo settings.
Definition DescriptorSet.h:33
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,...
DescriptorSetLayout encapsulates VkDescriptorSetLayout and VkDescriptorSetLayoutCreateInfo settings u...
Definition DescriptorSetLayout.h:28
Definition Inherit.h:28
Definition Object.h:60
Definition Visitor.h:172
Definition ref_ptr.h:22
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:28