blob: d74644ca8edb92caddd0f6fb29d9fdb8ce2c613a [file] [log] [blame]
Yiwei Zhangf9a57e62018-04-05 00:17:22 -07001///////////////////////////////////////////////////////////////////////////////
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
Yiwei Zhangf9a57e62018-04-05 00:17:22 -070024#include <string.h>
Nikita Gupta3c2535d2025-03-10 10:00:27 -070025#include <vulkan/vulkan.h>
Yiwei Zhangf9a57e62018-04-05 00:17:22 -070026
27#include <map>
28#include <string>
29#include <vector>
30
31#ifdef WIN32
32#undef min
33#undef max
34#endif
35
Yiwei Zhangf9a57e62018-04-05 00:17:22 -070036struct VkJsonLayer {
37 VkLayerProperties properties;
38 std::vector<VkExtensionProperties> extensions;
39};
40
Nikita Gupta3c2535d2025-03-10 10:00:27 -070041struct VkJsonKHRVariablePointers {
42 VkJsonKHRVariablePointers() {
43 reported = false;
44 memset(&variable_pointer_features_khr, 0,
45 sizeof(VkPhysicalDeviceVariablePointerFeaturesKHR));
46 memset(&variable_pointers_features_khr, 0,
47 sizeof(VkPhysicalDeviceVariablePointersFeaturesKHR));
48 }
49 bool reported;
50 VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointer_features_khr;
51 VkPhysicalDeviceVariablePointersFeaturesKHR variable_pointers_features_khr;
52};
53
54struct VkJsonKHRShaderFloat16Int8 {
55 VkJsonKHRShaderFloat16Int8() {
56 reported = false;
57 memset(&shader_float16_int8_features_khr, 0,
58 sizeof(VkPhysicalDeviceShaderFloat16Int8FeaturesKHR));
59 memset(&float16_int8_features_khr, 0,
60 sizeof(VkPhysicalDeviceFloat16Int8FeaturesKHR));
61 }
62 bool reported;
63 VkPhysicalDeviceShaderFloat16Int8FeaturesKHR shader_float16_int8_features_khr;
64 VkPhysicalDeviceFloat16Int8FeaturesKHR float16_int8_features_khr;
65};
66
67struct VkJsonExtImage2dViewOf3d {
68 VkJsonExtImage2dViewOf3d() {
69 reported = false;
70 memset(&image_2d_view_of_3d_features_ext, 0,
71 sizeof(VkPhysicalDeviceImage2DViewOf3DFeaturesEXT));
72 }
73 bool reported;
74 VkPhysicalDeviceImage2DViewOf3DFeaturesEXT image_2d_view_of_3d_features_ext;
75};
76
77struct VkJsonExtCustomBorderColor {
78 VkJsonExtCustomBorderColor() {
79 reported = false;
80 memset(&custom_border_color_features_ext, 0,
81 sizeof(VkPhysicalDeviceCustomBorderColorFeaturesEXT));
82 }
83 bool reported;
84 VkPhysicalDeviceCustomBorderColorFeaturesEXT custom_border_color_features_ext;
85};
86
87struct VkJsonExtPrimitiveTopologyListRestart {
88 VkJsonExtPrimitiveTopologyListRestart() {
89 reported = false;
90 memset(&primitive_topology_list_restart_features_ext, 0,
91 sizeof(VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT));
92 }
93 bool reported;
94 VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT
95 primitive_topology_list_restart_features_ext;
96};
97
98struct VkJsonExtProvokingVertex {
99 VkJsonExtProvokingVertex() {
100 reported = false;
101 memset(&provoking_vertex_features_ext, 0,
102 sizeof(VkPhysicalDeviceProvokingVertexFeaturesEXT));
103 }
104 bool reported;
105 VkPhysicalDeviceProvokingVertexFeaturesEXT provoking_vertex_features_ext;
106};
107
108struct VkJsonKHRIndexTypeUint8 {
109 VkJsonKHRIndexTypeUint8() {
110 reported = false;
111 memset(&index_type_uint8_features_khr, 0,
112 sizeof(VkPhysicalDeviceIndexTypeUint8FeaturesKHR));
113 }
114 bool reported;
115 VkPhysicalDeviceIndexTypeUint8FeaturesKHR index_type_uint8_features_khr;
116};
117
118struct VkJsonExtIndexTypeUint8 {
119 VkJsonExtIndexTypeUint8() {
120 reported = false;
121 memset(&index_type_uint8_features_ext, 0,
122 sizeof(VkPhysicalDeviceIndexTypeUint8FeaturesEXT));
123 }
124 bool reported;
125 VkPhysicalDeviceIndexTypeUint8FeaturesEXT index_type_uint8_features_ext;
126};
127
128struct VkJsonKHRVertexAttributeDivisor {
129 VkJsonKHRVertexAttributeDivisor() {
130 reported = false;
131 memset(&vertex_attribute_divisor_features_khr, 0,
132 sizeof(VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR));
133 }
134 bool reported;
135 VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR
136 vertex_attribute_divisor_features_khr;
137};
138
139struct VkJsonExtVertexAttributeDivisor {
140 VkJsonExtVertexAttributeDivisor() {
141 reported = false;
142 memset(&vertex_attribute_divisor_features_ext, 0,
143 sizeof(VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT));
144 }
145 bool reported;
146 VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT
147 vertex_attribute_divisor_features_ext;
148};
149
150struct VkJsonExtTransformFeedback {
151 VkJsonExtTransformFeedback() {
152 reported = false;
153 memset(&transform_feedback_features_ext, 0,
154 sizeof(VkPhysicalDeviceTransformFeedbackFeaturesEXT));
155 }
156 bool reported;
157 VkPhysicalDeviceTransformFeedbackFeaturesEXT transform_feedback_features_ext;
158};
159
160struct VkJsonKHRShaderSubgroupUniformControlFlow {
161 VkJsonKHRShaderSubgroupUniformControlFlow() {
162 reported = false;
163 memset(&shader_subgroup_uniform_control_flow_features_khr, 0,
164 sizeof(VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR));
165 }
166 bool reported;
167 VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR
168 shader_subgroup_uniform_control_flow_features_khr;
169};
170
171struct VkJsonKHRShaderSubgroupExtendedTypes {
172 VkJsonKHRShaderSubgroupExtendedTypes() {
173 reported = false;
174 memset(&shader_subgroup_extended_types_features_khr, 0,
175 sizeof(VkPhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR));
176 }
177 bool reported;
178 VkPhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR
179 shader_subgroup_extended_types_features_khr;
180};
181
182struct VkJsonKHR8bitStorage {
183 VkJsonKHR8bitStorage() {
184 reported = false;
185 memset(&bit8_storage_features_khr, 0,
186 sizeof(VkPhysicalDevice8BitStorageFeaturesKHR));
187 }
188 bool reported;
189 VkPhysicalDevice8BitStorageFeaturesKHR bit8_storage_features_khr;
190};
191
192struct VkJsonKHRShaderIntegerDotProduct {
193 VkJsonKHRShaderIntegerDotProduct() {
194 reported = false;
195 memset(&shader_integer_dot_product_features_khr, 0,
196 sizeof(VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR));
197 }
198 bool reported;
199 VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR
200 shader_integer_dot_product_features_khr;
201};
202
203struct VkJsonIMGRelaxedLineRasterization {
204 VkJsonIMGRelaxedLineRasterization() {
205 reported = false;
206 memset(&relaxed_line_rasterization_features_img, 0,
207 sizeof(VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG));
208 }
209 bool reported;
210 VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG
211 relaxed_line_rasterization_features_img;
212};
213
214struct VkJsonKHRLineRasterization {
215 VkJsonKHRLineRasterization() {
216 reported = false;
217 memset(&line_rasterization_features_khr, 0,
218 sizeof(VkPhysicalDeviceLineRasterizationFeaturesKHR));
219 }
220 bool reported;
221 VkPhysicalDeviceLineRasterizationFeaturesKHR line_rasterization_features_khr;
222};
223
224struct VkJsonExtLineRasterization {
225 VkJsonExtLineRasterization() {
226 reported = false;
227 memset(&line_rasterization_features_ext, 0,
228 sizeof(VkPhysicalDeviceLineRasterizationFeaturesEXT));
229 }
230 bool reported;
231 VkPhysicalDeviceLineRasterizationFeaturesEXT line_rasterization_features_ext;
232};
233
234struct VkJsonExtPrimitivesGeneratedQuery {
235 VkJsonExtPrimitivesGeneratedQuery() {
236 reported = false;
237 memset(&primitives_generated_query_features_ext, 0,
238 sizeof(VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT));
239 }
240 bool reported;
241 VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT
242 primitives_generated_query_features_ext;
243};
244
245struct VkJsonKHRShaderFloatControls {
246 VkJsonKHRShaderFloatControls() {
247 reported = false;
248 memset(&float_controls_properties_khr, 0,
249 sizeof(VkPhysicalDeviceFloatControlsPropertiesKHR));
250 }
251 bool reported;
252 VkPhysicalDeviceFloatControlsPropertiesKHR float_controls_properties_khr;
253};
254
255struct VkJsonKHRDriverProperties {
256 VkJsonKHRDriverProperties() {
Yiwei Zhang7b4169d2018-10-02 18:58:31 -0700257 reported = false;
258 memset(&driver_properties_khr, 0,
259 sizeof(VkPhysicalDeviceDriverPropertiesKHR));
260 }
261 bool reported;
262 VkPhysicalDeviceDriverPropertiesKHR driver_properties_khr;
263};
264
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700265struct VkJsonCore11 {
266 VkPhysicalDeviceVulkan11Properties properties;
267 VkPhysicalDeviceVulkan11Features features;
Peiyong Linc1b5ffb2020-02-27 19:31:51 -0800268};
269
Trevor David Blackd35f0f62021-09-07 23:39:36 +0000270struct VkJsonCore12 {
271 VkPhysicalDeviceVulkan12Properties properties;
272 VkPhysicalDeviceVulkan12Features features;
273};
274
Trevor David Black79883792021-11-04 23:46:31 +0000275struct VkJsonCore13 {
276 VkPhysicalDeviceVulkan13Properties properties;
277 VkPhysicalDeviceVulkan13Features features;
278};
279
Tom Murphy80d9ca72024-10-17 09:52:47 +0000280struct VkJsonCore14 {
281 VkPhysicalDeviceVulkan14Properties properties;
282 VkPhysicalDeviceVulkan14Features features;
283};
284
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700285struct VkJsonDevice {
286 VkJsonDevice() {
287 memset(&properties, 0, sizeof(VkPhysicalDeviceProperties));
288 memset(&features, 0, sizeof(VkPhysicalDeviceFeatures));
289 memset(&memory, 0, sizeof(VkPhysicalDeviceMemoryProperties));
290 memset(&subgroup_properties, 0, sizeof(VkPhysicalDeviceSubgroupProperties));
291 memset(&point_clipping_properties, 0,
292 sizeof(VkPhysicalDevicePointClippingProperties));
293 memset(&multiview_properties, 0,
294 sizeof(VkPhysicalDeviceMultiviewProperties));
295 memset(&id_properties, 0, sizeof(VkPhysicalDeviceIDProperties));
296 memset(&maintenance3_properties, 0,
297 sizeof(VkPhysicalDeviceMaintenance3Properties));
298 memset(&bit16_storage_features, 0,
299 sizeof(VkPhysicalDevice16BitStorageFeatures));
300 memset(&multiview_features, 0, sizeof(VkPhysicalDeviceMultiviewFeatures));
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700301 memset(&variable_pointers_features, 0,
302 sizeof(VkPhysicalDeviceVariablePointersFeatures));
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700303 memset(&protected_memory_features, 0,
304 sizeof(VkPhysicalDeviceProtectedMemoryFeatures));
305 memset(&sampler_ycbcr_conversion_features, 0,
306 sizeof(VkPhysicalDeviceSamplerYcbcrConversionFeatures));
307 memset(&shader_draw_parameter_features, 0,
308 sizeof(VkPhysicalDeviceShaderDrawParameterFeatures));
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700309 memset(&core11, 0, sizeof(VkJsonCore11));
Trevor David Blackd35f0f62021-09-07 23:39:36 +0000310 memset(&core12, 0, sizeof(VkJsonCore12));
Trevor David Black79883792021-11-04 23:46:31 +0000311 memset(&core13, 0, sizeof(VkJsonCore13));
Tom Murphy80d9ca72024-10-17 09:52:47 +0000312 memset(&core14, 0, sizeof(VkJsonCore14));
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700313 }
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700314 VkJsonKHRVariablePointers khr_variable_pointers;
315 VkJsonKHRShaderFloat16Int8 khr_shader_float16_int8;
316 VkJsonExtImage2dViewOf3d ext_image_2d_view_of_3d;
317 VkJsonExtCustomBorderColor ext_custom_border_color;
318 VkJsonExtPrimitiveTopologyListRestart ext_primitive_topology_list_restart;
319 VkJsonExtProvokingVertex ext_provoking_vertex;
320 VkJsonKHRIndexTypeUint8 khr_index_type_uint8;
321 VkJsonExtIndexTypeUint8 ext_index_type_uint8;
322 VkJsonKHRVertexAttributeDivisor khr_vertex_attribute_divisor;
323 VkJsonExtVertexAttributeDivisor ext_vertex_attribute_divisor;
324 VkJsonExtTransformFeedback ext_transform_feedback;
325 VkJsonKHRShaderSubgroupUniformControlFlow
326 khr_shader_subgroup_uniform_control_flow;
327 VkJsonKHRShaderSubgroupExtendedTypes khr_shader_subgroup_extended_types;
328 VkJsonKHR8bitStorage khr_8bit_storage;
329 VkJsonKHRShaderIntegerDotProduct khr_shader_integer_dot_product;
330 VkJsonIMGRelaxedLineRasterization img_relaxed_line_rasterization;
331 VkJsonKHRLineRasterization khr_line_rasterization;
332 VkJsonExtLineRasterization ext_line_rasterization;
333 VkJsonExtPrimitivesGeneratedQuery ext_primitives_generated_query;
334 VkJsonKHRShaderFloatControls khr_shader_float_controls;
335 VkJsonKHRDriverProperties khr_driver_properties;
336 VkJsonCore11 core11;
337 VkJsonCore12 core12;
338 VkJsonCore13 core13;
339 VkJsonCore14 core14;
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700340 VkPhysicalDeviceProperties properties;
341 VkPhysicalDeviceFeatures features;
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700342 VkPhysicalDeviceMemoryProperties memory;
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700343 VkPhysicalDeviceSubgroupProperties subgroup_properties;
344 VkPhysicalDevicePointClippingProperties point_clipping_properties;
345 VkPhysicalDeviceMultiviewProperties multiview_properties;
346 VkPhysicalDeviceIDProperties id_properties;
347 VkPhysicalDeviceMaintenance3Properties maintenance3_properties;
348 VkPhysicalDevice16BitStorageFeatures bit16_storage_features;
349 VkPhysicalDeviceMultiviewFeatures multiview_features;
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700350 VkPhysicalDeviceVariablePointersFeatures variable_pointers_features;
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700351 VkPhysicalDeviceProtectedMemoryFeatures protected_memory_features;
352 VkPhysicalDeviceSamplerYcbcrConversionFeatures
353 sampler_ycbcr_conversion_features;
354 VkPhysicalDeviceShaderDrawParameterFeatures shader_draw_parameter_features;
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700355 std::vector<VkQueueFamilyProperties> queues;
356 std::vector<VkExtensionProperties> extensions;
357 std::vector<VkLayerProperties> layers;
358 std::map<VkFormat, VkFormatProperties> formats;
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700359 std::map<VkExternalFenceHandleTypeFlagBits, VkExternalFenceProperties>
360 external_fence_properties;
361 std::map<VkExternalSemaphoreHandleTypeFlagBits, VkExternalSemaphoreProperties>
362 external_semaphore_properties;
363};
364
365struct VkJsonDeviceGroup {
366 VkJsonDeviceGroup() {
367 memset(&properties, 0, sizeof(VkPhysicalDeviceGroupProperties));
368 }
369 VkPhysicalDeviceGroupProperties properties;
370 std::vector<uint32_t> device_inds;
371};
372
373struct VkJsonInstance {
374 VkJsonInstance() : api_version(0) {}
375 uint32_t api_version;
376 std::vector<VkJsonLayer> layers;
377 std::vector<VkExtensionProperties> extensions;
378 std::vector<VkJsonDevice> devices;
379 std::vector<VkJsonDeviceGroup> device_groups;
380};
381
382VkJsonInstance VkJsonGetInstance();
383std::string VkJsonInstanceToJson(const VkJsonInstance& instance);
384bool VkJsonInstanceFromJson(const std::string& json,
385 VkJsonInstance* instance,
386 std::string* errors);
387
Yiwei Zhang91fc3dc2020-07-05 23:33:22 -0700388VkJsonDevice VkJsonGetDevice(VkPhysicalDevice device);
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700389std::string VkJsonDeviceToJson(const VkJsonDevice& device);
390bool VkJsonDeviceFromJson(const std::string& json,
391 VkJsonDevice* device,
392 std::string* errors);
393
394std::string VkJsonImageFormatPropertiesToJson(
395 const VkImageFormatProperties& properties);
396bool VkJsonImageFormatPropertiesFromJson(const std::string& json,
397 VkImageFormatProperties* properties,
398 std::string* errors);
399
400// Backward-compatibility aliases
401typedef VkJsonDevice VkJsonAllProperties;
402inline VkJsonAllProperties VkJsonGetAllProperties(
403 VkPhysicalDevice physicalDevice) {
Yiwei Zhang91fc3dc2020-07-05 23:33:22 -0700404 return VkJsonGetDevice(physicalDevice);
Yiwei Zhangf9a57e62018-04-05 00:17:22 -0700405}
406inline std::string VkJsonAllPropertiesToJson(
407 const VkJsonAllProperties& properties) {
408 return VkJsonDeviceToJson(properties);
409}
410inline bool VkJsonAllPropertiesFromJson(const std::string& json,
411 VkJsonAllProperties* properties,
412 std::string* errors) {
413 return VkJsonDeviceFromJson(json, properties, errors);
414}
415
Nikita Gupta3c2535d2025-03-10 10:00:27 -0700416#endif // VKJSON_H_