1 #ifndef _VKTCUSTOMINSTANCESDEVICES_HPP
2 #define _VKTCUSTOMINSTANCESDEVICES_HPP
3 /*-------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2019 The Khronos Group Inc.
8 * Copyright (c) 2019 Valve Corporation.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief Auxiliar functions to help create custom devices and instances.
25 *//*--------------------------------------------------------------------*/
28 #include "vktTestCase.hpp"
35 class PlatformInterface;
36 class InstanceInterface;
47 std::vector<const char*> getValidationLayers (const vk::PlatformInterface& vkp);
49 std::vector<const char*> getValidationLayers (const vk::InstanceInterface& vki, vk::VkPhysicalDevice physicalDevice);
55 #ifndef CTS_USES_VULKANSC
56 CustomInstance (Context& context, vk::Move<vk::VkInstance> instance, std::unique_ptr<vk::DebugReportRecorder>& recorder);
58 CustomInstance (Context& context, vk::Move<vk::VkInstance> instance);
59 #endif // CTS_USES_VULKANSC
60 CustomInstance (CustomInstance&& other);
62 CustomInstance& operator= (CustomInstance&& other);
63 operator vk::VkInstance () const;
64 void swap (CustomInstance& other);
65 const vk::InstanceDriver& getDriver () const;
66 void collectMessages ();
68 CustomInstance (const CustomInstance& other) = delete;
69 CustomInstance& operator= (const CustomInstance& other) = delete;
72 #ifndef CTS_USES_VULKANSC
73 std::unique_ptr<vk::DebugReportRecorder> m_recorder;
74 #endif // CTS_USES_VULKANSC
75 vk::Move<vk::VkInstance> m_instance;
76 #ifndef CTS_USES_VULKANSC
77 std::unique_ptr<vk::InstanceDriver> m_driver;
78 vk::Move<vk::VkDebugReportCallbackEXT> m_callback;
80 std::unique_ptr<vk::InstanceDriverSC> m_driver;
81 #endif // CTS_USES_VULKANSC
84 class UncheckedInstance
88 #ifndef CTS_USES_VULKANSC
89 UncheckedInstance (Context& context, vk::VkInstance instance, const vk::VkAllocationCallbacks* pAllocator, std::unique_ptr<vk::DebugReportRecorder>& recorder);
91 UncheckedInstance (Context& context, vk::VkInstance instance, const vk::VkAllocationCallbacks* pAllocator);
92 #endif // CTS_USES_VULKANSC
93 UncheckedInstance (UncheckedInstance&& other);
94 ~UncheckedInstance ();
95 UncheckedInstance& operator= (UncheckedInstance&& other);
96 operator vk::VkInstance () const;
97 operator bool () const;
98 void swap (UncheckedInstance& other);
100 UncheckedInstance (const UncheckedInstance& other) = delete;
101 UncheckedInstance& operator= (const UncheckedInstance& other) = delete;
104 #ifndef CTS_USES_VULKANSC
105 std::unique_ptr<vk::DebugReportRecorder> m_recorder;
106 #endif // CTS_USES_VULKANSC
107 const vk::VkAllocationCallbacks* m_allocator;
108 vk::VkInstance m_instance;
109 #ifndef CTS_USES_VULKANSC
110 std::unique_ptr<vk::InstanceDriver> m_driver;
111 vk::Move<vk::VkDebugReportCallbackEXT> m_callback;
113 std::unique_ptr<vk::InstanceDriverSC> m_driver;
114 #endif // CTS_USES_VULKANSC
119 CustomInstance createCustomInstanceWithExtensions (Context& context, const std::vector<std::string>& extension, const vk::VkAllocationCallbacks* pAllocator = DE_NULL, bool allowLayers = true);
121 CustomInstance createCustomInstanceWithExtension (Context& context, const std::string& extension, const vk::VkAllocationCallbacks* pAllocator = DE_NULL, bool allowLayers = true);
123 CustomInstance createCustomInstanceFromContext (Context& context, const vk::VkAllocationCallbacks* pAllocator = DE_NULL, bool allowLayers = true);
125 CustomInstance createCustomInstanceFromInfo (Context& context, const vk::VkInstanceCreateInfo* instanceCreateInfo, const vk::VkAllocationCallbacks* pAllocator = DE_NULL, bool allowLayers = true);
127 // Unchecked instance: creation allowed to fail.
129 vk::VkResult createUncheckedInstance (Context& context, const vk::VkInstanceCreateInfo* instanceCreateInfo, const vk::VkAllocationCallbacks* pAllocator, UncheckedInstance* instance, bool allowLayers = true);
133 vk::Move<vk::VkDevice> createCustomDevice (bool validationEnabled, const vk::PlatformInterface& vkp, vk::VkInstance instance, const vk::InstanceInterface& vki, vk::VkPhysicalDevice physicalDevice, const vk::VkDeviceCreateInfo* pCreateInfo, const vk::VkAllocationCallbacks* pAllocator = DE_NULL);
135 // Unchecked device: creation allowed to fail.
137 vk::VkResult createUncheckedDevice (bool validationEnabled, const vk::InstanceInterface& vki, vk::VkPhysicalDevice physicalDevice, const vk::VkDeviceCreateInfo* pCreateInfo, const vk::VkAllocationCallbacks* pAllocator, vk::VkDevice* pDevice);
139 class CustomInstanceWrapper
142 CustomInstanceWrapper(Context& context);
143 CustomInstanceWrapper(Context& context, const std::vector<std::string> extensions);
144 vkt::CustomInstance instance;
149 #endif // _VKTCUSTOMINSTANCESDEVICES_HPP