Home | History | Annotate | Download | only in vkjson
      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 // Permission is hereby granted, free of charge, to any person obtaining a copy
      9 // of this software and/or associated documentation files (the "Materials"), to
     10 // deal in the Materials without restriction, including without limitation the
     11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     12 // sell copies of the Materials, and to permit persons to whom the Materials are
     13 // furnished to do so, subject to the following conditions:
     14 //
     15 // The above copyright notice(s) and this permission notice shall be included in
     16 // all copies or substantial portions of the Materials.
     17 //
     18 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     21 //
     22 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
     23 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     24 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
     25 // USE OR OTHER DEALINGS IN THE MATERIALS.
     26 ///////////////////////////////////////////////////////////////////////////////
     27 
     28 #ifndef VKJSON_H_
     29 #define VKJSON_H_
     30 
     31 #include <vulkan/vulkan.h>
     32 #include <string.h>
     33 
     34 #include <map>
     35 #include <string>
     36 #include <vector>
     37 
     38 #ifdef WIN32
     39 #undef min
     40 #undef max
     41 #endif
     42 
     43 struct VkJsonLayer {
     44   VkLayerProperties properties;
     45   std::vector<VkExtensionProperties> extensions;
     46 };
     47 
     48 struct VkJsonDevice {
     49   VkJsonDevice() {
     50           memset(&properties, 0, sizeof(VkPhysicalDeviceProperties));
     51           memset(&features, 0, sizeof(VkPhysicalDeviceFeatures));
     52           memset(&memory, 0, sizeof(VkPhysicalDeviceMemoryProperties));
     53   }
     54   VkPhysicalDeviceProperties properties;
     55   VkPhysicalDeviceFeatures features;
     56   VkPhysicalDeviceMemoryProperties memory;
     57   std::vector<VkQueueFamilyProperties> queues;
     58   std::vector<VkExtensionProperties> extensions;
     59   std::vector<VkLayerProperties> layers;
     60   std::map<VkFormat, VkFormatProperties> formats;
     61 };
     62 
     63 struct VkJsonInstance {
     64   std::vector<VkJsonLayer> layers;
     65   std::vector<VkExtensionProperties> extensions;
     66   std::vector<VkJsonDevice> devices;
     67 };
     68 
     69 VkJsonInstance VkJsonGetInstance();
     70 std::string VkJsonInstanceToJson(const VkJsonInstance& instance);
     71 bool VkJsonInstanceFromJson(const std::string& json,
     72                             VkJsonInstance* instance,
     73                             std::string* errors);
     74 
     75 VkJsonDevice VkJsonGetDevice(VkPhysicalDevice device);
     76 std::string VkJsonDeviceToJson(const VkJsonDevice& device);
     77 bool VkJsonDeviceFromJson(const std::string& json,
     78                           VkJsonDevice* device,
     79                           std::string* errors);
     80 
     81 std::string VkJsonImageFormatPropertiesToJson(
     82     const VkImageFormatProperties& properties);
     83 bool VkJsonImageFormatPropertiesFromJson(const std::string& json,
     84                                          VkImageFormatProperties* properties,
     85                                          std::string* errors);
     86 
     87 // Backward-compatibility aliases
     88 typedef VkJsonDevice VkJsonAllProperties;
     89 inline VkJsonAllProperties VkJsonGetAllProperties(
     90     VkPhysicalDevice physicalDevice) {
     91   return VkJsonGetDevice(physicalDevice);
     92 }
     93 inline std::string VkJsonAllPropertiesToJson(
     94     const VkJsonAllProperties& properties) {
     95   return VkJsonDeviceToJson(properties);
     96 }
     97 inline bool VkJsonAllPropertiesFromJson(const std::string& json,
     98                                         VkJsonAllProperties* properties,
     99                                         std::string* errors) {
    100   return VkJsonDeviceFromJson(json, properties, errors);
    101 }
    102 
    103 #endif  // VKJSON_H_
    104