vsg  1.1.0
VulkanSceneGraph library
PipelineLayout.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/state/DescriptorSetLayout.h>
16 #include <vsg/vk/vk_buffer.h>
17 
18 namespace vsg
19 {
20  // forward declare
21  class Context;
22 
23  using PushConstantRanges = std::vector<VkPushConstantRange>;
24 
26  class VSG_DECLSPEC PipelineLayout : public Inherit<Object, PipelineLayout>
27  {
28  public:
30  PipelineLayout(const DescriptorSetLayouts& in_setLayouts, const PushConstantRanges& in_pushConstantRanges, VkPipelineLayoutCreateFlags in_flags = 0);
31 
33  VkPipelineLayoutCreateFlags flags = 0;
34  DescriptorSetLayouts setLayouts;
35  PushConstantRanges pushConstantRanges;
36 
38  VkPipelineLayout vk(uint32_t deviceID) const { return _implementation[deviceID]->_pipelineLayout; }
39 
40  int compare(const Object& rhs) const override;
41 
42  void read(Input& input) override;
43  void write(Output& output) const override;
44 
45  void compile(Context& context);
46 
47  void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
48  void release() { _implementation.clear(); }
49 
50  protected:
51  virtual ~PipelineLayout();
52 
53  struct Implementation : public Inherit<Object, Implementation>
54  {
55  Implementation(Device* device, const DescriptorSetLayouts& descriptorSetLayouts, const PushConstantRanges& pushConstantRanges, VkPipelineLayoutCreateFlags flags = 0);
56 
57  virtual ~Implementation();
58 
59  VkPipelineLayout _pipelineLayout;
60 
61  ref_ptr<Device> _device;
62  };
63 
64  vk_buffer<ref_ptr<Implementation>> _implementation;
65  };
66  VSG_type_name(vsg::PipelineLayout);
67 
68 } // namespace vsg
Definition: Context.h:67
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
PipelineLayout encapsulates VkPipelineLayout and the VkPipelineLayoutCreateInfo settings used to set ...
Definition: PipelineLayout.h:27
VkPipelineLayout vk(uint32_t deviceID) const
Vulkan VkPipelineLayout handle.
Definition: PipelineLayout.h:38
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
Definition: ref_ptr.h:22
Definition: PipelineLayout.h:54
vk_buffer that manages a single logical device supported.
Definition: vk_buffer.h:28