• 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_DEVICE_HPP_
16 #define VK_DEVICE_HPP_
17 
18 #include "VkObject.hpp"
19 
20 namespace vk
21 {
22 
23 class Queue;
24 
25 class Device
26 {
27 public:
28 	struct CreateInfo
29 	{
30 		const VkDeviceCreateInfo* pCreateInfo;
31 		VkPhysicalDevice pPhysicalDevice;
32 	};
33 
GetAllocationScope()34 	static constexpr VkSystemAllocationScope GetAllocationScope() { return VK_SYSTEM_ALLOCATION_SCOPE_DEVICE; }
35 
36 	Device(const CreateInfo* info, void* mem);
37 	void destroy(const VkAllocationCallbacks* pAllocator);
38 
39 	static size_t ComputeRequiredAllocationSize(const CreateInfo* info);
40 
41 	VkQueue getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex) const;
42 	void waitForFences(uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout);
43 	void waitIdle();
44 	void getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
45 	                                   VkDescriptorSetLayoutSupport* pSupport) const;
getPhysicalDevice() const46 	VkPhysicalDevice getPhysicalDevice() const { return physicalDevice; }
47 
48 private:
49 	VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
50 	Queue* queues = nullptr;
51 	uint32_t queueCount = 0;
52 };
53 
54 using DispatchableDevice = DispatchableObject<Device, VkDevice>;
55 
Cast(VkDevice object)56 static inline Device* Cast(VkDevice object)
57 {
58 	return DispatchableDevice::Cast(object);
59 }
60 
61 } // namespace vk
62 
63 #endif // VK_DEVICE_HPP_
64