blob: 15b773d713506cf092e79008f2eedb44ace8d0cc [file] [log] [blame]
Jesse Halld02edcb2015-09-08 07:44:48 -07001/*
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 Hall04f4f472015-08-16 19:51:04 -070017#ifndef LIBVULKAN_LOADER_H
18#define LIBVULKAN_LOADER_H 1
19
Jesse Hall6bd5dfa2016-01-16 17:13:30 -080020#include <bitset>
Jesse Hall1f91d392015-12-11 16:28:44 -080021#include "dispatch_gen.h"
Jesse Hall715b86a2016-01-16 16:34:29 -080022#include "debug_report.h"
Jesse Hall04f4f472015-08-16 19:51:04 -070023
Chia-I Wu136b8eb2016-03-24 15:01:52 +080024struct hwvulkan_device_t;
25
Jesse Hall04f4f472015-08-16 19:51:04 -070026namespace vulkan {
27
Jesse Hall6bd5dfa2016-01-16 17:13:30 -080028enum InstanceExtension {
29 kKHR_surface,
30 kKHR_android_surface,
31 kEXT_debug_report,
32 kInstanceExtensionCount
33};
34typedef std::bitset<kInstanceExtensionCount> InstanceExtensionSet;
35
Jesse Hallb1471272016-01-17 21:36:58 -080036enum DeviceExtension {
37 kKHR_swapchain,
38 kANDROID_native_buffer,
39 kDeviceExtensionCount
40};
41typedef std::bitset<kDeviceExtensionCount> DeviceExtensionSet;
42
Jesse Hall1f91d392015-12-11 16:28:44 -080043// -----------------------------------------------------------------------------
44// dispatch_gen.cpp
Jesse Hall04f4f472015-08-16 19:51:04 -070045
Jesse Hall1f91d392015-12-11 16:28:44 -080046bool LoadDriverDispatchTable(VkInstance instance,
47 PFN_vkGetInstanceProcAddr get_proc_addr,
Jesse Hall6bd5dfa2016-01-16 17:13:30 -080048 const InstanceExtensionSet& extensions,
Jesse Hall1f91d392015-12-11 16:28:44 -080049 DriverDispatchTable& dispatch);
Jesse Hall04f4f472015-08-16 19:51:04 -070050
51// -----------------------------------------------------------------------------
52// loader.cpp
53
Chia-I Wu136b8eb2016-03-24 15:01:52 +080054bool InitLoader(hwvulkan_device_t* dev);
55
Jesse Hall1f91d392015-12-11 16:28:44 -080056// clang-format off
Jesse Hall1f91d392015-12-11 16:28:44 -080057VKAPI_ATTR VkResult CreateInstance_Bottom(const VkInstanceCreateInfo* create_info, const VkAllocationCallbacks* allocator, VkInstance* vkinstance);
Jesse Hall1f91d392015-12-11 16:28:44 -080058VKAPI_ATTR VkResult EnumeratePhysicalDevices_Bottom(VkInstance vkinstance, uint32_t* pdev_count, VkPhysicalDevice* pdevs);
Jesse Hall1f91d392015-12-11 16:28:44 -080059VKAPI_ATTR VkResult EnumerateDeviceExtensionProperties_Bottom(VkPhysicalDevice pdev, const char* layer_name, uint32_t* properties_count, VkExtensionProperties* properties);
Jesse Hall1f91d392015-12-11 16:28:44 -080060VKAPI_ATTR VkResult CreateDevice_Bottom(VkPhysicalDevice pdev, const VkDeviceCreateInfo* create_info, const VkAllocationCallbacks* allocator, VkDevice* device_out);
61VKAPI_ATTR void DestroyInstance_Bottom(VkInstance vkinstance, const VkAllocationCallbacks* allocator);
Chia-I Wu0c203242016-03-15 13:44:51 +080062VKAPI_ATTR void DestroyDevice_Bottom(VkDevice device, const VkAllocationCallbacks* pAllocator);
63VKAPI_ATTR void GetDeviceQueue_Bottom(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue);
64VKAPI_ATTR VkResult AllocateCommandBuffers_Bottom(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers);
Jesse Hall1f91d392015-12-11 16:28:44 -080065// clang-format on
Jesse Halld7b994a2015-09-07 14:17:37 -070066
Jesse Hall1f91d392015-12-11 16:28:44 -080067const VkAllocationCallbacks* GetAllocator(VkInstance instance);
68const VkAllocationCallbacks* GetAllocator(VkDevice device);
Jesse Hall715b86a2016-01-16 16:34:29 -080069VkInstance GetDriverInstance(VkInstance instance);
70const DriverDispatchTable& GetDriverDispatch(VkInstance instance);
Jesse Hall1f91d392015-12-11 16:28:44 -080071const DriverDispatchTable& GetDriverDispatch(VkDevice device);
72const DriverDispatchTable& GetDriverDispatch(VkQueue queue);
Jesse Hall715b86a2016-01-16 16:34:29 -080073DebugReportCallbackList& GetDebugReportCallbacks(VkInstance instance);
Jesse Hall04f4f472015-08-16 19:51:04 -070074
Jesse Hallb1352bc2015-09-04 16:12:33 -070075// -----------------------------------------------------------------------------
76// swapchain.cpp
77
Jesse Hall1f91d392015-12-11 16:28:44 -080078// clang-format off
Jesse Hallf9fa9a52016-01-08 16:08:51 -080079VKAPI_ATTR VkResult CreateAndroidSurfaceKHR_Bottom(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
Jesse Hall1f91d392015-12-11 16:28:44 -080080VKAPI_ATTR void DestroySurfaceKHR_Bottom(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* allocator);
81VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceSupportKHR_Bottom(VkPhysicalDevice pdev, uint32_t queue_family, VkSurfaceKHR surface, VkBool32* pSupported);
82VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceCapabilitiesKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* capabilities);
83VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceFormatsKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, uint32_t* count, VkSurfaceFormatKHR* formats);
84VKAPI_ATTR VkResult GetPhysicalDeviceSurfacePresentModesKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, uint32_t* count, VkPresentModeKHR* modes);
85VKAPI_ATTR VkResult CreateSwapchainKHR_Bottom(VkDevice device, const VkSwapchainCreateInfoKHR* create_info, const VkAllocationCallbacks* allocator, VkSwapchainKHR* swapchain_handle);
86VKAPI_ATTR void DestroySwapchainKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, const VkAllocationCallbacks* allocator);
87VKAPI_ATTR VkResult GetSwapchainImagesKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, uint32_t* count, VkImage* images);
88VKAPI_ATTR VkResult AcquireNextImageKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* image_index);
89VKAPI_ATTR VkResult QueuePresentKHR_Bottom(VkQueue queue, const VkPresentInfoKHR* present_info);
90// clang-format on
Jesse Hallb1352bc2015-09-04 16:12:33 -070091
Jesse Hall80523e22016-01-06 16:47:54 -080092// -----------------------------------------------------------------------------
93// layers_extensions.cpp
94
95struct Layer;
96class LayerRef {
97 public:
98 LayerRef(Layer* layer);
99 LayerRef(LayerRef&& other);
100 ~LayerRef();
101 LayerRef(const LayerRef&) = delete;
102 LayerRef& operator=(const LayerRef&) = delete;
103
Michael Lentine57036832016-03-04 11:03:35 -0600104 const char* GetName() const;
Courtney Goeltzenleuchtereff63112016-02-08 20:12:59 -0700105 uint32_t GetSpecVersion();
106
Jesse Hall80523e22016-01-06 16:47:54 -0800107 // provides bool-like behavior
108 operator const Layer*() const { return layer_; }
109
110 PFN_vkGetInstanceProcAddr GetGetInstanceProcAddr() const;
111 PFN_vkGetDeviceProcAddr GetGetDeviceProcAddr() const;
112
Jesse Hallb1471272016-01-17 21:36:58 -0800113 bool SupportsExtension(const char* name) const;
114
Jesse Hall80523e22016-01-06 16:47:54 -0800115 private:
116 Layer* layer_;
117};
118
119void DiscoverLayers();
Jesse Hallaa410942016-01-17 13:07:10 -0800120uint32_t EnumerateInstanceLayers(uint32_t count, VkLayerProperties* properties);
121uint32_t EnumerateDeviceLayers(uint32_t count, VkLayerProperties* properties);
122void GetInstanceLayerExtensions(const char* name,
123 const VkExtensionProperties** properties,
124 uint32_t* count);
125void GetDeviceLayerExtensions(const char* name,
126 const VkExtensionProperties** properties,
127 uint32_t* count);
128LayerRef GetInstanceLayerRef(const char* name);
129LayerRef GetDeviceLayerRef(const char* name);
Jesse Hall80523e22016-01-06 16:47:54 -0800130
Jesse Hall6bd5dfa2016-01-16 17:13:30 -0800131InstanceExtension InstanceExtensionFromName(const char* name);
Jesse Hallb1471272016-01-17 21:36:58 -0800132DeviceExtension DeviceExtensionFromName(const char* name);
Jesse Hall6bd5dfa2016-01-16 17:13:30 -0800133
Jesse Hall04f4f472015-08-16 19:51:04 -0700134} // namespace vulkan
135
136#endif // LIBVULKAN_LOADER_H