blob: a150dc52aea4e01c0b87fb2b77f54b2334beb3c3 [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>
Chia-I Wucc5e2762016-03-24 13:01:16 +080021#include <vulkan/vulkan.h>
Jesse Hall715b86a2016-01-16 16:34:29 -080022#include "debug_report.h"
Chia-I Wucc5e2762016-03-24 13:01:16 +080023#include "driver.h"
Jesse Hall04f4f472015-08-16 19:51:04 -070024
Chia-I Wu136b8eb2016-03-24 15:01:52 +080025struct hwvulkan_device_t;
26
Jesse Hall04f4f472015-08-16 19:51:04 -070027namespace vulkan {
28
Jesse Hall6bd5dfa2016-01-16 17:13:30 -080029enum InstanceExtension {
30 kKHR_surface,
31 kKHR_android_surface,
32 kEXT_debug_report,
33 kInstanceExtensionCount
34};
35typedef std::bitset<kInstanceExtensionCount> InstanceExtensionSet;
36
Jesse Hallb1471272016-01-17 21:36:58 -080037enum DeviceExtension {
38 kKHR_swapchain,
39 kANDROID_native_buffer,
40 kDeviceExtensionCount
41};
42typedef std::bitset<kDeviceExtensionCount> DeviceExtensionSet;
43
Jesse Hall1f91d392015-12-11 16:28:44 -080044// -----------------------------------------------------------------------------
Jesse Hall04f4f472015-08-16 19:51:04 -070045// loader.cpp
46
Jesse Hall1f91d392015-12-11 16:28:44 -080047const VkAllocationCallbacks* GetAllocator(VkInstance instance);
48const VkAllocationCallbacks* GetAllocator(VkDevice device);
Jesse Hall715b86a2016-01-16 16:34:29 -080049VkInstance GetDriverInstance(VkInstance instance);
Chia-I Wucc5e2762016-03-24 13:01:16 +080050const driver::InstanceDriverTable& GetDriverDispatch(VkInstance instance);
51const driver::DeviceDriverTable& GetDriverDispatch(VkDevice device);
52const driver::DeviceDriverTable& GetDriverDispatch(VkQueue queue);
Jesse Hall715b86a2016-01-16 16:34:29 -080053DebugReportCallbackList& GetDebugReportCallbacks(VkInstance instance);
Jesse Hall04f4f472015-08-16 19:51:04 -070054
Jesse Hallb1352bc2015-09-04 16:12:33 -070055// -----------------------------------------------------------------------------
56// swapchain.cpp
57
Jesse Hall1f91d392015-12-11 16:28:44 -080058// clang-format off
Jesse Hallf9fa9a52016-01-08 16:08:51 -080059VKAPI_ATTR VkResult CreateAndroidSurfaceKHR_Bottom(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
Jesse Hall1f91d392015-12-11 16:28:44 -080060VKAPI_ATTR void DestroySurfaceKHR_Bottom(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* allocator);
61VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceSupportKHR_Bottom(VkPhysicalDevice pdev, uint32_t queue_family, VkSurfaceKHR surface, VkBool32* pSupported);
62VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceCapabilitiesKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* capabilities);
63VKAPI_ATTR VkResult GetPhysicalDeviceSurfaceFormatsKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, uint32_t* count, VkSurfaceFormatKHR* formats);
64VKAPI_ATTR VkResult GetPhysicalDeviceSurfacePresentModesKHR_Bottom(VkPhysicalDevice pdev, VkSurfaceKHR surface, uint32_t* count, VkPresentModeKHR* modes);
65VKAPI_ATTR VkResult CreateSwapchainKHR_Bottom(VkDevice device, const VkSwapchainCreateInfoKHR* create_info, const VkAllocationCallbacks* allocator, VkSwapchainKHR* swapchain_handle);
66VKAPI_ATTR void DestroySwapchainKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, const VkAllocationCallbacks* allocator);
67VKAPI_ATTR VkResult GetSwapchainImagesKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, uint32_t* count, VkImage* images);
68VKAPI_ATTR VkResult AcquireNextImageKHR_Bottom(VkDevice device, VkSwapchainKHR swapchain_handle, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* image_index);
69VKAPI_ATTR VkResult QueuePresentKHR_Bottom(VkQueue queue, const VkPresentInfoKHR* present_info);
70// clang-format on
Jesse Hallb1352bc2015-09-04 16:12:33 -070071
Jesse Hall80523e22016-01-06 16:47:54 -080072// -----------------------------------------------------------------------------
73// layers_extensions.cpp
74
75struct Layer;
76class LayerRef {
77 public:
78 LayerRef(Layer* layer);
79 LayerRef(LayerRef&& other);
80 ~LayerRef();
81 LayerRef(const LayerRef&) = delete;
82 LayerRef& operator=(const LayerRef&) = delete;
83
Michael Lentine57036832016-03-04 11:03:35 -060084 const char* GetName() const;
Courtney Goeltzenleuchtereff63112016-02-08 20:12:59 -070085 uint32_t GetSpecVersion();
86
Jesse Hall80523e22016-01-06 16:47:54 -080087 // provides bool-like behavior
88 operator const Layer*() const { return layer_; }
89
90 PFN_vkGetInstanceProcAddr GetGetInstanceProcAddr() const;
91 PFN_vkGetDeviceProcAddr GetGetDeviceProcAddr() const;
92
Jesse Hallb1471272016-01-17 21:36:58 -080093 bool SupportsExtension(const char* name) const;
94
Jesse Hall80523e22016-01-06 16:47:54 -080095 private:
96 Layer* layer_;
97};
98
99void DiscoverLayers();
Jesse Hallaa410942016-01-17 13:07:10 -0800100uint32_t EnumerateInstanceLayers(uint32_t count, VkLayerProperties* properties);
101uint32_t EnumerateDeviceLayers(uint32_t count, VkLayerProperties* properties);
102void GetInstanceLayerExtensions(const char* name,
103 const VkExtensionProperties** properties,
104 uint32_t* count);
105void GetDeviceLayerExtensions(const char* name,
106 const VkExtensionProperties** properties,
107 uint32_t* count);
108LayerRef GetInstanceLayerRef(const char* name);
109LayerRef GetDeviceLayerRef(const char* name);
Jesse Hall80523e22016-01-06 16:47:54 -0800110
Jesse Hall6bd5dfa2016-01-16 17:13:30 -0800111InstanceExtension InstanceExtensionFromName(const char* name);
Jesse Hallb1471272016-01-17 21:36:58 -0800112DeviceExtension DeviceExtensionFromName(const char* name);
Jesse Hall6bd5dfa2016-01-16 17:13:30 -0800113
Jesse Hall04f4f472015-08-16 19:51:04 -0700114} // namespace vulkan
115
116#endif // LIBVULKAN_LOADER_H