• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef VK_PIPELINE_LAYOUT_HPP_
16 #define VK_PIPELINE_LAYOUT_HPP_
17 
18 #include "VkConfig.hpp"
19 #include "VkDescriptorSetLayout.hpp"
20 
21 namespace vk {
22 
23 class PipelineLayout : public Object<PipelineLayout, VkPipelineLayout>
24 {
25 public:
26 	PipelineLayout(const VkPipelineLayoutCreateInfo *pCreateInfo, void *mem);
27 	void destroy(const VkAllocationCallbacks *pAllocator);
28 	bool release(const VkAllocationCallbacks *pAllocator);
29 
30 	static size_t ComputeRequiredAllocationSize(const VkPipelineLayoutCreateInfo *pCreateInfo);
31 
32 	size_t getDescriptorSetCount() const;
33 	uint32_t getBindingCount(uint32_t setNumber) const;
34 
35 	// Returns the index into the pipeline's dynamic offsets array for
36 	// the given descriptor set and binding number.
37 	uint32_t getDynamicOffsetIndex(uint32_t setNumber, uint32_t bindingNumber) const;
38 	uint32_t getDescriptorCount(uint32_t setNumber, uint32_t bindingNumber) const;
39 	uint32_t getBindingOffset(uint32_t setNumber, uint32_t bindingNumber) const;
40 	VkDescriptorType getDescriptorType(uint32_t setNumber, uint32_t bindingNumber) const;
41 	uint32_t getDescriptorSize(uint32_t setNumber, uint32_t bindingNumber) const;
42 	bool isDescriptorDynamic(uint32_t setNumber, uint32_t bindingNumber) const;
43 
44 	const uint32_t identifier;
45 
46 	uint32_t incRefCount();
47 	uint32_t decRefCount();
48 
49 private:
50 	struct Binding
51 	{
52 		VkDescriptorType descriptorType;
53 		uint32_t offset;  // Offset in bytes in the descriptor set data.
54 		uint32_t dynamicOffsetIndex;
55 		uint32_t descriptorCount;
56 	};
57 
58 	struct DescriptorSet
59 	{
60 		Binding *bindings;
61 		uint32_t bindingCount;
62 	};
63 
64 	DescriptorSet descriptorSets[MAX_BOUND_DESCRIPTOR_SETS];
65 
66 	const uint32_t descriptorSetCount = 0;
67 	const uint32_t pushConstantRangeCount = 0;
68 	VkPushConstantRange *pushConstantRanges = nullptr;
69 
70 	std::atomic<uint32_t> refCount{ 0 };
71 };
72 
Cast(VkPipelineLayout object)73 static inline PipelineLayout *Cast(VkPipelineLayout object)
74 {
75 	return PipelineLayout::Cast(object);
76 }
77 
78 }  // namespace vk
79 
80 #endif  // VK_PIPELINE_LAYOUT_HPP_
81