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 // 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 struct VkJsonLayer {
     37   VkLayerProperties properties;
     38   std::vector<VkExtensionProperties> extensions;
     39 };
     40 
     41 struct VkJsonDevice {
     42   VkJsonDevice() {
     43           memset(&properties, 0, sizeof(VkPhysicalDeviceProperties));
     44           memset(&features, 0, sizeof(VkPhysicalDeviceFeatures));
     45           memset(&variable_pointer_features, 0,
     46                  sizeof(VkPhysicalDeviceVariablePointerFeaturesKHR));
     47           memset(&memory, 0, sizeof(VkPhysicalDeviceMemoryProperties));
     48   }
     49   VkPhysicalDeviceProperties properties;
     50   VkPhysicalDeviceFeatures features;
     51   VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointer_features;
     52   VkPhysicalDeviceMemoryProperties memory;
     53   std::vector<VkQueueFamilyProperties> queues;
     54   std::vector<VkExtensionProperties> extensions;
     55   std::vector<VkLayerProperties> layers;
     56   std::map<VkFormat, VkFormatProperties> formats;
     57 };
     58 
     59 struct VkJsonInstance {
     60   std::vector<VkJsonLayer> layers;
     61   std::vector<VkExtensionProperties> extensions;
     62   std::vector<VkJsonDevice> devices;
     63 };
     64 
     65 VkJsonInstance VkJsonGetInstance();
     66 std::string VkJsonInstanceToJson(const VkJsonInstance& instance);
     67 bool VkJsonInstanceFromJson(const std::string& json,
     68                             VkJsonInstance* instance,
     69                             std::string* errors);
     70 
     71 VkJsonDevice VkJsonGetDevice(VkInstance instance,
     72                              VkPhysicalDevice device,
     73                              uint32_t instanceExtensionCount,
     74                              const char* const* instanceExtensions);
     75 std::string VkJsonDeviceToJson(const VkJsonDevice& device);
     76 bool VkJsonDeviceFromJson(const std::string& json,
     77                           VkJsonDevice* device,
     78                           std::string* errors);
     79 
     80 std::string VkJsonImageFormatPropertiesToJson(
     81     const VkImageFormatProperties& properties);
     82 bool VkJsonImageFormatPropertiesFromJson(const std::string& json,
     83                                          VkImageFormatProperties* properties,
     84                                          std::string* errors);
     85 
     86 // Backward-compatibility aliases
     87 typedef VkJsonDevice VkJsonAllProperties;
     88 inline VkJsonAllProperties VkJsonGetAllProperties(
     89     VkPhysicalDevice physicalDevice) {
     90   return VkJsonGetDevice(VK_NULL_HANDLE, physicalDevice, 0, nullptr);
     91 }
     92 inline std::string VkJsonAllPropertiesToJson(
     93     const VkJsonAllProperties& properties) {
     94   return VkJsonDeviceToJson(properties);
     95 }
     96 inline bool VkJsonAllPropertiesFromJson(const std::string& json,
     97                                         VkJsonAllProperties* properties,
     98                                         std::string* errors) {
     99   return VkJsonDeviceFromJson(json, properties, errors);
    100 }
    101 
    102 #endif  // VKJSON_H_
    103