1b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz///////////////////////////////////////////////////////////////////////////////
2e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour//
3b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz// Copyright (c) 2015-2016 The Khronos Group Inc.
4b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz// Copyright (c) 2015-2016 Valve Corporation
5b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz// Copyright (c) 2015-2016 LunarG, Inc.
6b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz// Copyright (c) 2015-2016 Google, Inc.
7e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour//
843b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// Licensed under the Apache License, Version 2.0 (the "License");
943b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// you may not use this file except in compliance with the License.
1043b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// You may obtain a copy of the License at
11e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour//
1243b53e83705f02245da6ae61e31273866a35b833Jon Ashburn//     http://www.apache.org/licenses/LICENSE-2.0
13b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz//
1443b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// Unless required by applicable law or agreed to in writing, software
1543b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// distributed under the License is distributed on an "AS IS" BASIS,
1643b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1743b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// See the License for the specific language governing permissions and
1843b53e83705f02245da6ae61e31273866a35b833Jon Ashburn// limitations under the License.
19b932f109ad6b92419e12f66f3e9087f2b49934cbKarl Schultz///////////////////////////////////////////////////////////////////////////////
20e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
21e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#ifndef VKJSON_H_
22e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#define VKJSON_H_
23e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
24e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#include <vulkan/vulkan.h>
25c824cd749b40d838f14ab159615d76356bb94ed7Antoine Labour#include <string.h>
26c824cd749b40d838f14ab159615d76356bb94ed7Antoine Labour
27e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#include <map>
28e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#include <string>
29e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#include <vector>
30e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
31fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn#ifdef WIN32
32fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn#undef min
33fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn#undef max
34fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn#endif
35fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn
36b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hallstruct VkJsonLayer {
37b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hall  VkLayerProperties properties;
38b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hall  std::vector<VkExtensionProperties> extensions;
39b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hall};
40b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hall
41594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hallstruct VkJsonDevice {
42594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall  VkJsonDevice() {
43fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn          memset(&properties, 0, sizeof(VkPhysicalDeviceProperties));
44fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn          memset(&features, 0, sizeof(VkPhysicalDeviceFeatures));
4573bf24cb361d3b2163cd0e124aff01b5308ad9d5Jesse Hall          memset(&variable_pointer_features, 0,
4673bf24cb361d3b2163cd0e124aff01b5308ad9d5Jesse Hall                 sizeof(VkPhysicalDeviceVariablePointerFeaturesKHR));
47fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn          memset(&memory, 0, sizeof(VkPhysicalDeviceMemoryProperties));
48fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn  }
49fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn  VkPhysicalDeviceProperties properties;
50fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn  VkPhysicalDeviceFeatures features;
5173bf24cb361d3b2163cd0e124aff01b5308ad9d5Jesse Hall  VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointer_features;
52fd1dac3d906bb13f5835da25d0d5e80512736e7dJon Ashburn  VkPhysicalDeviceMemoryProperties memory;
53e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour  std::vector<VkQueueFamilyProperties> queues;
54e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour  std::vector<VkExtensionProperties> extensions;
55e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour  std::vector<VkLayerProperties> layers;
56e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour  std::map<VkFormat, VkFormatProperties> formats;
57e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour};
58e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
59041bd1d26b9e27e308022206210424e7396547daJesse Hallstruct VkJsonInstance {
60b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hall  std::vector<VkJsonLayer> layers;
61b4d24eaa8cdc950e730418898612fe971c176c46Jesse Hall  std::vector<VkExtensionProperties> extensions;
62041bd1d26b9e27e308022206210424e7396547daJesse Hall  std::vector<VkJsonDevice> devices;
63041bd1d26b9e27e308022206210424e7396547daJesse Hall};
64041bd1d26b9e27e308022206210424e7396547daJesse Hall
65041bd1d26b9e27e308022206210424e7396547daJesse HallVkJsonInstance VkJsonGetInstance();
666f328aec9b6c8667e12fee73847d9954814991ddJesse Hallstd::string VkJsonInstanceToJson(const VkJsonInstance& instance);
676f328aec9b6c8667e12fee73847d9954814991ddJesse Hallbool VkJsonInstanceFromJson(const std::string& json,
686f328aec9b6c8667e12fee73847d9954814991ddJesse Hall                            VkJsonInstance* instance,
696f328aec9b6c8667e12fee73847d9954814991ddJesse Hall                            std::string* errors);
70e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
71365754e951120dddb07d6f818897282766f52265Jesse HallVkJsonDevice VkJsonGetDevice(VkInstance instance,
72365754e951120dddb07d6f818897282766f52265Jesse Hall                             VkPhysicalDevice device,
73365754e951120dddb07d6f818897282766f52265Jesse Hall                             uint32_t instanceExtensionCount,
74365754e951120dddb07d6f818897282766f52265Jesse Hall                             const char* const* instanceExtensions);
75594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hallstd::string VkJsonDeviceToJson(const VkJsonDevice& device);
76594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hallbool VkJsonDeviceFromJson(const std::string& json,
77594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall                          VkJsonDevice* device,
78594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall                          std::string* errors);
79e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
80e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labourstd::string VkJsonImageFormatPropertiesToJson(
81e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour    const VkImageFormatProperties& properties);
82e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labourbool VkJsonImageFormatPropertiesFromJson(const std::string& json,
83e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour                                         VkImageFormatProperties* properties,
84e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour                                         std::string* errors);
85e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour
86594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall// Backward-compatibility aliases
87594091db7f508f6073975efddb5fab8d0fb273e7Jesse Halltypedef VkJsonDevice VkJsonAllProperties;
88594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hallinline VkJsonAllProperties VkJsonGetAllProperties(
89594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall    VkPhysicalDevice physicalDevice) {
90365754e951120dddb07d6f818897282766f52265Jesse Hall  return VkJsonGetDevice(VK_NULL_HANDLE, physicalDevice, 0, nullptr);
91594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall}
92594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hallinline std::string VkJsonAllPropertiesToJson(
93594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall    const VkJsonAllProperties& properties) {
94594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall  return VkJsonDeviceToJson(properties);
95594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall}
96594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hallinline bool VkJsonAllPropertiesFromJson(const std::string& json,
97594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall                                        VkJsonAllProperties* properties,
98594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall                                        std::string* errors) {
99594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall  return VkJsonDeviceFromJson(json, properties, errors);
100594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall}
101594091db7f508f6073975efddb5fab8d0fb273e7Jesse Hall
102e3795c1c4e1fd43419a156d9f7858327768ccb76Antoine Labour#endif  // VKJSON_H_
103