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 virtual const tcu::FunctionLibrary& getFunctionLibrary (void) const = 0; 46 }; 47 48 class PlatformDriver : public PlatformInterface 49 { 50 public: 51 PlatformDriver (const tcu::FunctionLibrary& library); 52 ~PlatformDriver (void); 53 54 #include "vkConcretePlatformInterface.inl" 55 getGetInstanceProcAddr() const56 virtual GetInstanceProcAddrFunc getGetInstanceProcAddr () const { 57 return m_vk.getInstanceProcAddr; 58 } 59 60 protected: 61 struct Functions 62 { 63 #include "vkPlatformFunctionPointers.inl" 64 }; 65 66 Functions m_vk; 67 }; 68 69 class InstanceDriver : public InstanceInterface 70 { 71 public: 72 InstanceDriver (const PlatformInterface& platformInterface, VkInstance instance); 73 ~InstanceDriver (void); 74 75 #include "vkConcreteInstanceInterface.inl" 76 77 protected: 78 void loadFunctions (const PlatformInterface& platformInterface, VkInstance instance); 79 80 struct Functions 81 { 82 #include "vkInstanceFunctionPointers.inl" 83 }; 84 85 Functions m_vk; 86 }; 87 88 class DeviceDriver : public DeviceInterface 89 { 90 public: 91 DeviceDriver (const PlatformInterface& platformInterface, VkInstance instance, VkDevice device); 92 ~DeviceDriver (void); 93 94 #include "vkConcreteDeviceInterface.inl" 95 96 protected: 97 struct Functions 98 { 99 #include "vkDeviceFunctionPointers.inl" 100 }; 101 102 Functions m_vk; 103 }; 104 105 // Defined in vkWsiPlatform.hpp 106 namespace wsi 107 { 108 class Display; 109 } // wsi 110 111 /*--------------------------------------------------------------------*//*! 112 * \brief Vulkan platform interface 113 *//*--------------------------------------------------------------------*/ 114 class Platform 115 { 116 public: Platform(void)117 Platform (void) {} ~Platform(void)118 ~Platform (void) {} 119 120 virtual Library* createLibrary (void) const = 0; 121 virtual wsi::Display* createWsiDisplay (wsi::Type wsiType) const; 122 virtual bool hasDisplay (wsi::Type wsiType) const; 123 virtual void describePlatform (std::ostream& dst) const; 124 }; 125 126 } // vk 127 128 #endif // _VKPLATFORM_HPP 129