Yiwei Zhang | f9a57e6 | 2018-04-05 00:17:22 -0700 | [diff] [blame] | 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // Copyright (c) 2015-2016 The Khronos Group Inc. |
| 4 | // Copyright (c) 2015-2016 Valve Corporation |
| 5 | // Copyright (c) 2015-2016 LunarG, Inc. |
| 6 | // Copyright (c) 2015-2016 Google, Inc. |
| 7 | // |
| 8 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | // you may not use this file except in compliance with the License. |
| 10 | // You may obtain a copy of the License at |
| 11 | // |
| 12 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | // |
| 14 | // Unless required by applicable law or agreed to in writing, software |
| 15 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | // See the License for the specific language governing permissions and |
| 18 | // limitations under the License. |
| 19 | /////////////////////////////////////////////////////////////////////////////// |
| 20 | |
| 21 | #ifndef VKJSON_H_ |
| 22 | #define VKJSON_H_ |
| 23 | |
| 24 | #include <vulkan/vulkan.h> |
| 25 | #include <string.h> |
| 26 | |
| 27 | #include <map> |
| 28 | #include <string> |
| 29 | #include <vector> |
| 30 | |
| 31 | #ifdef WIN32 |
| 32 | #undef min |
| 33 | #undef max |
| 34 | #endif |
| 35 | |
| 36 | #ifndef VK_API_VERSION_1_0 |
| 37 | #define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0) |
| 38 | #endif |
| 39 | |
| 40 | #ifndef VK_API_VERSION_1_1 |
| 41 | #define VK_API_VERSION_1_1 VK_MAKE_VERSION(1, 1, 0) |
| 42 | #endif |
| 43 | |
| 44 | struct VkJsonLayer { |
| 45 | VkLayerProperties properties; |
| 46 | std::vector<VkExtensionProperties> extensions; |
| 47 | }; |
| 48 | |
Yiwei Zhang | 7b4169d | 2018-10-02 18:58:31 -0700 | [diff] [blame^] | 49 | struct VkJsonExtDriverProperties { |
| 50 | VkJsonExtDriverProperties() { |
| 51 | reported = false; |
| 52 | memset(&driver_properties_khr, 0, |
| 53 | sizeof(VkPhysicalDeviceDriverPropertiesKHR)); |
| 54 | } |
| 55 | bool reported; |
| 56 | VkPhysicalDeviceDriverPropertiesKHR driver_properties_khr; |
| 57 | }; |
| 58 | |
Yiwei Zhang | f9a57e6 | 2018-04-05 00:17:22 -0700 | [diff] [blame] | 59 | struct VkJsonExtVariablePointerFeatures { |
| 60 | VkJsonExtVariablePointerFeatures() { |
Yiwei Zhang | 7b4169d | 2018-10-02 18:58:31 -0700 | [diff] [blame^] | 61 | reported = false; |
Yiwei Zhang | f9a57e6 | 2018-04-05 00:17:22 -0700 | [diff] [blame] | 62 | memset(&variable_pointer_features_khr, 0, |
| 63 | sizeof(VkPhysicalDeviceVariablePointerFeaturesKHR)); |
| 64 | } |
Yiwei Zhang | 7b4169d | 2018-10-02 18:58:31 -0700 | [diff] [blame^] | 65 | bool reported; |
Yiwei Zhang | f9a57e6 | 2018-04-05 00:17:22 -0700 | [diff] [blame] | 66 | VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointer_features_khr; |
| 67 | }; |
| 68 | |
| 69 | struct VkJsonDevice { |
| 70 | VkJsonDevice() { |
| 71 | memset(&properties, 0, sizeof(VkPhysicalDeviceProperties)); |
| 72 | memset(&features, 0, sizeof(VkPhysicalDeviceFeatures)); |
| 73 | memset(&memory, 0, sizeof(VkPhysicalDeviceMemoryProperties)); |
| 74 | memset(&subgroup_properties, 0, sizeof(VkPhysicalDeviceSubgroupProperties)); |
| 75 | memset(&point_clipping_properties, 0, |
| 76 | sizeof(VkPhysicalDevicePointClippingProperties)); |
| 77 | memset(&multiview_properties, 0, |
| 78 | sizeof(VkPhysicalDeviceMultiviewProperties)); |
| 79 | memset(&id_properties, 0, sizeof(VkPhysicalDeviceIDProperties)); |
| 80 | memset(&maintenance3_properties, 0, |
| 81 | sizeof(VkPhysicalDeviceMaintenance3Properties)); |
| 82 | memset(&bit16_storage_features, 0, |
| 83 | sizeof(VkPhysicalDevice16BitStorageFeatures)); |
| 84 | memset(&multiview_features, 0, sizeof(VkPhysicalDeviceMultiviewFeatures)); |
| 85 | memset(&variable_pointer_features, 0, |
| 86 | sizeof(VkPhysicalDeviceVariablePointerFeatures)); |
| 87 | memset(&protected_memory_features, 0, |
| 88 | sizeof(VkPhysicalDeviceProtectedMemoryFeatures)); |
| 89 | memset(&sampler_ycbcr_conversion_features, 0, |
| 90 | sizeof(VkPhysicalDeviceSamplerYcbcrConversionFeatures)); |
| 91 | memset(&shader_draw_parameter_features, 0, |
| 92 | sizeof(VkPhysicalDeviceShaderDrawParameterFeatures)); |
| 93 | } |
| 94 | VkPhysicalDeviceProperties properties; |
| 95 | VkPhysicalDeviceFeatures features; |
Yiwei Zhang | 7b4169d | 2018-10-02 18:58:31 -0700 | [diff] [blame^] | 96 | VkJsonExtDriverProperties ext_driver_properties; |
Yiwei Zhang | f9a57e6 | 2018-04-05 00:17:22 -0700 | [diff] [blame] | 97 | VkJsonExtVariablePointerFeatures ext_variable_pointer_features; |
| 98 | VkPhysicalDeviceMemoryProperties memory; |
| 99 | std::vector<VkQueueFamilyProperties> queues; |
| 100 | std::vector<VkExtensionProperties> extensions; |
| 101 | std::vector<VkLayerProperties> layers; |
| 102 | std::map<VkFormat, VkFormatProperties> formats; |
| 103 | VkPhysicalDeviceSubgroupProperties subgroup_properties; |
| 104 | VkPhysicalDevicePointClippingProperties point_clipping_properties; |
| 105 | VkPhysicalDeviceMultiviewProperties multiview_properties; |
| 106 | VkPhysicalDeviceIDProperties id_properties; |
| 107 | VkPhysicalDeviceMaintenance3Properties maintenance3_properties; |
| 108 | VkPhysicalDevice16BitStorageFeatures bit16_storage_features; |
| 109 | VkPhysicalDeviceMultiviewFeatures multiview_features; |
| 110 | VkPhysicalDeviceVariablePointerFeatures variable_pointer_features; |
| 111 | VkPhysicalDeviceProtectedMemoryFeatures protected_memory_features; |
| 112 | VkPhysicalDeviceSamplerYcbcrConversionFeatures |
| 113 | sampler_ycbcr_conversion_features; |
| 114 | VkPhysicalDeviceShaderDrawParameterFeatures shader_draw_parameter_features; |
| 115 | std::map<VkExternalFenceHandleTypeFlagBits, VkExternalFenceProperties> |
| 116 | external_fence_properties; |
| 117 | std::map<VkExternalSemaphoreHandleTypeFlagBits, VkExternalSemaphoreProperties> |
| 118 | external_semaphore_properties; |
| 119 | }; |
| 120 | |
| 121 | struct VkJsonDeviceGroup { |
| 122 | VkJsonDeviceGroup() { |
| 123 | memset(&properties, 0, sizeof(VkPhysicalDeviceGroupProperties)); |
| 124 | } |
| 125 | VkPhysicalDeviceGroupProperties properties; |
| 126 | std::vector<uint32_t> device_inds; |
| 127 | }; |
| 128 | |
| 129 | struct VkJsonInstance { |
| 130 | VkJsonInstance() : api_version(0) {} |
| 131 | uint32_t api_version; |
| 132 | std::vector<VkJsonLayer> layers; |
| 133 | std::vector<VkExtensionProperties> extensions; |
| 134 | std::vector<VkJsonDevice> devices; |
| 135 | std::vector<VkJsonDeviceGroup> device_groups; |
| 136 | }; |
| 137 | |
| 138 | VkJsonInstance VkJsonGetInstance(); |
| 139 | std::string VkJsonInstanceToJson(const VkJsonInstance& instance); |
| 140 | bool VkJsonInstanceFromJson(const std::string& json, |
| 141 | VkJsonInstance* instance, |
| 142 | std::string* errors); |
| 143 | |
| 144 | VkJsonDevice VkJsonGetDevice(VkInstance instance, |
| 145 | VkPhysicalDevice device, |
| 146 | uint32_t instanceExtensionCount, |
| 147 | const char* const* instanceExtensions); |
| 148 | std::string VkJsonDeviceToJson(const VkJsonDevice& device); |
| 149 | bool VkJsonDeviceFromJson(const std::string& json, |
| 150 | VkJsonDevice* device, |
| 151 | std::string* errors); |
| 152 | |
| 153 | std::string VkJsonImageFormatPropertiesToJson( |
| 154 | const VkImageFormatProperties& properties); |
| 155 | bool VkJsonImageFormatPropertiesFromJson(const std::string& json, |
| 156 | VkImageFormatProperties* properties, |
| 157 | std::string* errors); |
| 158 | |
| 159 | // Backward-compatibility aliases |
| 160 | typedef VkJsonDevice VkJsonAllProperties; |
| 161 | inline VkJsonAllProperties VkJsonGetAllProperties( |
| 162 | VkPhysicalDevice physicalDevice) { |
| 163 | return VkJsonGetDevice(VK_NULL_HANDLE, physicalDevice, 0, nullptr); |
| 164 | } |
| 165 | inline std::string VkJsonAllPropertiesToJson( |
| 166 | const VkJsonAllProperties& properties) { |
| 167 | return VkJsonDeviceToJson(properties); |
| 168 | } |
| 169 | inline bool VkJsonAllPropertiesFromJson(const std::string& json, |
| 170 | VkJsonAllProperties* properties, |
| 171 | std::string* errors) { |
| 172 | return VkJsonDeviceFromJson(json, properties, errors); |
| 173 | } |
| 174 | |
| 175 | #endif // VKJSON_H_ |