blob: 742bffad7e4d768e3582166fe6d9f23552985501 [file] [log] [blame]
Chris Forbes3fdf41f2017-05-02 14:32:26 -07001/* Copyright (c) 2015-2016 The Khronos Group Inc.
2 * Copyright (c) 2015-2016 Valve Corporation
3 * Copyright (c) 2015-2016 LunarG, Inc.
4 * Copyright (C) 2015-2016 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Chris Forbes <chrisforbes@google.com>
19 */
20#ifndef DEVICE_EXTENSIONS_H_
21#define DEVICE_EXTENSIONS_H_
22
23struct DeviceExtensions {
24 bool khr_swapchain;
25 bool khr_display_swapchain;
26 bool nv_glsl_shader;
27 bool khr_descriptor_update_template;
28 bool khr_shader_draw_parameters;
29 bool khr_maintenance1;
30 bool nv_geometry_shader_passthrough;
31 bool nv_sample_mask_override_coverage;
32 bool nv_viewport_array2;
33 bool khr_subgroup_ballot;
34 bool khr_subgroup_vote;
Chris Forbes8976f742017-05-02 14:52:05 -070035 bool khr_push_descriptor;
36 bool khx_device_group;
37 bool khx_external_memory_fd;
38 bool khx_external_memory_win32;
39 bool khx_external_semaphore_fd;
40 bool khx_external_semaphore_win32;
41 bool ext_debug_marker;
42 bool ext_discard_rectangles;
43 bool ext_display_control;
44 bool amd_draw_indirect_count;
45 bool amd_negative_viewport_height;
46 bool nv_clip_space_w_scaling;
47 bool nv_external_memory;
48 bool nv_external_memory_win32;
49 bool nvx_device_generated_commands;
50 bool khr_incremental_present;
Chris Forbes3fdf41f2017-05-02 14:32:26 -070051
52 void InitFromDeviceCreateInfo(const VkDeviceCreateInfo *pCreateInfo) {
53 using E = DeviceExtensions;
54
55 static const std::pair<char const *, bool E::*> known_extensions[]{
56 {VK_KHR_SWAPCHAIN_EXTENSION_NAME, &E::khr_swapchain},
57 {VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME, &E::khr_display_swapchain},
58 {VK_NV_GLSL_SHADER_EXTENSION_NAME, &E::nv_glsl_shader},
59 {VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, &E::khr_descriptor_update_template},
60 {VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, &E::khr_shader_draw_parameters},
61 {VK_KHR_MAINTENANCE1_EXTENSION_NAME, &E::khr_maintenance1},
62 {VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME, &E::nv_geometry_shader_passthrough},
63 {VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME, &E::nv_sample_mask_override_coverage},
64 {VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME, &E::nv_viewport_array2},
65 {VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME, &E::khr_subgroup_ballot},
66 {VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME, &E::khr_subgroup_vote},
Chris Forbes8976f742017-05-02 14:52:05 -070067 {VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, &E::khr_push_descriptor},
68 {VK_KHX_DEVICE_GROUP_EXTENSION_NAME, &E::khx_device_group},
69 {VK_KHX_EXTERNAL_MEMORY_FD_EXTENSION_NAME, &E::khx_external_memory_fd},
70 {VK_KHX_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, &E::khx_external_semaphore_fd},
71#ifdef VK_USE_PLATFORM_WIN32_KHX
72 {VK_KHX_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, &E::khx_external_memory_win32},
73 {VK_KHX_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, &E::khx_external_semaphore_win32},
74#endif
75 {VK_EXT_DEBUG_MARKER_EXTENSION_NAME, &E::ext_debug_marker},
76 {VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME, &E::ext_discard_rectangles},
77 {VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME, &E::ext_display_control},
78 {VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME, &E::amd_draw_indirect_count},
79 {VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME, &E::amd_negative_viewport_height},
Chris Forbes7d11b8e2017-05-03 08:21:33 -070080 {VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME, &E::nv_clip_space_w_scaling},
Chris Forbes8976f742017-05-02 14:52:05 -070081 {VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME, &E::nv_external_memory},
82#ifdef VK_USE_PLATFORM_WIN32_KHR
83 {VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, &E::nv_external_memory_win32},
84#endif
Chris Forbes7d11b8e2017-05-03 08:21:33 -070085 {VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME, &E::nvx_device_generated_commands},
Chris Forbes8976f742017-05-02 14:52:05 -070086 {VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME, &E::khr_incremental_present},
Chris Forbes3fdf41f2017-05-02 14:32:26 -070087 };
88
89 for (auto ext : known_extensions) {
90 this->*(ext.second) = false;
91 }
92
93 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
94 for (auto ext : known_extensions) {
95 if (!strcmp(ext.first, pCreateInfo->ppEnabledExtensionNames[i])) {
96 this->*(ext.second) = true;
97 break;
98 }
99 }
100 }
101 }
102};
103
Chris Forbesff37d382017-05-02 15:39:16 -0700104struct InstanceExtensions {
105 bool khr_surface;
106 bool khr_display;
107 bool khr_android_surface;
108 bool khr_xcb_surface;
109 bool khr_xlib_surface;
110 bool khr_win32_surface;
111 bool khr_wayland_surface;
112 bool khr_mir_surface;
Chris Forbes8130cc52017-05-02 15:47:16 -0700113 bool khr_get_physical_device_properties2;
114 bool khx_device_group_creation;
115 bool khx_external_memory_capabilities;
116 bool khx_external_semaphore_capabilities;
117 bool ext_acquire_xlib_display;
118 bool ext_direct_mode_display;
119 bool ext_display_surface_counter;
120 bool nv_external_memory_capabilities;
Chris Forbesff37d382017-05-02 15:39:16 -0700121
122 void InitFromInstanceCreateInfo(const VkInstanceCreateInfo *pCreateInfo) {
123 using E = InstanceExtensions;
124
125 static const std::pair<char const *, bool E::*> known_extensions[]{
126 {VK_KHR_SURFACE_EXTENSION_NAME, &E::khr_surface},
127 {VK_KHR_DISPLAY_EXTENSION_NAME, &E::khr_display},
128#ifdef VK_USE_PLATFORM_ANDROID_KHR
129 {VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, &E::khr_android_surface},
130#endif
131#ifdef VK_USE_PLATFORM_XCB_KHR
132 {VK_KHR_XCB_SURFACE_EXTENSION_NAME, &E::khr_xcb_surface},
133#endif
134#ifdef VK_USE_PLATFORM_XLIB_KHR
135 {VK_KHR_XLIB_SURFACE_EXTENSION_NAME, &E::khr_xlib_surface},
136#endif
137#ifdef VK_USE_PLATFORM_WIN32_KHR
138 {VK_KHR_WIN32_SURFACE_EXTENSION_NAME, &E::khr_win32_surface},
139#endif
140#ifdef VK_USE_PLATFORM_WAYLAND_KHR
141 {VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, &E::khr_wayland_surface},
142#endif
143#ifdef VK_USE_PLATFORM_MIR_KHR
144 {VK_KHR_MIR_SURFACE_EXTENSION_NAME, &E::khr_mir_surface},
145#endif
Chris Forbes8130cc52017-05-02 15:47:16 -0700146 {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, &E::khr_get_physical_device_properties2},
147 {VK_KHX_DEVICE_GROUP_CREATION_EXTENSION_NAME, &E::khx_device_group_creation},
148 {VK_KHX_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, &E::khx_external_memory_capabilities},
149 {VK_KHX_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, &E::khx_external_semaphore_capabilities},
150#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
151 {VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME, &E::ext_acquire_xlib_display},
152#endif
153 {VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME, &E::ext_direct_mode_display},
154 {VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME, &E::ext_display_surface_counter},
155 {VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, &E::nv_external_memory_capabilities},
Chris Forbesff37d382017-05-02 15:39:16 -0700156 };
157
158 for (auto ext : known_extensions) {
159 this->*(ext.second) = false;
160 }
161
162 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
163 for (auto ext : known_extensions) {
164 if (!strcmp(ext.first, pCreateInfo->ppEnabledExtensionNames[i])) {
165 this->*(ext.second) = true;
166 break;
167 }
168 }
169 }
170 }
171};
172
Chris Forbes3fdf41f2017-05-02 14:32:26 -0700173#endif