-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathPipelineLayout.h
More file actions
75 lines (51 loc) · 3.37 KB
/
PipelineLayout.h
File metadata and controls
75 lines (51 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
/* <editor-fold desc="MIT License">
Copyright(c) 2018 Robert Osfield
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
</editor-fold> */
#include <vsg/state/DescriptorSetLayout.h>
#include <vsg/vk/vk_buffer.h>
namespace vsg
{
// forward declare
class Context;
using PushConstantRanges = std::vector<VkPushConstantRange>;
/// PipelineLayout encapsulates VkPipelineLayout and the VkPipelineLayoutCreateInfo settings used to set it up.
class VSG_DECLSPEC PipelineLayout : public Inherit<Object, PipelineLayout>
{
public:
PipelineLayout();
PipelineLayout(const PipelineLayout& rhs, const CopyOp& copyop = {});
PipelineLayout(const DescriptorSetLayouts& in_setLayouts, const PushConstantRanges& in_pushConstantRanges, VkPipelineLayoutCreateFlags in_flags = 0);
/// VkPipelineLayoutCreateInfo settings
VkPipelineLayoutCreateFlags flags = 0;
DescriptorSetLayouts setLayouts;
PushConstantRanges pushConstantRanges;
std::vector<bool> descriptorSetSlots;
/// Vulkan VkPipelineLayout handle
VkPipelineLayout vk(uint32_t deviceID) const { return _implementation[deviceID]->_pipelineLayout; }
void compile(Context& context);
void release(uint32_t deviceID) { _implementation[deviceID] = {}; }
void release() { _implementation.clear(); }
// returns whether the layouts are push-constant-compatible and the lowest N for which the layouts are not compatible for descriptor set N
std::pair<bool, uint32_t> computeCompatibility(const PipelineLayout& other);
public:
ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return PipelineLayout::create(*this, copyop); }
int compare(const Object& rhs) const override;
void read(Input& input) override;
void write(Output& output) const override;
protected:
virtual ~PipelineLayout();
struct Implementation : public Inherit<Object, Implementation>
{
Implementation(Device* device, const DescriptorSetLayouts& descriptorSetLayouts, const PushConstantRanges& pushConstantRanges, VkPipelineLayoutCreateFlags flags = 0);
virtual ~Implementation();
VkPipelineLayout _pipelineLayout;
ref_ptr<Device> _device;
};
vk_buffer<ref_ptr<Implementation>> _implementation;
};
VSG_type_name(vsg::PipelineLayout);
} // namespace vsg