1// Copyright 2019 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_DESCRIPTOR_SET_HPP_
16#define VK_DESCRIPTOR_SET_HPP_
17
18// Intentionally not including VkObject.hpp here due to b/127920555
19
20#include <array>
21#include <memory>
22
23namespace vk
24{
25 class DescriptorSetLayout;
26
27 struct alignas(16) DescriptorSetHeader
28 {
29 DescriptorSetLayout* layout;
30 };
31
32 class alignas(16) DescriptorSet
33 {
34 public:
35 static inline DescriptorSet* Cast(VkDescriptorSet object)
36 {
37 return static_cast<DescriptorSet*>(static_cast<void*>(object));
38 }
39
40 using Bindings = std::array<vk::DescriptorSet*, vk::MAX_BOUND_DESCRIPTOR_SETS>;
41 using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
42
43 DescriptorSetHeader header;
44 alignas(16) uint8_t data[1];
45 };
46
47 inline DescriptorSet* Cast(VkDescriptorSet object)
48 {
49 return DescriptorSet::Cast(object);
50 }
51
52} // namespace vk
53
54#endif // VK_DESCRIPTOR_SET_HPP_
55