Jesse Hall | d02edcb | 2015-09-08 07:44:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 17 | #ifndef LIBVULKAN_LOADER_H |
| 18 | #define LIBVULKAN_LOADER_H 1 |
| 19 | |
Jesse Hall | 6bd5dfa | 2016-01-16 17:13:30 -0800 | [diff] [blame] | 20 | #include <bitset> |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 21 | #include <vulkan/vulkan.h> |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 22 | #include "debug_report.h" |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 23 | #include "driver.h" |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 24 | |
Chia-I Wu | 136b8eb | 2016-03-24 15:01:52 +0800 | [diff] [blame] | 25 | struct hwvulkan_device_t; |
| 26 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 27 | namespace vulkan { |
| 28 | |
Jesse Hall | 6bd5dfa | 2016-01-16 17:13:30 -0800 | [diff] [blame] | 29 | enum InstanceExtension { |
| 30 | kKHR_surface, |
| 31 | kKHR_android_surface, |
| 32 | kEXT_debug_report, |
| 33 | kInstanceExtensionCount |
| 34 | }; |
| 35 | typedef std::bitset<kInstanceExtensionCount> InstanceExtensionSet; |
| 36 | |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 37 | enum DeviceExtension { |
| 38 | kKHR_swapchain, |
| 39 | kANDROID_native_buffer, |
| 40 | kDeviceExtensionCount |
| 41 | }; |
| 42 | typedef std::bitset<kDeviceExtensionCount> DeviceExtensionSet; |
| 43 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 44 | // ----------------------------------------------------------------------------- |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 45 | // loader.cpp |
| 46 | |
Chia-I Wu | 136b8eb | 2016-03-24 15:01:52 +0800 | [diff] [blame] | 47 | bool InitLoader(hwvulkan_device_t* dev); |
| 48 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 49 | // clang-format off |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 50 | VKAPI_ATTR VkResult CreateInstance_Bottom(const VkInstanceCreateInfo* create_info, const VkAllocationCallbacks* allocator, VkInstance* vkinstance); |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 51 | VKAPI_ATTR VkResult EnumeratePhysicalDevices_Bottom(VkInstance vkinstance, uint32_t* pdev_count, VkPhysicalDevice* pdevs); |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 52 | VKAPI_ATTR VkResult EnumerateDeviceExtensionProperties_Bottom(VkPhysicalDevice pdev, const char* layer_name, uint32_t* properties_count, VkExtensionProperties* properties); |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 53 | VKAPI_ATTR void DestroyInstance_Bottom(VkInstance vkinstance, const VkAllocationCallbacks* allocator); |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 54 | // clang-format on |
Jesse Hall | d7b994a | 2015-09-07 14:17:37 -0700 | [diff] [blame] | 55 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 56 | const VkAllocationCallbacks* GetAllocator(VkInstance instance); |
| 57 | const VkAllocationCallbacks* GetAllocator(VkDevice device); |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 58 | VkInstance GetDriverInstance(VkInstance instance); |
Chia-I Wu | cc5e276 | 2016-03-24 13:01:16 +0800 | [diff] [blame] | 59 | const driver::InstanceDriverTable& GetDriverDispatch(VkInstance instance); |
| 60 | const driver::DeviceDriverTable& GetDriverDispatch(VkDevice device); |
| 61 | const driver::DeviceDriverTable& GetDriverDispatch(VkQueue queue); |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 62 | DebugReportCallbackList& GetDebugReportCallbacks(VkInstance instance); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 63 | |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 64 | // ----------------------------------------------------------------------------- |
| 65 | // swapchain.cpp |
| 66 | |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 67 | // clang-format off |
Jesse Hall | f9fa9a5 | 2016-01-08 16:08:51 -0800 | [diff] [blame] | 68 | VKAPI_ATTR VkResult CreateAndroidSurfaceKHR_Bottom(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 69 | VKAPI_ATTR void DestroySurfaceKHR_Bottom(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* allocator); |
| 70 | VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceSupportKHR_Bottom(VkPhysicalDevice pdev, uint32_t queue_family, VkSurfaceKHR surface, VkBool32* pSupported); |
| 71 | VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceCapabilitiesKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* capabilities); |
| 72 | VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceFormatsKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, uint32_t* count, VkSurfaceFormatKHR* formats); |
| 73 | VKAPI_ATTR VkResult GetPhysicalDeviceSurfacePresentModesKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, uint32_t* count, VkPresentModeKHR* modes); |
| 74 | VKAPI_ATTR VkResult CreateSwapchainKHR_Bottom(VkDevice device, const VkSwapchainCreateInfoKHR* create_info, const VkAllocationCallbacks* allocator, VkSwapchainKHR* swapchain_handle); |
| 75 | VKAPI_ATTR void DestroySwapchainKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, const VkAllocationCallbacks* allocator); |
| 76 | VKAPI_ATTR VkResult GetSwapchainImagesKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, uint32_t* count, VkImage* images); |
| 77 | VKAPI_ATTR VkResult AcquireNextImageKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* image_index); |
| 78 | VKAPI_ATTR VkResult QueuePresentKHR_Bottom(VkQueue queue, const VkPresentInfoKHR* present_info); |
| 79 | // clang-format on |
Jesse Hall | b1352bc | 2015-09-04 16:12:33 -0700 | [diff] [blame] | 80 | |
Jesse Hall | 80523e2 | 2016-01-06 16:47:54 -0800 | [diff] [blame] | 81 | // ----------------------------------------------------------------------------- |
| 82 | // layers_extensions.cpp |
| 83 | |
| 84 | struct Layer; |
| 85 | class LayerRef { |
| 86 | public: |
| 87 | LayerRef(Layer* layer); |
| 88 | LayerRef(LayerRef&& other); |
| 89 | ~LayerRef(); |
| 90 | LayerRef(const LayerRef&) = delete; |
| 91 | LayerRef& operator=(const LayerRef&) = delete; |
| 92 | |
Michael Lentine | 5703683 | 2016-03-04 11:03:35 -0600 | [diff] [blame] | 93 | const char* GetName() const; |
Courtney Goeltzenleuchter | eff6311 | 2016-02-08 20:12:59 -0700 | [diff] [blame] | 94 | uint32_t GetSpecVersion(); |
| 95 | |
Jesse Hall | 80523e2 | 2016-01-06 16:47:54 -0800 | [diff] [blame] | 96 | // provides bool-like behavior |
| 97 | operator const Layer*() const { return layer_; } |
| 98 | |
| 99 | PFN_vkGetInstanceProcAddr GetGetInstanceProcAddr() const; |
| 100 | PFN_vkGetDeviceProcAddr GetGetDeviceProcAddr() const; |
| 101 | |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 102 | bool SupportsExtension(const char* name) const; |
| 103 | |
Jesse Hall | 80523e2 | 2016-01-06 16:47:54 -0800 | [diff] [blame] | 104 | private: |
| 105 | Layer* layer_; |
| 106 | }; |
| 107 | |
| 108 | void DiscoverLayers(); |
Jesse Hall | aa41094 | 2016-01-17 13:07:10 -0800 | [diff] [blame] | 109 | uint32_t EnumerateInstanceLayers(uint32_t count, VkLayerProperties* properties); |
| 110 | uint32_t EnumerateDeviceLayers(uint32_t count, VkLayerProperties* properties); |
| 111 | void GetInstanceLayerExtensions(const char* name, |
| 112 | const VkExtensionProperties** properties, |
| 113 | uint32_t* count); |
| 114 | void GetDeviceLayerExtensions(const char* name, |
| 115 | const VkExtensionProperties** properties, |
| 116 | uint32_t* count); |
| 117 | LayerRef GetInstanceLayerRef(const char* name); |
| 118 | LayerRef GetDeviceLayerRef(const char* name); |
Jesse Hall | 80523e2 | 2016-01-06 16:47:54 -0800 | [diff] [blame] | 119 | |
Jesse Hall | 6bd5dfa | 2016-01-16 17:13:30 -0800 | [diff] [blame] | 120 | InstanceExtension InstanceExtensionFromName(const char* name); |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 121 | DeviceExtension DeviceExtensionFromName(const char* name); |
Jesse Hall | 6bd5dfa | 2016-01-16 17:13:30 -0800 | [diff] [blame] | 122 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 123 | } // namespace vulkan |
| 124 | |
| 125 | #endif // LIBVULKAN_LOADER_H |