78c363fe622f5bd469fdd71506f59103c84f80d0
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / spirv_assembly / vktSpvAsmUtils.hpp
1 #ifndef _VKTSPVASMUTILS_HPP
2 #define _VKTSPVASMUTILS_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2017 Google Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Utilities for Vulkan SPIR-V assembly tests
24  *//*--------------------------------------------------------------------*/
25
26 #include "vkDefs.hpp"
27 #include "vkMemUtil.hpp"
28 #include "vkRef.hpp"
29 #include "vkTypeUtil.hpp"
30
31 #include <string>
32 #include <vector>
33
34 namespace vkt
35 {
36 namespace SpirVAssembly
37 {
38
39 enum Extension16BitStorageFeatureBits
40 {
41         EXT16BITSTORAGEFEATURES_UNIFORM_BUFFER_BLOCK    = (1u << 1),
42         EXT16BITSTORAGEFEATURES_UNIFORM                                 = (1u << 2),
43         EXT16BITSTORAGEFEATURES_PUSH_CONSTANT                   = (1u << 3),
44         EXT16BITSTORAGEFEATURES_INPUT_OUTPUT                    = (1u << 4),
45 };
46 typedef deUint32 Extension16BitStorageFeatures;
47
48 struct ExtensionFeatures
49 {
50         Extension16BitStorageFeatures   ext16BitStorage;
51
52         ExtensionFeatures       (void)
53                 : ext16BitStorage       (0)
54         {}
55         explicit ExtensionFeatures      (Extension16BitStorageFeatures  ext16BitStorage_)
56                 : ext16BitStorage       (ext16BitStorage_)
57         {}
58 };
59
60 // Returns true if the given 16bit storage extension features in `toCheck` are all supported.
61 bool is16BitStorageFeaturesSupported (const vk::InstanceInterface&      vkInstance,
62                                                                           vk::VkPhysicalDevice                  device,
63                                                                           const std::vector<std::string>& instanceExtensions,
64                                                                           Extension16BitStorageFeatures toCheck);
65
66 // Creates a Vulkan logical device with the requiredExtensions enabled and all other extensions disabled.
67 // The logical device will be created from the given instance and physical device. A single queue will
68 // be created from the given queue family.
69 vk::Move<vk::VkDevice> createDeviceWithExtensions (const vk::InstanceInterface&         vki,
70                                                                                                    vk::VkPhysicalDevice                         physicalDevice,
71                                                                                                    deUint32                                                     queueFamilyIndex,
72                                                                                                    const std::vector<std::string>&      supportedExtensions,
73                                                                                                    const std::vector<std::string>&      requiredExtensions);
74
75 // Creates a SimpleAllocator on the given device.
76 vk::Allocator* createAllocator (const vk::InstanceInterface& instanceInterface,
77                                                                 const vk::VkPhysicalDevice physicalDevice,
78                                                                 const vk::DeviceInterface& deviceInterface,
79                                                                 const vk::VkDevice device);
80
81 } // SpirVAssembly
82 } // vkt
83
84 #endif // _VKTSPVASMUTILS_HPP