• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKPLATFORM_HPP
2 #define _VKPLATFORM_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan CTS Framework
5  * --------------------
6  *
7  * Copyright (c) 2015 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 Vulkan platform abstraction.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "vkDefs.hpp"
27 
28 #include <ostream>
29 
30 namespace tcu
31 {
32 class FunctionLibrary;
33 }
34 
35 namespace vk
36 {
37 
38 class Library
39 {
40 public:
Library(void)41 										Library					(void) {}
~Library(void)42 	virtual								~Library				(void) {}
43 
44 	virtual const PlatformInterface&	getPlatformInterface	(void) const = 0;
45 };
46 
47 class PlatformDriver : public PlatformInterface
48 {
49 public:
50 				PlatformDriver	(const tcu::FunctionLibrary& library);
51 				~PlatformDriver	(void);
52 
53 #include "vkConcretePlatformInterface.inl"
54 
55 protected:
56 	struct Functions
57 	{
58 #include "vkPlatformFunctionPointers.inl"
59 	};
60 
61 	Functions	m_vk;
62 };
63 
64 class InstanceDriver : public InstanceInterface
65 {
66 public:
67 				InstanceDriver	(const PlatformInterface& platformInterface, VkInstance instance);
68 				~InstanceDriver	(void);
69 
70 #include "vkConcreteInstanceInterface.inl"
71 
72 protected:
73 	struct Functions
74 	{
75 #include "vkInstanceFunctionPointers.inl"
76 	};
77 
78 	Functions	m_vk;
79 };
80 
81 class DeviceDriver : public DeviceInterface
82 {
83 public:
84 				DeviceDriver	(const InstanceInterface& instanceInterface, VkDevice device);
85 				~DeviceDriver	(void);
86 
87 #include "vkConcreteDeviceInterface.inl"
88 
89 protected:
90 	struct Functions
91 	{
92 #include "vkDeviceFunctionPointers.inl"
93 	};
94 
95 	Functions	m_vk;
96 };
97 
98 // Defined in vkWsiPlatform.hpp
99 namespace wsi
100 {
101 class Display;
102 } // wsi
103 
104 struct PlatformMemoryLimits
105 {
106 	// System memory properties
107 	size_t			totalSystemMemory;					//!< #bytes of system memory (heap + HOST_LOCAL) tests must not exceed
108 
109 	// Device memory properties
110 	VkDeviceSize	totalDeviceLocalMemory;				//!< #bytes of total DEVICE_LOCAL memory tests must not exceed or 0 if DEVICE_LOCAL counts against system memory
111 	VkDeviceSize	deviceMemoryAllocationGranularity;	//!< VkDeviceMemory allocation granularity (typically page size)
112 
113 	// Device memory page table geometry
114 	// \todo [2016-03-23 pyry] This becomes obsolete if Vulkan API adds a way for driver to expose internal device memory allocations
115 	VkDeviceSize	devicePageSize;						//!< Page size on device (must be rounded up to nearest POT)
116 	VkDeviceSize	devicePageTableEntrySize;			//!< Number of bytes per page table size
117 	size_t			devicePageTableHierarchyLevels;		//!< Number of levels in device page table hierarchy
118 
PlatformMemoryLimitsvk::PlatformMemoryLimits119 	PlatformMemoryLimits (void)
120 		: totalSystemMemory					(0)
121 		, totalDeviceLocalMemory			(0)
122 		, deviceMemoryAllocationGranularity	(0)
123 		, devicePageSize					(0)
124 		, devicePageTableEntrySize			(0)
125 		, devicePageTableHierarchyLevels	(0)
126 	{}
127 };
128 
129 /*--------------------------------------------------------------------*//*!
130  * \brief Vulkan platform interface
131  *//*--------------------------------------------------------------------*/
132 class Platform
133 {
134 public:
Platform(void)135 							Platform			(void) {}
~Platform(void)136 							~Platform			(void) {}
137 
138 	virtual Library*		createLibrary		(void) const = 0;
139 
140 	virtual wsi::Display*	createWsiDisplay	(wsi::Type wsiType) const;
141 
142 	virtual void			getMemoryLimits		(PlatformMemoryLimits& limits) const = 0;
143 	virtual void			describePlatform	(std::ostream& dst) const;
144 };
145 
getMemoryLimits(const Platform & platform)146 inline PlatformMemoryLimits getMemoryLimits (const Platform& platform)
147 {
148 	PlatformMemoryLimits limits;
149 	platform.getMemoryLimits(limits);
150 	return limits;
151 }
152 
153 } // vk
154 
155 #endif // _VKPLATFORM_HPP
156