blob: 200aa70aa658f5ab5997bbe350e5ebc49b78654d [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;
35
36 void InitFromDeviceCreateInfo(const VkDeviceCreateInfo *pCreateInfo) {
37 using E = DeviceExtensions;
38
39 static const std::pair<char const *, bool E::*> known_extensions[]{
40 {VK_KHR_SWAPCHAIN_EXTENSION_NAME, &E::khr_swapchain},
41 {VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME, &E::khr_display_swapchain},
42 {VK_NV_GLSL_SHADER_EXTENSION_NAME, &E::nv_glsl_shader},
43 {VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, &E::khr_descriptor_update_template},
44 {VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, &E::khr_shader_draw_parameters},
45 {VK_KHR_MAINTENANCE1_EXTENSION_NAME, &E::khr_maintenance1},
46 {VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME, &E::nv_geometry_shader_passthrough},
47 {VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME, &E::nv_sample_mask_override_coverage},
48 {VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME, &E::nv_viewport_array2},
49 {VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME, &E::khr_subgroup_ballot},
50 {VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME, &E::khr_subgroup_vote},
51 };
52
53 for (auto ext : known_extensions) {
54 this->*(ext.second) = false;
55 }
56
57 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
58 for (auto ext : known_extensions) {
59 if (!strcmp(ext.first, pCreateInfo->ppEnabledExtensionNames[i])) {
60 this->*(ext.second) = true;
61 break;
62 }
63 }
64 }
65 }
66};
67
68#endif