summaryrefslogtreecommitdiffstats
path: root/include/vulkan/vk_ext_khr_swapchain.h
blob: 862b4d5e7415b8fed48cc0e16c06136ccce7f566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//
// File: vk_ext_khr_swapchain.h
//
/*
** Copyright (c) 2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/

#ifndef __VK_EXT_KHR_SWAPCHAIN_H__
#define __VK_EXT_KHR_SWAPCHAIN_H__

#include "vulkan.h"

#define VK_EXT_KHR_SWAPCHAIN_REVISION         17
#define VK_EXT_KHR_SWAPCHAIN_EXTENSION_NUMBER 1
#define VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME   "VK_EXT_KHR_swapchain"

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

// ------------------------------------------------------------------------------------------------
// Objects

// ------------------------------------------------------------------------------------------------
// Enumeration constants

#define VK_EXT_KHR_SWAPCHAIN_ENUM(type,id)    ((type)((int)0xc0000000 - VK_EXT_KHR_SWAPCHAIN_EXTENSION_NUMBER * -1024 + (id)))
#define VK_EXT_KHR_SWAPCHAIN_ENUM_POSITIVE(type,id)    ((type)((int)0x40000000 + (VK_EXT_KHR_SWAPCHAIN_EXTENSION_NUMBER - 1) * 1024 + (id)))

// Extend VkStructureType enum with extension specific constants
#define VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR            VK_EXT_KHR_SWAPCHAIN_ENUM(VkStructureType, 0)

// ------------------------------------------------------------------------------------------------
// Enumerations

typedef enum {
    VK_SURFACE_TRANSFORM_NONE_KHR = 0,
    VK_SURFACE_TRANSFORM_ROT90_KHR = 1,
    VK_SURFACE_TRANSFORM_ROT180_KHR = 2,
    VK_SURFACE_TRANSFORM_ROT270_KHR = 3,
    VK_SURFACE_TRANSFORM_HMIRROR_KHR = 4,
    VK_SURFACE_TRANSFORM_HMIRROR_ROT90_KHR = 5,
    VK_SURFACE_TRANSFORM_HMIRROR_ROT180_KHR = 6,
    VK_SURFACE_TRANSFORM_HMIRROR_ROT270_KHR = 7,
    VK_SURFACE_TRANSFORM_INHERIT_KHR = 8,
} VkSurfaceTransformKHR;

typedef enum {
    VK_SURFACE_TRANSFORM_NONE_BIT_KHR = 0x00000001,
    VK_SURFACE_TRANSFORM_ROT90_BIT_KHR = 0x00000002,
    VK_SURFACE_TRANSFORM_ROT180_BIT_KHR = 0x00000004,
    VK_SURFACE_TRANSFORM_ROT270_BIT_KHR = 0x00000008,
    VK_SURFACE_TRANSFORM_HMIRROR_BIT_KHR = 0x00000010,
    VK_SURFACE_TRANSFORM_HMIRROR_ROT90_BIT_KHR = 0x00000020,
    VK_SURFACE_TRANSFORM_HMIRROR_ROT180_BIT_KHR = 0x00000040,
    VK_SURFACE_TRANSFORM_HMIRROR_ROT270_BIT_KHR = 0x00000080,
    VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100,
} VkSurfaceTransformFlagBitsKHR;
typedef VkFlags VkSurfaceTransformFlagsKHR;

typedef enum {
    VK_PLATFORM_WIN32_KHR = 0,
    VK_PLATFORM_X11_KHR = 1,
    VK_PLATFORM_XCB_KHR = 2,
    VK_PLATFORM_ANDROID_KHR = 3,
    VK_PLATFORM_WAYLAND_KHR = 4,
    VK_PLATFORM_MIR_KHR = 5,
    VK_PLATFORM_BEGIN_RANGE_KHR = VK_PLATFORM_WIN32_KHR,
    VK_PLATFORM_END_RANGE_KHR = VK_PLATFORM_MIR_KHR,
    VK_PLATFORM_NUM_KHR = (VK_PLATFORM_MIR_KHR - VK_PLATFORM_WIN32_KHR + 1),
    VK_PLATFORM_MAX_ENUM_KHR = 0x7FFFFFFF
} VkPlatformKHR;

// ------------------------------------------------------------------------------------------------
// Flags

// ------------------------------------------------------------------------------------------------
// Structures

// Placeholder structure header for the different types of surface description structures
typedef struct {
    VkStructureType                          sType;             // Can be any of the VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_XXX_KHR constants
    const void*                              pNext;             // Pointer to next structure
} VkSurfaceDescriptionKHR;

// Surface description structure for a native platform window surface
typedef struct {
    VkStructureType                         sType;              // Must be VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_KHR
    const void*                             pNext;              // Pointer to next structure
    VkPlatformKHR                           platform;           // e.g. VK_PLATFORM_*_KHR
    void*                                   pPlatformHandle;
    void*                                   pPlatformWindow;
} VkSurfaceDescriptionWindowKHR;

// pPlatformHandle points to this struct when platform is VK_PLATFORM_X11_KHR
#ifdef _X11_XLIB_H_
typedef struct {
    Display*                                 dpy;               // Display connection to an X server
    Window                                   root;              // To identify the X screen
} VkPlatformHandleX11KHR;
#endif /* _X11_XLIB_H_ */

// pPlatformHandle points to this struct when platform is VK_PLATFORM_XCB_KHR
#ifdef __XCB_H__
typedef struct {
    xcb_connection_t*                        connection;        // XCB connection to an X server
    xcb_window_t                             root;              // To identify the X screen
} VkPlatformHandleXcbKHR;
#endif /* __XCB_H__ */

// ------------------------------------------------------------------------------------------------
// Function types

typedef VkResult (VKAPI *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, const VkSurfaceDescriptionKHR* pSurfaceDescription, VkBool32* pSupported);

// ------------------------------------------------------------------------------------------------
// Function prototypes

#ifdef VK_PROTOTYPES

VkResult VKAPI vkGetPhysicalDeviceSurfaceSupportKHR(
    VkPhysicalDevice                        physicalDevice,
    uint32_t                                queueFamilyIndex,
    const VkSurfaceDescriptionKHR*          pSurfaceDescription,
    VkBool32*                               pSupported);

#endif // VK_PROTOTYPES

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

#endif // __VK_EXT_KHR_SWAPCHAIN_H__