xref: /aosp_15_r20/external/swiftshader/tests/VulkanWrapper/VulkanTester.hpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1 // Copyright 2021 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 VULKAN_TESTER_HPP_
16 #define VULKAN_TESTER_HPP_
17 
18 #include "VulkanHeaders.hpp"
19 
20 #include <memory>
21 
22 class VulkanTester
23 {
24 public:
25 	VulkanTester();
26 	virtual ~VulkanTester();
27 
28 	// Call once after construction so that virtual functions may be called during init
29 	void initialize();
30 
dynamicLoader() const31 	const vk::DynamicLoader &dynamicLoader() const { return *dl; }
getPhysicalDevice()32 	vk::PhysicalDevice &getPhysicalDevice() { return physicalDevice; }
getDevice()33 	vk::Device &getDevice() { return device; }
getQueue()34 	vk::Queue &getQueue() { return queue; }
getQueueFamilyIndex() const35 	uint32_t getQueueFamilyIndex() const { return queueFamilyIndex; }
36 
37 private:
38 	std::unique_ptr<vk::DynamicLoader> loadDriver();
39 
40 	std::unique_ptr<class ScopedSetIcdFilenames> setIcdFilenames;
41 	std::unique_ptr<vk::DynamicLoader> dl;
42 	vk::DebugUtilsMessengerEXT debugReport;
43 
44 protected:
45 	const uint32_t queueFamilyIndex = 0;
46 
47 	vk::Instance instance;  // Owning handle
48 	vk::PhysicalDevice physicalDevice;
49 	vk::Device device;  // Owning handle
50 	vk::Queue queue;
51 };
52 
53 #endif  // VULKAN_TESTER_HPP_
54