summaryrefslogtreecommitdiffstats
path: root/include/vulkan/vk_wsi_swapchain.h
blob: 64704d4731800efb94a5549f52e0f0e60b47b2da (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
//
// File: vk_wsi_swapchain.h
//
/*
** Copyright (c) 2014 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_WSI_SWAPCHAIN_H__
#define __VK_WSI_SWAPCHAIN_H__

#include "vulkan.h"

#define VK_WSI_SWAPCHAIN_REVISION             12
#define VK_WSI_SWAPCHAIN_EXTENSION_NUMBER     1
#define VK_WSI_SWAPCHAIN_EXTENSION_NAME       "VK_WSI_swapchain"

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

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

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

#define VK_WSI_SWAPCHAIN_ENUM(type,id)    ((type)((int)0xc0000000 - VK_WSI_SWAPCHAIN_EXTENSION_NUMBER * -1024 + (id)))
#define VK_WSI_SWAPCHAIN_ENUM_POSITIVE(type,id)    ((type)((int)0x40000000 + (VK_WSI_SWAPCHAIN_EXTENSION_NUMBER - 1) * 1024 + (id)))

// Extend VkStructureType enum with extension specific constants
#define VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI            VK_WSI_SWAPCHAIN_ENUM(VkStructureType, 0) 

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

typedef enum VkPlatformWSI_
{
    VK_PLATFORM_WIN32_WSI = 0,
    VK_PLATFORM_X11_WSI = 1,
    VK_PLATFORM_XCB_WSI = 2,
    VK_PLATFORM_ANDROID_WSI = 3,
    VK_PLATFORM_WAYLAND_WSI = 4,
    VK_PLATFORM_MIR_WSI = 5,
    VK_PLATFORM_BEGIN_RANGE_WSI = VK_PLATFORM_WIN32_WSI,
    VK_PLATFORM_END_RANGE_WSI = VK_PLATFORM_MIR_WSI,
    VK_PLATFORM_NUM_WSI = (VK_PLATFORM_MIR_WSI - VK_PLATFORM_WIN32_WSI + 1),
    VK_PLATFORM_MAX_ENUM_WSI = 0x7FFFFFFF
} VkPlatformWSI;

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

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

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

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

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

// Surface description structure for a native platform window surface
typedef struct VkSurfaceDescriptionWindowWSI_
{
    VkStructureType                         sType;              // Must be VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI
    const void*                             pNext;              // Pointer to next structure
    VkPlatformWSI                           platform;           // e.g. VK_PLATFORM_*_WSI
    void*                                   pPlatformHandle;
    void*                                   pPlatformWindow;
} VkSurfaceDescriptionWindowWSI;

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

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

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

#ifdef VK_PROTOTYPES

VkResult VKAPI vkGetPhysicalDeviceSurfaceSupportWSI(
    VkPhysicalDevice                        physicalDevice,
    uint32_t                                queueFamilyIndex,
    const VkSurfaceDescriptionWSI*          pSurfaceDescription,
    VkBool32*                               pSupported);

#endif // VK_PROTOTYPES

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

#endif // __VK_WSI_SWAPCHAIN_H__