1e8556ba3Sopenharmony_ci//
2e8556ba3Sopenharmony_ci// File: vk_platform.h
3e8556ba3Sopenharmony_ci//
4e8556ba3Sopenharmony_ci/*
5e8556ba3Sopenharmony_ci** Copyright 2014-2024 The Khronos Group Inc.
6e8556ba3Sopenharmony_ci**
7e8556ba3Sopenharmony_ci** SPDX-License-Identifier: Apache-2.0
8e8556ba3Sopenharmony_ci*/
9e8556ba3Sopenharmony_ci
10e8556ba3Sopenharmony_ci
11e8556ba3Sopenharmony_ci#ifndef VK_PLATFORM_H_
12e8556ba3Sopenharmony_ci#define VK_PLATFORM_H_
13e8556ba3Sopenharmony_ci
14e8556ba3Sopenharmony_ci#ifdef __cplusplus
15e8556ba3Sopenharmony_ciextern "C"
16e8556ba3Sopenharmony_ci{
17e8556ba3Sopenharmony_ci#endif // __cplusplus
18e8556ba3Sopenharmony_ci
19e8556ba3Sopenharmony_ci/*
20e8556ba3Sopenharmony_ci***************************************************************************************************
21e8556ba3Sopenharmony_ci*   Platform-specific directives and type declarations
22e8556ba3Sopenharmony_ci***************************************************************************************************
23e8556ba3Sopenharmony_ci*/
24e8556ba3Sopenharmony_ci
25e8556ba3Sopenharmony_ci/* Platform-specific calling convention macros.
26e8556ba3Sopenharmony_ci *
27e8556ba3Sopenharmony_ci * Platforms should define these so that Vulkan clients call Vulkan commands
28e8556ba3Sopenharmony_ci * with the same calling conventions that the Vulkan implementation expects.
29e8556ba3Sopenharmony_ci *
30e8556ba3Sopenharmony_ci * VKAPI_ATTR - Placed before the return type in function declarations.
31e8556ba3Sopenharmony_ci *              Useful for C++11 and GCC/Clang-style function attribute syntax.
32e8556ba3Sopenharmony_ci * VKAPI_CALL - Placed after the return type in function declarations.
33e8556ba3Sopenharmony_ci *              Useful for MSVC-style calling convention syntax.
34e8556ba3Sopenharmony_ci * VKAPI_PTR  - Placed between the '(' and '*' in function pointer types.
35e8556ba3Sopenharmony_ci *
36e8556ba3Sopenharmony_ci * Function declaration:  VKAPI_ATTR void VKAPI_CALL vkCommand(void);
37e8556ba3Sopenharmony_ci * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
38e8556ba3Sopenharmony_ci */
39e8556ba3Sopenharmony_ci#if defined(_WIN32)
40e8556ba3Sopenharmony_ci    // On Windows, Vulkan commands use the stdcall convention
41e8556ba3Sopenharmony_ci    #define VKAPI_ATTR
42e8556ba3Sopenharmony_ci    #define VKAPI_CALL __stdcall
43e8556ba3Sopenharmony_ci    #define VKAPI_PTR  VKAPI_CALL
44e8556ba3Sopenharmony_ci#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
45e8556ba3Sopenharmony_ci    #error "Vulkan is not supported for the 'armeabi' NDK ABI"
46e8556ba3Sopenharmony_ci#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
47e8556ba3Sopenharmony_ci    // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
48e8556ba3Sopenharmony_ci    // calling convention, i.e. float parameters are passed in registers. This
49e8556ba3Sopenharmony_ci    // is true even if the rest of the application passes floats on the stack,
50e8556ba3Sopenharmony_ci    // as it does by default when compiling for the armeabi-v7a NDK ABI.
51e8556ba3Sopenharmony_ci    #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
52e8556ba3Sopenharmony_ci    #define VKAPI_CALL
53e8556ba3Sopenharmony_ci    #define VKAPI_PTR  VKAPI_ATTR
54e8556ba3Sopenharmony_ci#else
55e8556ba3Sopenharmony_ci    // On other platforms, use the default calling convention
56e8556ba3Sopenharmony_ci    #define VKAPI_ATTR
57e8556ba3Sopenharmony_ci    #define VKAPI_CALL
58e8556ba3Sopenharmony_ci    #define VKAPI_PTR
59e8556ba3Sopenharmony_ci#endif
60e8556ba3Sopenharmony_ci
61e8556ba3Sopenharmony_ci#if !defined(VK_NO_STDDEF_H)
62e8556ba3Sopenharmony_ci    #include <stddef.h>
63e8556ba3Sopenharmony_ci#endif // !defined(VK_NO_STDDEF_H)
64e8556ba3Sopenharmony_ci
65e8556ba3Sopenharmony_ci#if !defined(VK_NO_STDINT_H)
66e8556ba3Sopenharmony_ci    #if defined(_MSC_VER) && (_MSC_VER < 1600)
67e8556ba3Sopenharmony_ci        typedef signed   __int8  int8_t;
68e8556ba3Sopenharmony_ci        typedef unsigned __int8  uint8_t;
69e8556ba3Sopenharmony_ci        typedef signed   __int16 int16_t;
70e8556ba3Sopenharmony_ci        typedef unsigned __int16 uint16_t;
71e8556ba3Sopenharmony_ci        typedef signed   __int32 int32_t;
72e8556ba3Sopenharmony_ci        typedef unsigned __int32 uint32_t;
73e8556ba3Sopenharmony_ci        typedef signed   __int64 int64_t;
74e8556ba3Sopenharmony_ci        typedef unsigned __int64 uint64_t;
75e8556ba3Sopenharmony_ci    #else
76e8556ba3Sopenharmony_ci        #include <stdint.h>
77e8556ba3Sopenharmony_ci    #endif
78e8556ba3Sopenharmony_ci#endif // !defined(VK_NO_STDINT_H)
79e8556ba3Sopenharmony_ci
80e8556ba3Sopenharmony_ci#ifdef __cplusplus
81e8556ba3Sopenharmony_ci} // extern "C"
82e8556ba3Sopenharmony_ci#endif // __cplusplus
83e8556ba3Sopenharmony_ci
84e8556ba3Sopenharmony_ci#endif
85