vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
DescriptorSetLayout.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/vk/Device.h>
16#include <vsg/vk/vk_buffer.h>
17
18namespace 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 // compile the Vulkan object, context parameter used for Device
43 virtual void compile(Context& context);
44
45 // remove the local reference to the Vulkan implementation
46 void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
47 void release() { _implementation.clear(); }
48
49 public:
50 int compare(const Object& rhs_object) const override;
51
52 void read(Input& input) override;
53 void write(Output& output) const override;
54
55 protected:
56 virtual ~DescriptorSetLayout();
57
58 struct Implementation : public Inherit<Object, Implementation>
59 {
60 Implementation(Device* device, const DescriptorSetLayoutBindings& descriptorSetLayoutBindings);
61
62 virtual ~Implementation();
63
64 ref_ptr<Device> _device;
65 VkDescriptorSetLayout _descriptorSetLayout;
66 };
67
68 vk_buffer<ref_ptr<Implementation>> _implementation;
69 };
70 VSG_type_name(vsg::DescriptorSetLayout);
71
72 using DescriptorSetLayouts = std::vector<vsg::ref_ptr<vsg::DescriptorSetLayout>>;
73
74} // 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:60
Definition Output.h:41
Definition ref_ptr.h:22
Definition DescriptorSetLayout.h:59
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:28