blob: 0fa62ee23dca95cf741dfbe07394ad05db5ec875 [file] [log] [blame]
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -06001//
Courtney Goeltzenleuchter2040b432015-04-09 11:52:55 -06002// File: vk_platform.h
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -06003//
4/*
Jon Ashburnf1ea4182016-03-22 12:57:13 -06005** Copyright (c) 2014-2015 The Khronos Group Inc.
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -06006**
Jon Ashburn43b53e82016-04-19 11:30:31 -06007** Licensed under the Apache License, Version 2.0 (the "License");
8** you may not use this file except in compliance with the License.
9** You may obtain a copy of the License at
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060010**
Jon Ashburn43b53e82016-04-19 11:30:31 -060011** http://www.apache.org/licenses/LICENSE-2.0
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060012**
Jon Ashburn43b53e82016-04-19 11:30:31 -060013** Unless required by applicable law or agreed to in writing, software
14** distributed under the License is distributed on an "AS IS" BASIS,
15** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16** See the License for the specific language governing permissions and
17** limitations under the License.
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060018*/
19
20
Jon Ashburnf1ea4182016-03-22 12:57:13 -060021#ifndef VK_PLATFORM_H_
22#define VK_PLATFORM_H_
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060023
24#ifdef __cplusplus
25extern "C"
26{
27#endif // __cplusplus
28
29/*
30***************************************************************************************************
31* Platform-specific directives and type declarations
32***************************************************************************************************
33*/
34
Chia-I Wuaf9e4fd2015-11-06 06:42:02 +080035/* Platform-specific calling convention macros.
36 *
37 * Platforms should define these so that Vulkan clients call Vulkan commands
38 * with the same calling conventions that the Vulkan implementation expects.
39 *
40 * VKAPI_ATTR - Placed before the return type in function declarations.
41 * Useful for C++11 and GCC/Clang-style function attribute syntax.
42 * VKAPI_CALL - Placed after the return type in function declarations.
43 * Useful for MSVC-style calling convention syntax.
44 * VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
45 *
46 * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
47 * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
48 */
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060049#if defined(_WIN32)
Chia-I Wuaf9e4fd2015-11-06 06:42:02 +080050 // On Windows, Vulkan commands use the stdcall convention
51 #define VKAPI_ATTR
52 #define VKAPI_CALL __stdcall
53 #define VKAPI_PTR VKAPI_CALL
Mark Lobodzinski76201382016-08-26 10:19:57 -060054#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
55 #error "Vulkan isn't supported for the 'armeabi' NDK ABI"
Mark Lobodzinskiccbb5af2016-09-29 10:47:27 -060056#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
Mark Lobodzinski76201382016-08-26 10:19:57 -060057 // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
58 // calling convention, i.e. float parameters are passed in registers. This
59 // is true even if the rest of the application passes floats on the stack,
60 // as it does by default when compiling for the armeabi-v7a NDK ABI.
Chia-I Wuaf9e4fd2015-11-06 06:42:02 +080061 #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
62 #define VKAPI_CALL
63 #define VKAPI_PTR VKAPI_ATTR
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060064#else
Chia-I Wuaf9e4fd2015-11-06 06:42:02 +080065 // On other platforms, use the default calling convention
66 #define VKAPI_ATTR
67 #define VKAPI_CALL
68 #define VKAPI_PTR
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060069#endif
70
71#include <stddef.h>
72
73#if !defined(VK_NO_STDINT_H)
74 #if defined(_MSC_VER) && (_MSC_VER < 1600)
75 typedef signed __int8 int8_t;
76 typedef unsigned __int8 uint8_t;
77 typedef signed __int16 int16_t;
78 typedef unsigned __int16 uint16_t;
79 typedef signed __int32 int32_t;
80 typedef unsigned __int32 uint32_t;
81 typedef signed __int64 int64_t;
82 typedef unsigned __int64 uint64_t;
83 #else
84 #include <stdint.h>
85 #endif
86#endif // !defined(VK_NO_STDINT_H)
87
Courtney Goeltzenleuchter89e99e62015-04-08 18:04:29 -060088#ifdef __cplusplus
89} // extern "C"
90#endif // __cplusplus
91
Ian Elliott677dec82015-11-18 12:24:57 -070092// Platform-specific headers required by platform window system extensions.
93// These are enabled prior to #including "vulkan.h". The same enable then
94// controls inclusion of the extension interfaces in vulkan.h.
95
96#ifdef VK_USE_PLATFORM_ANDROID_KHR
97#include <android/native_window.h>
98#endif
99
100#ifdef VK_USE_PLATFORM_MIR_KHR
101#include <mir_toolkit/client_types.h>
102#endif
103
104#ifdef VK_USE_PLATFORM_WAYLAND_KHR
105#include <wayland-client.h>
106#endif
107
108#ifdef VK_USE_PLATFORM_WIN32_KHR
109#include <windows.h>
110#endif
111
112#ifdef VK_USE_PLATFORM_XLIB_KHR
113#include <X11/Xlib.h>
114#endif
115
116#ifdef VK_USE_PLATFORM_XCB_KHR
117#include <xcb/xcb.h>
118#endif
119
Jon Ashburnf1ea4182016-03-22 12:57:13 -0600120#endif